From 22e72527294a0de6b93c7a4028f485d9b59552f6 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 21 May 2014 19:13:26 -0400 Subject: [PATCH] inline ScrollGroup::canvas_position() for no particular reason --- libs/canvas/canvas/scroll_group.h | 10 +++++++++- libs/canvas/scroll_group.cc | 21 ++++++++++----------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/libs/canvas/canvas/scroll_group.h b/libs/canvas/canvas/scroll_group.h index c2b26bf9d9..36d98538a1 100644 --- a/libs/canvas/canvas/scroll_group.h +++ b/libs/canvas/canvas/scroll_group.h @@ -35,8 +35,16 @@ class LIBCANVAS_API ScrollGroup : public Group explicit ScrollGroup (Group *, Duple, ScrollSensitivity); void scroll_to (Duple const& d); - Duple canvas_position() const; + /** return the normal "base" position of this item + rather its position as affected by any scroll + offset. + */ + Duple canvas_position() const { + return _position.translate (_scroll_offset); + } + + Duple scroll_offset() const { return _scroll_offset; } private: ScrollSensitivity _scroll_sensitivity; Duple _scroll_offset; diff --git a/libs/canvas/scroll_group.cc b/libs/canvas/scroll_group.cc index bda6911ca7..94ea869971 100644 --- a/libs/canvas/scroll_group.cc +++ b/libs/canvas/scroll_group.cc @@ -37,27 +37,26 @@ ScrollGroup::ScrollGroup (Group* parent, Duple position, ScrollSensitivity s) void ScrollGroup::scroll_to (Duple const& d) { - Duple base_pos (position().translate (_scroll_offset)); + /* get the nominal position of the group without scroll being in effect + */ + + Duple base_pos (_position.translate (_scroll_offset)); + + /* compute a new position given our sensitivity to h- and v-scrolling + */ if (_scroll_sensitivity & ScrollsHorizontally) { base_pos.x -= d.x; _scroll_offset.x = d.x; - } + } if (_scroll_sensitivity & ScrollsVertically) { base_pos.y -= d.y; _scroll_offset.y = d.y; } + /* move there */ + set_position (base_pos); } -Duple -ScrollGroup::canvas_position() const -{ - /* return the normal "base" position of this item - rather its position as affected by any scroll - offset. - */ - return _position.translate (_scroll_offset); -}