]>
Commit | Line | Data |
---|---|---|
23935421 JH |
1 | /* |
2 | * This file is part of the PulseView project. | |
3 | * | |
4 | * Copyright (C) 2013 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_VIEW_HEADERITEM_H | |
22 | #define PULSEVIEW_PV_VIEW_HEADERITEM_H | |
23 | ||
dc747705 JH |
24 | #include <memory> |
25 | ||
7ff0145f JH |
26 | #include <QPropertyAnimation> |
27 | ||
2acdb232 | 28 | #include "selectableitem.hpp" |
23935421 JH |
29 | |
30 | namespace pv { | |
31 | namespace view { | |
32 | ||
eae6e30a | 33 | class RowItemOwner; |
23935421 | 34 | |
dc747705 JH |
35 | class RowItem : public SelectableItem, |
36 | public std::enable_shared_from_this<pv::view::RowItem> | |
23935421 | 37 | { |
6dcdb325 | 38 | Q_OBJECT |
7ff0145f JH |
39 | Q_PROPERTY(int visual_v_offset |
40 | READ visual_v_offset | |
41 | WRITE set_visual_v_offset) | |
6dcdb325 | 42 | |
23935421 JH |
43 | public: |
44 | /** | |
45 | * Constructor. | |
46 | */ | |
47 | RowItem(); | |
48 | ||
49 | /** | |
50 | * Returns true if the item is visible and enabled. | |
51 | */ | |
52 | virtual bool enabled() const = 0; | |
53 | ||
54 | /** | |
55 | * Gets the vertical layout offset of this signal. | |
56 | */ | |
be9e7b4b | 57 | int layout_v_offset() const; |
23935421 JH |
58 | |
59 | /** | |
60 | * Sets the vertical layout offset of this signal. | |
61 | */ | |
be9e7b4b JH |
62 | void set_layout_v_offset(int v_offset); |
63 | ||
64 | /** | |
65 | * Gets the vertical visual offset of this signal. | |
66 | */ | |
67 | int visual_v_offset() const; | |
68 | ||
69 | /** | |
70 | * Sets the vertical visual offset of this signal. | |
71 | */ | |
72 | void set_visual_v_offset(int v_offset); | |
73 | ||
74 | /** | |
75 | * Sets the visual and layout offset of this signal. | |
76 | */ | |
77 | void force_to_v_offset(int v_offset); | |
23935421 | 78 | |
7ff0145f JH |
79 | /** |
80 | * Begins an animation that will animate the visual offset toward | |
81 | * the layout offset. | |
82 | */ | |
83 | void animate_to_layout_v_offset(); | |
84 | ||
bd9a1f17 JH |
85 | /** |
86 | * Gets the owner this trace in the view trace hierachy. | |
87 | */ | |
88 | pv::view::RowItemOwner* owner() const; | |
89 | ||
23935421 | 90 | /** |
eae6e30a | 91 | * Sets the owner this trace in the view trace hierachy. |
23935421 JH |
92 | * @param The new owner of the trace. |
93 | */ | |
eae6e30a | 94 | void set_owner(pv::view::RowItemOwner *owner); |
23935421 JH |
95 | |
96 | /** | |
be9e7b4b | 97 | * Gets the visual y-offset of the axis. |
23935421 | 98 | */ |
be9e7b4b | 99 | int get_visual_y() const; |
23935421 | 100 | |
0dda6fe5 JH |
101 | /** |
102 | * Gets the drag point of the row item. | |
103 | */ | |
104 | QPoint point() const; | |
105 | ||
a5d93c27 JH |
106 | /** |
107 | * Computes the vertical extents of the contents of this row item. | |
108 | * @return A pair containing the minimum and maximum y-values. | |
109 | */ | |
110 | virtual std::pair<int, int> v_extents() const = 0; | |
111 | ||
23935421 JH |
112 | /** |
113 | * Paints the background layer of the trace with a QPainter | |
114 | * @param p the QPainter to paint into. | |
115 | * @param left the x-coordinate of the left edge of the signal | |
116 | * @param right the x-coordinate of the right edge of the signal | |
117 | **/ | |
118 | virtual void paint_back(QPainter &p, int left, int right); | |
119 | ||
120 | /** | |
121 | * Paints the mid-layer of the trace with a QPainter | |
122 | * @param p the QPainter to paint into. | |
123 | * @param left the x-coordinate of the left edge of the signal | |
124 | * @param right the x-coordinate of the right edge of the signal | |
125 | **/ | |
126 | virtual void paint_mid(QPainter &p, int left, int right); | |
127 | ||
128 | /** | |
129 | * Paints the foreground layer of the trace with a QPainter | |
130 | * @param p the QPainter to paint into. | |
131 | * @param left the x-coordinate of the left edge of the signal | |
132 | * @param right the x-coordinate of the right edge of the signal | |
133 | **/ | |
134 | virtual void paint_fore(QPainter &p, int left, int right); | |
135 | ||
136 | /** | |
137 | * Paints the signal label. | |
138 | * @param p the QPainter to paint into. | |
139 | * @param right the x-coordinate of the right edge of the header | |
140 | * area. | |
141 | * @param hover true if the label is being hovered over by the mouse. | |
142 | */ | |
143 | virtual void paint_label(QPainter &p, int right, bool hover) = 0; | |
144 | ||
145 | /** | |
146 | * Computes the outline rectangle of a label. | |
147 | * @param right the x-coordinate of the right edge of the header | |
148 | * area. | |
149 | * @return Returns the rectangle of the signal label. | |
150 | */ | |
0067d804 | 151 | virtual QRectF label_rect(int right) const = 0; |
23935421 JH |
152 | |
153 | public: | |
154 | virtual void hover_point_changed(); | |
155 | ||
156 | protected: | |
8dbbc7f0 | 157 | pv::view::RowItemOwner *owner_; |
23935421 | 158 | |
8dbbc7f0 JH |
159 | int layout_v_offset_; |
160 | int visual_v_offset_; | |
7ff0145f JH |
161 | |
162 | private: | |
8dbbc7f0 | 163 | QPropertyAnimation v_offset_animation_; |
23935421 JH |
164 | }; |
165 | ||
166 | } // namespace view | |
167 | } // namespace pv | |
168 | ||
169 | #endif // PULSEVIEW_PV_VIEW_HEADERITEM_H |