Put playhead on top of everything.

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.
This commit is contained in:
David Robillard 2015-01-16 19:09:47 -05:00
parent d194ec9135
commit b759fd5879
6 changed files with 26 additions and 6 deletions

View File

@ -504,6 +504,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
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;
@ -820,6 +821,10 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
*/
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;

View File

@ -80,6 +80,7 @@ Editor::initialize_canvas ()
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");
@ -91,6 +92,10 @@ Editor::initialize_canvas ()
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 */

View File

@ -33,7 +33,7 @@ using namespace Gtk;
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");

View File

@ -370,6 +370,7 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi
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;

View File

@ -236,7 +236,7 @@ Canvas::window_to_canvas (Duple const & d) const
*/
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.
@ -252,13 +252,20 @@ Canvas::window_to_canvas (Duple const & d) const
}
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;

View File

@ -46,6 +46,8 @@ class LIBCANVAS_API ScrollGroup : public Container
void render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const;
ScrollSensitivity sensitivity() const { return _scroll_sensitivity; }
private:
ScrollSensitivity _scroll_sensitivity;
Duple _scroll_offset;