diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2015-01-24 14:07:36 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2015-01-24 18:48:15 -0500 |
commit | e84e1f74030ad123cd1ba08331b5ef5df1835129 (patch) | |
tree | 02d0ad44697302ba7e625a1bf8450242cb9d02e9 /libs/canvas/canvas.cc | |
parent | db28eefc49baeb124275ad53b067c5caa953d363 (diff) |
ScrollGroups are kept in their own list, so ::window_to_canvas() does not need to inspect root group children to find them
Conflicts:
libs/canvas/canvas.cc
Diffstat (limited to 'libs/canvas/canvas.cc')
-rw-r--r-- | libs/canvas/canvas.cc | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/libs/canvas/canvas.cc b/libs/canvas/canvas.cc index a3d8e6ae67..1a14f8bde3 100644 --- a/libs/canvas/canvas.cc +++ b/libs/canvas/canvas.cc @@ -230,13 +230,8 @@ Canvas::item_changed (Item* item, boost::optional<Rect> pre_change_bounding_box) Duple Canvas::window_to_canvas (Duple const & d) const { - /* Find the scroll group that covers d (a window coordinate). Scroll groups are only allowed - * as children of the root group, so we just scan its first level - * children and see what we can find. - */ - - std::list<Item*> const& root_children (_root.items()); ScrollGroup* best_group = 0; + ScrollGroup* sg = 0; /* if the coordinates are negative, clamp to zero and find the item * that covers that "edge" position. @@ -251,15 +246,27 @@ Canvas::window_to_canvas (Duple const & d) const in_window.y = 0; } - for (std::list<Item*>::const_reverse_iterator i = root_children.rbegin(); i != root_children.rend(); ++i) { - ScrollGroup* sg = dynamic_cast<ScrollGroup*>(*i); - /* If scroll groups overlap, choose the one with the highest sensitivity, - that is, choose an HV scroll group over an H or V only group. */ - if (sg && (!best_group || sg->sensitivity() > best_group->sensitivity())) { - best_group = sg; - if (sg->sensitivity() == (ScrollGroup::ScrollsVertically | ScrollGroup::ScrollsHorizontally)) { - /* Can't do any better than this. */ - break; + for (list<ScrollGroup*>::const_iterator s = scrollers.begin(); s != scrollers.end(); ++s) { + + if ((*s)->covers_window (in_window)) { + sg = *s; + + /* XXX January 22nd 2015: leaving this in place for now + * but I think it fixes a bug that really should be + * fixed in a different way (and will be) by my next + * commit. But it may still be relevant. + */ + + /* If scroll groups overlap, choose the one with the highest sensitivity, + that is, choose an HV scroll group over an H or V + only group. + */ + if (!best_group || sg->sensitivity() > best_group->sensitivity()) { + best_group = sg; + if (sg->sensitivity() == (ScrollGroup::ScrollsVertically | ScrollGroup::ScrollsHorizontally)) { + /* Can't do any better than this. */ + break; + } } } } @@ -288,7 +295,6 @@ Canvas::canvas_to_window (Duple const & d, bool rounded) const break; } } - if (sg) { wd = d.translate (-sg->scroll_offset()); |