diff options
author | Carl Hetherington <carl@carlh.net> | 2011-07-17 16:02:26 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2011-07-17 16:02:26 +0000 |
commit | 7e8e8b4e7289d6b4f677c5aa8d00a0c02cd8f857 (patch) | |
tree | f2a51fcd599667e6d30496cd99c8a1479a19bb1e /gtk2_ardour/editor_drag.cc | |
parent | 7b8efcc25002c1b747fcaa00be8f19f23c930735 (diff) |
Tie note y to mouse pointer position when dragging MIDI
notes (#4051).
git-svn-id: svn://localhost/ardour2/branches/3.0@9886 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/editor_drag.cc')
-rw-r--r-- | gtk2_ardour/editor_drag.cc | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index c889921db7..deffee2ecd 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -3890,29 +3890,11 @@ NoteDrag::total_dx () const return _region->snap_frame_to_frame (st) - n; } -/** @return Current total drag y change in notes */ +/** @return Current total drag y change in note number */ int8_t NoteDrag::total_dy () const { - /* this is `backwards' to make increasing note number go in the right direction */ - double const dy = _drags->current_pointer_y() - grab_y(); - - /* dy in notes */ - int8_t ndy = 0; - - if (abs (dy) >= _note_height) { - if (dy > 0) { - ndy = (int8_t) ceil (dy / _note_height / 2.0); - } else { - ndy = (int8_t) floor (dy / _note_height / 2.0); - } - } - - /* more positive value = higher pitch and higher y-axis position on track, - which is the inverse of the X-centric geometric universe - */ - - return -ndy; + return ((int8_t) (grab_y() / _note_height)) - ((int8_t) (_drags->current_pointer_y() / _note_height)); } void @@ -3920,11 +3902,11 @@ NoteDrag::motion (GdkEvent *, bool) { /* Total change in x and y since the start of the drag */ frameoffset_t const dx = total_dx (); - int8_t const dy = -total_dy (); + int8_t const dy = total_dy (); /* Now work out what we have to do to the note canvas items to set this new drag delta */ double const tdx = _editor->frame_to_unit (dx) - _cumulative_dx; - double const tdy = dy * _note_height - _cumulative_dy; + double const tdy = -dy * _note_height - _cumulative_dy; if (tdx || tdy) { _cumulative_dx += tdx; |