]>
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 | #include <assert.h> | |
22 | ||
2acdb232 | 23 | #include "view.hpp" |
23935421 | 24 | |
2acdb232 | 25 | #include "rowitem.hpp" |
23935421 JH |
26 | |
27 | namespace pv { | |
28 | namespace view { | |
29 | ||
30 | RowItem::RowItem() : | |
8dbbc7f0 JH |
31 | owner_(NULL), |
32 | layout_v_offset_(0), | |
33 | visual_v_offset_(0), | |
34 | v_offset_animation_(this, "visual_v_offset") | |
23935421 JH |
35 | { |
36 | } | |
37 | ||
be9e7b4b | 38 | int RowItem::layout_v_offset() const |
23935421 | 39 | { |
8dbbc7f0 | 40 | return layout_v_offset_; |
23935421 JH |
41 | } |
42 | ||
be9e7b4b | 43 | void RowItem::set_layout_v_offset(int v_offset) |
23935421 | 44 | { |
8dbbc7f0 | 45 | if (layout_v_offset_ == v_offset) |
be9e7b4b JH |
46 | return; |
47 | ||
8dbbc7f0 | 48 | layout_v_offset_ = v_offset; |
32218d3e | 49 | |
8dbbc7f0 JH |
50 | if (owner_) |
51 | owner_->extents_changed(false, true); | |
be9e7b4b JH |
52 | } |
53 | ||
54 | int RowItem::visual_v_offset() const | |
55 | { | |
8dbbc7f0 | 56 | return visual_v_offset_; |
be9e7b4b JH |
57 | } |
58 | ||
59 | void RowItem::set_visual_v_offset(int v_offset) | |
60 | { | |
8dbbc7f0 | 61 | visual_v_offset_ = v_offset; |
32218d3e | 62 | |
8dbbc7f0 JH |
63 | if (owner_) |
64 | owner_->appearance_changed(true, true); | |
be9e7b4b JH |
65 | } |
66 | ||
67 | void RowItem::force_to_v_offset(int v_offset) | |
68 | { | |
8dbbc7f0 JH |
69 | v_offset_animation_.stop(); |
70 | layout_v_offset_ = visual_v_offset_ = v_offset; | |
23935421 JH |
71 | } |
72 | ||
7ff0145f JH |
73 | void RowItem::animate_to_layout_v_offset() |
74 | { | |
8dbbc7f0 JH |
75 | if (visual_v_offset_ == layout_v_offset_ || |
76 | (v_offset_animation_.endValue() == layout_v_offset_ && | |
77 | v_offset_animation_.state() == QAbstractAnimation::Running)) | |
7ff0145f JH |
78 | return; |
79 | ||
8dbbc7f0 JH |
80 | v_offset_animation_.setDuration(100); |
81 | v_offset_animation_.setStartValue(visual_v_offset_); | |
82 | v_offset_animation_.setEndValue(layout_v_offset_); | |
83 | v_offset_animation_.setEasingCurve(QEasingCurve::OutQuad); | |
84 | v_offset_animation_.start(); | |
7ff0145f JH |
85 | } |
86 | ||
bd9a1f17 JH |
87 | RowItemOwner* RowItem::owner() const |
88 | { | |
8dbbc7f0 | 89 | return owner_; |
bd9a1f17 JH |
90 | } |
91 | ||
eae6e30a | 92 | void RowItem::set_owner(RowItemOwner *owner) |
23935421 | 93 | { |
8dbbc7f0 JH |
94 | assert(owner_ || owner); |
95 | v_offset_animation_.stop(); | |
7ff0145f | 96 | |
8dbbc7f0 JH |
97 | if (owner_) { |
98 | const int owner_offset = owner_->owner_visual_v_offset(); | |
99 | layout_v_offset_ += owner_offset; | |
100 | visual_v_offset_ += owner_offset; | |
7ff0145f | 101 | } |
be9e7b4b | 102 | |
8dbbc7f0 | 103 | owner_ = owner; |
7ff0145f | 104 | |
8dbbc7f0 JH |
105 | if (owner_) { |
106 | const int owner_offset = owner_->owner_visual_v_offset(); | |
107 | layout_v_offset_ -= owner_offset; | |
108 | visual_v_offset_ -= owner_offset; | |
7ff0145f | 109 | } |
23935421 JH |
110 | } |
111 | ||
be9e7b4b | 112 | int RowItem::get_visual_y() const |
23935421 | 113 | { |
8dbbc7f0 JH |
114 | assert(owner_); |
115 | return visual_v_offset_ + owner_->owner_visual_v_offset(); | |
23935421 JH |
116 | } |
117 | ||
0dda6fe5 JH |
118 | QPoint RowItem::point() const |
119 | { | |
be9e7b4b | 120 | return QPoint(0, visual_v_offset()); |
0dda6fe5 JH |
121 | } |
122 | ||
23935421 JH |
123 | void RowItem::paint_back(QPainter &p, int left, int right) |
124 | { | |
125 | (void)p; | |
126 | (void)left; | |
127 | (void)right; | |
128 | } | |
129 | ||
130 | void RowItem::paint_mid(QPainter &p, int left, int right) | |
131 | { | |
132 | (void)p; | |
133 | (void)left; | |
134 | (void)right; | |
135 | } | |
136 | ||
137 | void RowItem::paint_fore(QPainter &p, int left, int right) | |
138 | { | |
139 | (void)p; | |
140 | (void)left; | |
141 | (void)right; | |
142 | } | |
143 | ||
144 | void RowItem::hover_point_changed() | |
145 | { | |
146 | } | |
147 | ||
148 | } // namespace view | |
149 | } // namespace pv |