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