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/canvas.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/canvas.cc')
-rw-r--r-- | libs/canvas/canvas.cc | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/libs/canvas/canvas.cc b/libs/canvas/canvas.cc index 8d4c1b8858..aad614d906 100644 --- a/libs/canvas/canvas.cc +++ b/libs/canvas/canvas.cc @@ -50,11 +50,9 @@ Canvas::scroll_to (Coord x, Coord y) { Duple d (x, y); - if (_global_scroll) { - _scroll_offset = d; - } - - //_root.scroll_to (d); + _scroll_offset = d; + + _root.scroll_to (d); pick_current_item (0); // no current mouse position } @@ -81,9 +79,9 @@ Canvas::render (Rect const & area, Cairo::RefPtr<Cairo::Context> const & context #ifdef CANVAS_DEBUG if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { cerr << this << " RENDER: " << area << endl; - cerr << "CANVAS @ " << this << endl; - dump (cerr); - cerr << "-------------------------\n"; + //cerr << "CANVAS @ " << this << endl; + //dump (cerr); + //cerr << "-------------------------\n"; } #endif @@ -208,13 +206,14 @@ Canvas::canvas_to_window (Duple const & d, bool rounded) const Duple wd = d.translate (Duple (-_scroll_offset.x, -_scroll_offset.y)); /* Note that this intentionally almost always returns integer coordinates */ + if (rounded) { wd.x = round (wd.x); wd.y = round (wd.y); } return wd; -} +} Rect Canvas::window_to_canvas (Rect const & r) const |