remove global canvas scroll offset, to provide no-scroll-parent == no-scroll behaviour

This commit is contained in:
Paul Davis 2014-06-09 08:39:38 -04:00
parent 8fe593fcca
commit f0c18abf55
3 changed files with 4 additions and 11 deletions

View file

@ -48,8 +48,6 @@ Canvas::Canvas ()
void void
Canvas::scroll_to (Coord x, Coord y) Canvas::scroll_to (Coord x, Coord y)
{ {
_scroll_offset = Duple (x, y);
/* We do things this way because we do not want to recurse through /* We do things this way because we do not want to recurse through
the canvas for every scroll. In the presence of large MIDI the canvas for every scroll. In the presence of large MIDI
tracks this means traversing item lists that include tracks this means traversing item lists that include
@ -61,7 +59,7 @@ Canvas::scroll_to (Coord x, Coord y)
*/ */
for (list<ScrollGroup*>::iterator i = scrollers.begin(); i != scrollers.end(); ++i) { for (list<ScrollGroup*>::iterator i = scrollers.begin(); i != scrollers.end(); ++i) {
(*i)->scroll_to (_scroll_offset); (*i)->scroll_to (Duple (x, y));
} }
pick_current_item (0); // no current mouse position pick_current_item (0); // no current mouse position
@ -225,9 +223,7 @@ Canvas::window_to_canvas (Duple const & d) const
return d.translate (sg->scroll_offset()); return d.translate (sg->scroll_offset());
} }
/* fallback to global canvas offset ... it would be nice to remove this */ return d;
return d.translate (_scroll_offset);
} }
Duple Duple
@ -252,7 +248,7 @@ Canvas::canvas_to_window (Duple const & d, bool rounded) const
if (sg) { if (sg) {
wd = d.translate (-sg->scroll_offset()); wd = d.translate (-sg->scroll_offset());
} else { } else {
wd = d.translate (-_scroll_offset); wd = d;
} }
/* Note that this intentionally almost always returns integer coordinates */ /* Note that this intentionally almost always returns integer coordinates */

View file

@ -107,7 +107,6 @@ public:
} }
void scroll_to (Coord x, Coord y); void scroll_to (Coord x, Coord y);
Duple scroll_offset() const { return _scroll_offset; }
void add_scroller (ScrollGroup& i); void add_scroller (ScrollGroup& i);
virtual Rect visible_area () const = 0; virtual Rect visible_area () const = 0;
@ -126,8 +125,6 @@ protected:
/** our root group */ /** our root group */
RootGroup _root; RootGroup _root;
Duple _scroll_offset;
virtual void pick_current_item (int state) = 0; virtual void pick_current_item (int state) = 0;
virtual void pick_current_item (Duple const &, int state) = 0; virtual void pick_current_item (Duple const &, int state) = 0;

View file

@ -114,7 +114,7 @@ Item::scroll_offset () const
if (_scroll_parent) { if (_scroll_parent) {
return _scroll_parent->scroll_offset(); return _scroll_parent->scroll_offset();
} }
return _canvas->scroll_offset(); return Duple (0,0);
} }
Duple Duple