diff options
author | nick_m <mainsbridge@gmail.com> | 2015-05-23 05:36:03 +1000 |
---|---|---|
committer | nick_m <mainsbridge@gmail.com> | 2015-05-23 05:36:03 +1000 |
commit | ea8b5a970f7fdc0818fb86c32c93dd564eff941c (patch) | |
tree | 68b2b6c93267d9131aee82ffa9440c27e40b7782 /gtk2_ardour/midi_region_view.cc | |
parent | 3d599be991a71b7e4611b1c38ee88a77bf1c5460 (diff) |
Bring back contrained drag modifier with preference setting.
- this should work as before, but when applied to a button 1 drag,
the constraint is in the first direction travelled.
Diffstat (limited to 'gtk2_ardour/midi_region_view.cc')
-rw-r--r-- | gtk2_ardour/midi_region_view.cc | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 4b0c9f54c4..7c74b5f1e0 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -2800,15 +2800,16 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_ } if (!cursor_set) { - /* snap delta is in pixels (sigh) */ - framepos_t delta_samps = trackview.editor().pixel_to_sample (snap_delta); - double delta_beats; + /* Convert snap delta from pixels to beats. */ + framepos_t snap_delta_samps = trackview.editor().pixel_to_sample (snap_delta); + double snap_delta_beats; int sign = 1; + /* negative beat offsets aren't allowed */ - if (delta_samps > 0) { - delta_beats = region_frames_to_region_beats_double (delta_samps); - } else if (delta_samps < 0) { - delta_beats = region_frames_to_region_beats_double ( - delta_samps); + if (snap_delta_samps > 0) { + snap_delta_beats = region_frames_to_region_beats_double (snap_delta_samps); + } else if (snap_delta_samps < 0) { + snap_delta_beats = region_frames_to_region_beats_double ( - snap_delta_samps); sign = -1; } @@ -2818,12 +2819,12 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_ if (at_front) { if (beats < canvas_note->note()->end_time()) { - len = canvas_note->note()->time() - beats + (sign * delta_beats); + len = canvas_note->note()->time() - beats + (sign * snap_delta_beats); len += canvas_note->note()->length(); } } else { if (beats >= canvas_note->note()->time()) { - len = beats - canvas_note->note()->time() - (sign * delta_beats); + len = beats - canvas_note->note()->time() - (sign * snap_delta_beats); } } @@ -2878,9 +2879,12 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_ if (current_x > trackview.editor().sample_to_pixel(_region->length())) { current_x = trackview.editor().sample_to_pixel(_region->length()); } + + /* Convert snap delta from pixels to beats with sign. */ framepos_t snap_delta_samps = trackview.editor().pixel_to_sample (snap_delta); double snap_delta_beats; int sign = 1; + if (snap_delta_samps > 0) { snap_delta_beats = region_frames_to_region_beats_double (snap_delta_samps); } else if (snap_delta_samps < 0) { @@ -2888,7 +2892,7 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_ sign = -1; } - /* Convert that to a frame within the source */ + /* Convert the new x position to a frame within the source */ const framepos_t current_fr = snap_pixel_to_sample (current_x, with_snap) + _region->start (); /* and then to beats */ |