2 * This file is part of the PulseView project.
4 * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
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.
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.
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
25 #include "tracetreeitem.hpp"
31 TraceTreeItem::TraceTreeItem() :
35 v_offset_animation_(this, "visual_v_offset")
39 void TraceTreeItem::select(bool select)
41 ViewItem::select(select);
42 owner_->row_item_appearance_changed(true, true);
45 int TraceTreeItem::layout_v_offset() const
47 return layout_v_offset_;
50 void TraceTreeItem::set_layout_v_offset(int v_offset)
52 if (layout_v_offset_ == v_offset)
55 layout_v_offset_ = v_offset;
58 owner_->extents_changed(false, true);
61 int TraceTreeItem::visual_v_offset() const
63 return visual_v_offset_;
66 void TraceTreeItem::set_visual_v_offset(int v_offset)
68 visual_v_offset_ = v_offset;
71 owner_->row_item_appearance_changed(true, true);
74 void TraceTreeItem::force_to_v_offset(int v_offset)
76 v_offset_animation_.stop();
77 layout_v_offset_ = visual_v_offset_ = v_offset;
80 owner_->row_item_appearance_changed(true, true);
81 owner_->extents_changed(false, true);
85 void TraceTreeItem::animate_to_layout_v_offset()
87 if (visual_v_offset_ == layout_v_offset_ ||
88 (v_offset_animation_.endValue() == layout_v_offset_ &&
89 v_offset_animation_.state() == QAbstractAnimation::Running))
92 v_offset_animation_.setDuration(100);
93 v_offset_animation_.setStartValue(visual_v_offset_);
94 v_offset_animation_.setEndValue(layout_v_offset_);
95 v_offset_animation_.setEasingCurve(QEasingCurve::OutQuad);
96 v_offset_animation_.start();
99 TraceTreeItemOwner* TraceTreeItem::owner() const
104 void TraceTreeItem::set_owner(TraceTreeItemOwner *owner)
106 assert(owner_ || owner);
107 v_offset_animation_.stop();
110 const int owner_offset = owner_->owner_visual_v_offset();
111 layout_v_offset_ += owner_offset;
112 visual_v_offset_ += owner_offset;
118 const int owner_offset = owner_->owner_visual_v_offset();
119 layout_v_offset_ -= owner_offset;
120 visual_v_offset_ -= owner_offset;
124 int TraceTreeItem::get_visual_y() const
127 return visual_v_offset_ + owner_->owner_visual_v_offset();
130 void TraceTreeItem::drag_by(const QPoint &delta)
133 force_to_v_offset(drag_point_.y() + delta.y() -
134 owner_->owner_visual_v_offset());
137 QPoint TraceTreeItem::point(const QRect &rect) const
139 return QPoint(rect.right(), get_visual_y());
142 void TraceTreeItem::set_bgcolour_state(bool state)
144 bgcolour_state_ = state;
147 } // namespace TraceView