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 "rowitem.hpp"
34 v_offset_animation_(this, "visual_v_offset")
38 int RowItem::layout_v_offset() const
40 return layout_v_offset_;
43 void RowItem::set_layout_v_offset(int v_offset)
45 if (layout_v_offset_ == v_offset)
48 layout_v_offset_ = v_offset;
51 owner_->extents_changed(false, true);
54 int RowItem::visual_v_offset() const
56 return visual_v_offset_;
59 void RowItem::set_visual_v_offset(int v_offset)
61 visual_v_offset_ = v_offset;
64 owner_->row_item_appearance_changed(true, true);
67 void RowItem::force_to_v_offset(int v_offset)
69 v_offset_animation_.stop();
70 layout_v_offset_ = visual_v_offset_ = v_offset;
73 void RowItem::animate_to_layout_v_offset()
75 if (visual_v_offset_ == layout_v_offset_ ||
76 (v_offset_animation_.endValue() == layout_v_offset_ &&
77 v_offset_animation_.state() == QAbstractAnimation::Running))
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();
87 RowItemOwner* RowItem::owner() const
92 void RowItem::set_owner(RowItemOwner *owner)
94 assert(owner_ || owner);
95 v_offset_animation_.stop();
98 const int owner_offset = owner_->owner_visual_v_offset();
99 layout_v_offset_ += owner_offset;
100 visual_v_offset_ += owner_offset;
106 const int owner_offset = owner_->owner_visual_v_offset();
107 layout_v_offset_ -= owner_offset;
108 visual_v_offset_ -= owner_offset;
112 int RowItem::get_visual_y() const
115 return visual_v_offset_ + owner_->owner_visual_v_offset();
118 QPoint RowItem::point() const
120 return QPoint(0, visual_v_offset());
123 void RowItem::hover_point_changed()