Achieve this by adding a new hscroll group just for cursors.
That requires a slightly smarter window_to_canvas() to deal with overlapping
sensitive scroll groups. New rule is that scroll groups can overlap, but the
most sensitive one found from the top down will be chosen to translate
coordinates. This basically means don't overlap scroll groups with different
sensitivities.
In the presence of scroll groups, having a canvas-wide window_to_canvas()
and/or canvas_to_window() fundamentally makes no sense. At some point in the
glorious future we should kill those and use only item-relative coordinate
translation.
ArdourCanvas::Container* get_noscroll_group () const { return no_scroll_group; }
ArdourCanvas::ScrollGroup* get_hscroll_group () const { return h_scroll_group; }
ArdourCanvas::ScrollGroup* get_hvscroll_group () const { return hv_scroll_group; }
+ ArdourCanvas::ScrollGroup* get_cursor_scroll_group () const { return cursor_scroll_group; }
ArdourCanvas::GtkCanvasViewport* get_track_canvas () const;
*/
ArdourCanvas::ScrollGroup* h_scroll_group;
+ /* Scroll group for cursors, scrolled horizontally, above everything else
+ */
+ ArdourCanvas::ScrollGroup* cursor_scroll_group;
+
/* The group containing all trackviews. */
ArdourCanvas::Container* no_scroll_group;
ArdourCanvas::ScrollGroup* hsg;
ArdourCanvas::ScrollGroup* hg;
+ ArdourCanvas::ScrollGroup* cg;
h_scroll_group = hg = new ArdourCanvas::ScrollGroup (_track_canvas->root(), ArdourCanvas::ScrollGroup::ScrollsHorizontally);
CANVAS_DEBUG_NAME (h_scroll_group, "canvas h scroll");
CANVAS_DEBUG_NAME (hv_scroll_group, "canvas hv scroll");
_track_canvas->add_scroller (*hsg);
+ cursor_scroll_group = cg = new ArdourCanvas::ScrollGroup (_track_canvas->root(), ArdourCanvas::ScrollGroup::ScrollsHorizontally);
+ CANVAS_DEBUG_NAME (cursor_scroll_group, "canvas cursor scroll");
+ _track_canvas->add_scroller (*cg);
+
_verbose_cursor = new VerboseCursor (this);
/* on the bottom, an image */
EditorCursor::EditorCursor (Editor& ed, bool (Editor::*callbck)(GdkEvent*,ArdourCanvas::Item*))
: _editor (ed)
- , _track_canvas_item (new ArdourCanvas::Arrow (_editor.get_hscroll_group()))
+ , _track_canvas_item (new ArdourCanvas::Arrow (_editor.get_cursor_scroll_group()))
{
CANVAS_DEBUG_NAME (_track_canvas_item, "track canvas editor cursor");
virtual ArdourCanvas::Container* get_trackview_group () const = 0;
virtual ArdourCanvas::ScrollGroup* get_hscroll_group () const = 0;
virtual ArdourCanvas::ScrollGroup* get_hvscroll_group () const = 0;
+ virtual ArdourCanvas::ScrollGroup* get_cursor_scroll_group () const = 0;
virtual ArdourCanvas::GtkCanvasViewport* get_track_canvas() const = 0;
*/
std::list<Item*> const& root_children (_root.items());
- ScrollGroup* sg = 0;
+ ScrollGroup* best_group = 0;
/* if the coordinates are negative, clamp to zero and find the item
* that covers that "edge" position.
}
for (std::list<Item*>::const_reverse_iterator i = root_children.rbegin(); i != root_children.rend(); ++i) {
- if (((sg = dynamic_cast<ScrollGroup*>(*i)) != 0) && sg->covers_window (in_window)) {
- break;
+ 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;
+ }
}
}
- if (sg) {
- return d.translate (sg->scroll_offset());
+ if (best_group) {
+ return d.translate (best_group->scroll_offset());
}
return d;
void render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const;
+ ScrollSensitivity sensitivity() const { return _scroll_sensitivity; }
+
private:
ScrollSensitivity _scroll_sensitivity;
Duple _scroll_offset;