Make y position of MIDI note drags slightly better.
authorCarl Hetherington <carl@carlh.net>
Wed, 13 Jun 2012 18:01:29 +0000 (18:01 +0000)
committerCarl Hetherington <carl@carlh.net>
Wed, 13 Jun 2012 18:01:29 +0000 (18:01 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@12707 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor_drag.cc

index ce785af18876168fa594e8404fb2d43236ae4e36..e5eb7630c0f5bff75484391fd8a91a6a5f7e7a81 100644 (file)
@@ -3999,7 +3999,15 @@ NoteDrag::total_dx () const
 int8_t
 NoteDrag::total_dy () const
 {
-       return ((int8_t) (grab_y() / _note_height)) - ((int8_t) (_drags->current_pointer_y() / _note_height));
+       MidiStreamView* msv = _region->midi_stream_view ();
+       double const y = _region->midi_view()->y_position ();
+       /* new current note */
+       uint8_t n = msv->y_to_note (_drags->current_pointer_y () - y);
+       /* clamp */
+       n = max (msv->lowest_note(), n);
+       n = min (msv->highest_note(), n);
+       /* and work out delta */
+       return n - msv->y_to_note (grab_y() - y);
 }
 
 void