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