prevent trim cursors appearing, and prevent note trimming, when in a MIDI note that...
[ardour.git] / gtk2_ardour / canvas-note-event.cc
index 0e1afcc01774bcd6379d35e3209419a6b2b6b8fc..e05c6956adffe347cf43dba299825ad902f84d65 100644 (file)
@@ -292,7 +292,14 @@ CanvasNoteEvent::set_mouse_fractions (GdkEvent* ev)
        _mouse_y_fraction = yf;
 
        if (notify) {
-               _region.note_mouse_position (_mouse_x_fraction, _mouse_y_fraction, set_cursor);
+                if (big_enough_to_trim()) {
+                        _region.note_mouse_position (_mouse_x_fraction, _mouse_y_fraction, set_cursor);
+                } else {
+                        /* pretend the mouse is in the middle, because this is not big enough
+                           to trim right now.
+                        */
+                        _region.note_mouse_position (0.5, 0.5, set_cursor);
+                }
        }
 }
 
@@ -347,6 +354,12 @@ CanvasNoteEvent::mouse_near_ends () const
                (_mouse_x_fraction >= 0.75 && _mouse_x_fraction < 1.0);
 }
 
+bool
+CanvasNoteEvent::big_enough_to_trim () const
+{
+        return (x2() - x1()) > 10; /* canvas units, really pixels */
+}
+
 } // namespace Canvas
 } // namespace Gnome