]> sigrok.org Git - pulseview.git/blame - pv/view/rowitem.h
RowItemOwner: Added depth() method
[pulseview.git] / pv / view / rowitem.h
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
23935421
JH
26#include "selectableitem.h"
27
28namespace pv {
29namespace view {
30
eae6e30a 31class RowItemOwner;
23935421 32
dc747705
JH
33class RowItem : public SelectableItem,
34 public std::enable_shared_from_this<pv::view::RowItem>
23935421 35{
6dcdb325
JH
36 Q_OBJECT
37
23935421
JH
38public:
39 /**
40 * Constructor.
41 */
42 RowItem();
43
44 /**
45 * Returns true if the item is visible and enabled.
46 */
47 virtual bool enabled() const = 0;
48
49 /**
50 * Gets the vertical layout offset of this signal.
51 */
be9e7b4b 52 int layout_v_offset() const;
23935421
JH
53
54 /**
55 * Sets the vertical layout offset of this signal.
56 */
be9e7b4b
JH
57 void set_layout_v_offset(int v_offset);
58
59 /**
60 * Gets the vertical visual offset of this signal.
61 */
62 int visual_v_offset() const;
63
64 /**
65 * Sets the vertical visual offset of this signal.
66 */
67 void set_visual_v_offset(int v_offset);
68
69 /**
70 * Sets the visual and layout offset of this signal.
71 */
72 void force_to_v_offset(int v_offset);
23935421 73
bd9a1f17
JH
74 /**
75 * Gets the owner this trace in the view trace hierachy.
76 */
77 pv::view::RowItemOwner* owner() const;
78
23935421 79 /**
eae6e30a 80 * Sets the owner this trace in the view trace hierachy.
23935421
JH
81 * @param The new owner of the trace.
82 */
eae6e30a 83 void set_owner(pv::view::RowItemOwner *owner);
23935421
JH
84
85 /**
be9e7b4b 86 * Gets the visual y-offset of the axis.
23935421 87 */
be9e7b4b 88 int get_visual_y() const;
23935421 89
0dda6fe5
JH
90 /**
91 * Gets the drag point of the row item.
92 */
93 QPoint point() const;
94
a5d93c27
JH
95 /**
96 * Computes the vertical extents of the contents of this row item.
97 * @return A pair containing the minimum and maximum y-values.
98 */
99 virtual std::pair<int, int> v_extents() const = 0;
100
23935421
JH
101 /**
102 * Paints the background layer of the trace with a QPainter
103 * @param p the QPainter to paint into.
104 * @param left the x-coordinate of the left edge of the signal
105 * @param right the x-coordinate of the right edge of the signal
106 **/
107 virtual void paint_back(QPainter &p, int left, int right);
108
109 /**
110 * Paints the mid-layer of the trace with a QPainter
111 * @param p the QPainter to paint into.
112 * @param left the x-coordinate of the left edge of the signal
113 * @param right the x-coordinate of the right edge of the signal
114 **/
115 virtual void paint_mid(QPainter &p, int left, int right);
116
117 /**
118 * Paints the foreground layer of the trace with a QPainter
119 * @param p the QPainter to paint into.
120 * @param left the x-coordinate of the left edge of the signal
121 * @param right the x-coordinate of the right edge of the signal
122 **/
123 virtual void paint_fore(QPainter &p, int left, int right);
124
125 /**
126 * Paints the signal label.
127 * @param p the QPainter to paint into.
128 * @param right the x-coordinate of the right edge of the header
129 * area.
130 * @param hover true if the label is being hovered over by the mouse.
131 */
132 virtual void paint_label(QPainter &p, int right, bool hover) = 0;
133
134 /**
135 * Computes the outline rectangle of a label.
136 * @param right the x-coordinate of the right edge of the header
137 * area.
138 * @return Returns the rectangle of the signal label.
139 */
0067d804 140 virtual QRectF label_rect(int right) const = 0;
23935421
JH
141
142public:
143 virtual void hover_point_changed();
144
145protected:
eae6e30a 146 pv::view::RowItemOwner *_owner;
23935421 147
be9e7b4b
JH
148 int _layout_v_offset;
149 int _visual_v_offset;
23935421
JH
150};
151
152} // namespace view
153} // namespace pv
154
155#endif // PULSEVIEW_PV_VIEW_HEADERITEM_H