diff options
author | nick_m <mainsbridge@gmail.com> | 2017-02-24 00:36:58 +1100 |
---|---|---|
committer | nick_m <mainsbridge@gmail.com> | 2017-02-24 00:36:58 +1100 |
commit | ae3c50c495ffadbc62103cc1d3a61af2b48f423e (patch) | |
tree | 03486a265f4332530c85f7f399fc3d301e0c2b08 | |
parent | cdbf6215c9401efeec131bae8b989664525d9d3a (diff) |
hotfix for flying percussive hits while dragging.
- Hit::position still may not be set correctly,
but this patch eliminates the error for now.
-rw-r--r-- | gtk2_ardour/midi_region_view.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index b495fe5c64..58db852659 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -2578,8 +2578,18 @@ MidiRegionView::move_selection(double dx_qn, double dy, double cumulative_dy) to_play.push_back (n->note()); } double const note_time_qn = session_relative_qn (n->note()->time().to_double()); - double const dx = editor->sample_to_pixel_unrounded (tmap.frame_at_quarter_note (note_time_qn + dx_qn)) - - n->item()->item_to_canvas (ArdourCanvas::Duple (n->x0(), 0)).x; + double dx = 0.0; + if (midi_view()->note_mode() == Sustained) { + dx = editor->sample_to_pixel_unrounded (tmap.frame_at_quarter_note (note_time_qn + dx_qn)) + - n->item()->item_to_canvas (ArdourCanvas::Duple (n->x0(), 0)).x; + } else { + /* Hit::x0() is offset by _position.x, unlike Note::x0() */ + Hit* hit = dynamic_cast<Hit*>(n); + if (hit) { + dx = editor->sample_to_pixel_unrounded (tmap.frame_at_quarter_note (note_time_qn + dx_qn)) + - n->item()->item_to_canvas (ArdourCanvas::Duple (((hit->x0() + hit->x1()) / 2.0) - hit->position().x, 0)).x; + } + } (*i)->move_event(dx, dy); |