merge fix
[ardour.git] / gtk2_ardour / editor_canvas.cc
index 5a791ff0608ecec39ce83d7badebf2113f33b030..6413b6d6910de00031a27aecd6851676a0711b76 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 */
@@ -1007,15 +1012,22 @@ Editor::set_canvas_cursor (Gdk::Cursor* cursor)
 {
        Glib::RefPtr<Gdk::Window> win = _track_canvas->get_window();
 
-       if (win && cursor) {
-               win->set_cursor (*cursor);
+       if (win && !_cursors->is_invalid (cursor)) {
+               /* glibmm 2.4 doesn't allow null cursor pointer because it uses
+                  a Gdk::Cursor& as the argument to Gdk::Window::set_cursor().
+                  But a null pointer just means "use parent window cursor",
+                  and so should be allowed. Gtkmm 3.x has fixed this API.
+
+                  For now, drop down and use C API
+               */
+               gdk_window_set_cursor (win->gobj(), cursor ? cursor->gobj() : 0);
        }
 }
 
 size_t
 Editor::push_canvas_cursor (Gdk::Cursor* cursor)
 {
-       if (cursor) {
+       if (!_cursors->is_invalid (cursor)) {
                _cursor_stack.push_back (cursor);
                set_canvas_cursor (cursor);
        }
@@ -1090,7 +1102,7 @@ Editor::which_trim_cursor (bool left) const
 Gdk::Cursor*
 Editor::which_mode_cursor () const
 {
-       Gdk::Cursor* mode_cursor = 0;
+       Gdk::Cursor* mode_cursor = MouseCursors::invalid_cursor ();
 
        switch (mouse_mode) {
        case MouseRange:
@@ -1156,7 +1168,7 @@ Editor::which_mode_cursor () const
 Gdk::Cursor*
 Editor::which_track_cursor () const
 {
-       Gdk::Cursor* cursor = 0;
+       Gdk::Cursor* cursor = MouseCursors::invalid_cursor();
 
        switch (_join_object_range_state) {
        case JOIN_OBJECT_RANGE_NONE:
@@ -1176,6 +1188,19 @@ Editor::which_canvas_cursor(ItemType type) const
 {
        Gdk::Cursor* cursor = which_mode_cursor ();
 
+       if (mouse_mode == MouseRange) {
+               switch (type) {
+               case StartSelectionTrimItem:
+                       cursor = _cursors->left_side_trim;
+                       break;
+               case EndSelectionTrimItem:
+                       cursor = _cursors->right_side_trim;
+                       break;
+               default:
+                       break;
+               }
+       }
+       
        if ((mouse_mode == MouseObject || get_smart_mode ()) ||
            mouse_mode == MouseContent) {
 
@@ -1211,7 +1236,7 @@ Editor::which_canvas_cursor(ItemType type) const
                        cursor = _cursors->fader;
                        break;
                case GainLineItem:
-                       cursor = which_track_cursor ();
+                       cursor = _cursors->cross_hair;
                        break;
                case AutomationLineItem:
                        cursor = _cursors->cross_hair;
@@ -1244,12 +1269,16 @@ Editor::which_canvas_cursor(ItemType type) const
                        cursor = _cursors->cross_hair;
                        break;
                case LeftFrameHandle:
-                       if ( effective_mouse_mode() == MouseObject )  // (smart mode): if the user is in the top half, override the trim cursor, since they are in the range zone
-                               cursor = which_trim_cursor (true);  //alternatively, one could argue that we _should_ allow trims here, and disallow range selection
+                       if ( effective_mouse_mode() == MouseObject )  // (smart mode): if the user is in the btm half, show the trim cursor
+                               cursor = which_trim_cursor (true);
+                       else
+                               cursor = _cursors->selector;  // (smart mode): in the top half, just show the selection (range) cursor
                        break;
                case RightFrameHandle:
                        if ( effective_mouse_mode() == MouseObject )  //see above
                                cursor = which_trim_cursor (false);
+                       else
+                               cursor = _cursors->selector;
                        break;
                case StartCrossFadeItem:
                        cursor = _cursors->fade_in;
@@ -1327,7 +1356,7 @@ Editor::choose_canvas_cursor_on_entry (ItemType type)
 
        Gdk::Cursor* cursor = which_canvas_cursor(type);
 
-       if (cursor) {
+       if (!_cursors->is_invalid (cursor)) {
                // Push a new enter context
                const EnterContext ctx = { type, CursorContext::create(*this, cursor) };
                _enter_stack.push_back(ctx);