diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-05-20 23:08:15 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-06-03 16:10:27 -0400 |
commit | 6019f06bdf919e1d95dd0912116cdec0834af8db (patch) | |
tree | be8d2e41e692c2e8a572f531b546efde67b1503f /libs/canvas/item.cc | |
parent | fc9e6651dd804672822e06cbd4092c043dc8406d (diff) |
different approach to independent scrolling, involving ArdourCanvas::ScrollGroup
The idea now is that a scroll group item can be added to the canvas which will causes its children to scroll in either or both
directions (horizontal or vertical). There are few complications: the position() of the ScrollGroup is ambiguous depending
on whether you want it with scroll taken into account or not, so Item::canvas_position() was added, which defaults to
the same value as Item::position() but is overridden by ScrollGroup to return the position independent of scrolling. This
method is used when translating between item/canvas/window coordinate systems.
Note that the basic idea is that we MOVE the scroll group when a scroll happens. This mirrors what happens in the GnomeCanvas,
where Nick Mainsbridge came up with a great idea that allowed unification of the time bar and track canvases.
Diffstat (limited to 'libs/canvas/item.cc')
-rw-r--r-- | libs/canvas/item.cc | 61 |
1 files changed, 8 insertions, 53 deletions
diff --git a/libs/canvas/item.cc b/libs/canvas/item.cc index 7a55e9604f..c6652f9d3a 100644 --- a/libs/canvas/item.cc +++ b/libs/canvas/item.cc @@ -35,7 +35,6 @@ using namespace ArdourCanvas; Item::Item (Canvas* canvas) : _canvas (canvas) , _parent (0) - , _scroll_sensitivity (ScrollSensitivity (0)) { init (); } @@ -43,7 +42,6 @@ Item::Item (Canvas* canvas) Item::Item (Group* parent) : _canvas (parent->canvas ()) , _parent (parent) - , _scroll_sensitivity (ScrollSensitivity (0)) { init (); } @@ -52,7 +50,6 @@ Item::Item (Group* parent, Duple position) : _canvas (parent->canvas()) , _parent (parent) , _position (position) - , _scroll_sensitivity (ScrollSensitivity (0)) { init (); } @@ -82,24 +79,6 @@ Item::~Item () } } -void -Item::scroll_to (Duple const& d) -{ - if (_scroll_sensitivity & ScrollsVertically) { - _scroll_offset.y = d.y; - } - - if (_scroll_sensitivity & ScrollsHorizontally) { - _scroll_offset.x = d.x; - } -} - -void -Item::set_scroll_sensitivity (ScrollSensitivity s) -{ - _scroll_sensitivity = s; -} - ArdourCanvas::Rect Item::item_to_parent (ArdourCanvas::Rect const & r) const { @@ -113,7 +92,7 @@ Item::item_to_canvas (ArdourCanvas::Rect const & r) const Duple offset; while (i) { - offset = offset.translate (i->position()); + offset = offset.translate (i->canvas_position()); i = i->parent(); } @@ -127,7 +106,7 @@ Item::item_to_canvas (ArdourCanvas::Duple const & d) const Duple offset; while (i) { - offset = offset.translate (i->position()); + offset = offset.translate (i->canvas_position()); i = i->parent(); } @@ -141,7 +120,7 @@ Item::canvas_to_item (ArdourCanvas::Duple const & d) const Duple offset; while (i) { - offset = offset.translate (-(i->position())); + offset = offset.translate (-(i->canvas_position())); i = i->parent(); } @@ -155,7 +134,7 @@ Item::canvas_to_item (ArdourCanvas::Rect const & d) const Duple offset; while (i) { - offset = offset.translate (-(i->position())); + offset = offset.translate (-(i->canvas_position())); i = i->parent(); } @@ -197,43 +176,19 @@ Item::item_to_window (ArdourCanvas::Duple const & d, bool rounded) const Duple Item::window_to_item (ArdourCanvas::Duple const & d) const { - Item const * i = this; - Duple offset; - - while (i) { - offset = offset.translate (-i->scroll_offset()); - i = i->parent(); - } - - return _canvas->window_to_canvas (d.translate (offset)); + return canvas_to_item (_canvas->window_to_canvas (d)); } ArdourCanvas::Rect Item::item_to_window (ArdourCanvas::Rect const & r) const { - Item const * i = this; - Duple offset; - - while (i) { - offset = offset.translate (i->scroll_offset()); - i = i->parent(); - } - - return _canvas->canvas_to_window (item_to_canvas (r.translate (offset))); + return _canvas->canvas_to_window (item_to_canvas (r)); } ArdourCanvas::Rect Item::window_to_item (ArdourCanvas::Rect const & r) const { - Item const * i = this; - Duple offset; - - while (i) { - offset = offset.translate (-i->scroll_offset()); - i = i->parent(); - } - - return canvas_to_item (_canvas->window_to_canvas (r).translate (offset)); + return canvas_to_item (_canvas->window_to_canvas (r)); } /** Set the position of this item in the parent's coordinates */ @@ -576,7 +531,7 @@ Item::dump (ostream& o) const boost::optional<ArdourCanvas::Rect> bb = bounding_box(); o << _canvas->indent() << whatami() << ' ' << this << " Visible ? " << _visible; - o << " @ " << position() << " scrolled-to " << _scroll_offset; + o << " @ " << position(); #ifdef CANVAS_DEBUG if (!name.empty()) { |