]> sigrok.org Git - pulseview.git/blame - pv/view/tracetreeitem.hpp
MainWindow: Use regular pointer for QDockWidgets
[pulseview.git] / pv / view / tracetreeitem.hpp
CommitLineData
af503b10
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
f4e57597
SA
21#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACETREEITEM_HPP
22#define PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACETREEITEM_HPP
af503b10
JH
23
24#include <memory>
25
26#include <QPropertyAnimation>
27
28#include "rowitem.hpp"
29
30namespace pv {
f4e57597
SA
31namespace views {
32namespace TraceView {
af503b10
JH
33
34class TraceTreeItemOwner;
35
36class TraceTreeItem : public RowItem,
f4e57597 37 public std::enable_shared_from_this<TraceTreeItem>
af503b10
JH
38{
39 Q_OBJECT
40 Q_PROPERTY(int visual_v_offset
41 READ visual_v_offset
42 WRITE set_visual_v_offset)
43
44public:
45 /**
46 * Constructor.
47 */
48 TraceTreeItem();
49
c373f828 50 /**
4ca23e7d 51 * Gets the owner of this item in the view item hierachy.
c373f828
JH
52 */
53 TraceTreeItemOwner* owner() const;
54
75663e3a
JH
55 /**
56 * Selects or deselects the signal.
57 */
58 void select(bool select = true);
59
af503b10
JH
60 /**
61 * Gets the vertical layout offset of this signal.
62 */
63 int layout_v_offset() const;
64
65 /**
66 * Sets the vertical layout offset of this signal.
67 */
68 void set_layout_v_offset(int v_offset);
69
70 /**
71 * Gets the vertical visual offset of this signal.
72 */
73 int visual_v_offset() const;
74
75 /**
76 * Sets the vertical visual offset of this signal.
77 */
78 void set_visual_v_offset(int v_offset);
79
80 /**
81 * Sets the visual and layout offset of this signal.
82 */
83 void force_to_v_offset(int v_offset);
84
85 /**
86 * Begins an animation that will animate the visual offset toward
87 * the layout offset.
88 */
89 void animate_to_layout_v_offset();
90
af503b10
JH
91 /**
92 * Sets the owner this trace in the view trace hierachy.
93 * @param The new owner of the trace.
94 */
f4e57597 95 void set_owner(TraceTreeItemOwner *owner);
af503b10
JH
96
97 /**
98 * Gets the visual y-offset of the axis.
99 */
100 int get_visual_y() const;
101
102 /**
103 * Drags the item to a delta relative to the drag point.
104 * @param delta the offset from the drag point.
105 */
106 void drag_by(const QPoint &delta);
107
108 /**
109 * Gets the arrow-tip point of the row item marker.
110 * @param rect the rectangle of the header area.
111 */
112 QPoint point(const QRect &rect) const;
113
ac0708fb 114 /**
5d738861 115 * Sets the new background colour state: false = dark, true = bright.
ac0708fb
SA
116 * This is to allow for alternating backgrounds but has no effect
117 * when coloured background colours are used.
118 * @param state New bg color state to use.
119 */
120 void set_bgcolour_state(bool state);
121
af503b10
JH
122 /**
123 * Computes the vertical extents of the contents of this row item.
124 * @return A pair containing the minimum and maximum y-values.
125 */
126 virtual std::pair<int, int> v_extents() const = 0;
127
af503b10 128protected:
c373f828 129 TraceTreeItemOwner *owner_;
af503b10
JH
130
131 int layout_v_offset_;
132 int visual_v_offset_;
133
ac0708fb
SA
134 bool bgcolour_state_;
135
af503b10
JH
136private:
137 QPropertyAnimation v_offset_animation_;
138};
139
f4e57597
SA
140} // namespace TraceView
141} // namespace views
af503b10
JH
142} // namespace pv
143
f4e57597 144#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACETREEITEM_HPP