]> sigrok.org Git - pulseview.git/blob - pv/view/signalscalehandle.hpp
67dcf14d0382a39596047b920d6ced6a2a236811
[pulseview.git] / pv / view / signalscalehandle.hpp
1 /*
2  * This file is part of the PulseView project.
3  *
4  * Copyright (C) 2015 Joel Holdsworth <joel@airwebreathe.org.uk>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19  */
20
21 #ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_SIGNALSCALEHANDLE_HPP
22 #define PULSEVIEW_PV_VIEWS_TRACEVIEW_SIGNALSCALEHANDLE_HPP
23
24 #include "rowitem.hpp"
25
26 namespace pv {
27 namespace views {
28 namespace TraceView {
29
30 class Signal;
31
32 /**
33  * A row item owned by a @c Signal that implements the v-scale adjustment grab
34  * handle.
35  */
36 class SignalScaleHandle : public RowItem
37 {
38         Q_OBJECT
39 public:
40         /**
41          * Constructor
42          */
43         explicit SignalScaleHandle(Signal &owner);
44
45 public:
46         /**
47          * Returns true if the parent item is enabled.
48          */
49         bool enabled() const;
50
51         /**
52          * Selects or deselects the signal.
53          */
54         void select(bool select = true);
55
56         /**
57          * Sets this item into the un-dragged state.
58          */
59         void drag_release();
60
61         /**
62          * Drags the item to a delta relative to the drag point.
63          * @param delta the offset from the drag point.
64          */
65         void drag_by(const QPoint &delta);
66
67         /**
68          * Get the drag point.
69          * @param rect the rectangle of the widget area.
70          */
71         QPoint point(const QRect &rect) const;
72
73         /**
74          * Computes the outline rectangle of the viewport hit-box.
75          * @param rect the rectangle of the viewport area.
76          * @return Returns the rectangle of the hit-box.
77          */
78         QRectF hit_box_rect(const ViewItemPaintParams &pp) const;
79
80         /**
81          * Paints the foreground layer of the item with a QPainter
82          * @param p the QPainter to paint into.
83          * @param pp the painting parameters object to paint with.
84          */
85         void paint_fore(QPainter &p, const ViewItemPaintParams &pp);
86
87 private:
88         Signal &owner_;
89 };
90
91 } // namespace TraceView
92 } // namespace views
93 } // namespace pv
94
95 #endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_SIGNALSCALEHANDLE_HPP