Put playhead on top of everything.
authorDavid Robillard <d@drobilla.net>
Sat, 17 Jan 2015 00:09:47 +0000 (19:09 -0500)
committerDavid Robillard <d@drobilla.net>
Sat, 17 Jan 2015 00:13:56 +0000 (19:13 -0500)
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.

gtk2_ardour/editor.h
gtk2_ardour/editor_canvas.cc
gtk2_ardour/editor_cursors.cc
gtk2_ardour/public_editor.h
libs/canvas/canvas.cc
libs/canvas/canvas/scroll_group.h

index 5eb0df4621c4046b324d9471432ccf0c3d8cb6a8..5cf98fa0d9615e9d2ed9e059504539b1be5f007c 100644 (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;
 
index 5a791ff0608ecec39ce83d7badebf2113f33b030..611d5ac054c6a79ffbf1b5caf6f9dd2e2d780aff 100644 (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 */
index abce8f6252dc7613bea603efb8406998a5a8e77e..ee8253fed8dee27feb9f9d617ea8a22e77e6c8c8 100644 (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");
 
index 33b4782f086262f1a9a8ac447fc8adb12230e606..ff7cae35f2ca8494f40ec592585c292bb738a33d 100644 (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;
 
index 3ac91deda863b3d835a7259f4654421e2bac5c7c..a3d8e6ae6702d416cfe3ae8d4d4469b0305b984a 100644 (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;
index 463abc0bbc805c7588c3309f290869c92bfcee24..fd9b2388d4e2da44135626d3b5c59964d8e32781 100644 (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;