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.
This commit is contained in:
Paul Davis 2014-05-20 23:08:15 -04:00
parent 6e91e9fd5f
commit cb9453b475
14 changed files with 200 additions and 122 deletions

View file

@ -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