From 6a4f4e471078c0ea259388aa8ae813694fd6609f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 1 Jul 2025 17:29:46 -0600 Subject: [PATCH] rework NoteDrag::total_dy() to correctly clamp y to within the required range --- gtk2_ardour/editor_drag.cc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index ccb616828d..b531d55acc 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -6232,15 +6232,12 @@ NoteDrag::total_dy () const return 0; } - double const y = _view->midi_context().y_position (); - /* new current note */ - uint8_t n = _view->y_to_note (current_pointer_y () - y); - /* clamp */ - MidiViewBackground& mvb = _view->midi_context (); - n = max (mvb.lowest_note (), n); - n = min (mvb.highest_note (), n); + /* clamp y to the view-relative vertical boundaries of the view */ + int o = _view->midi_context().y_position (); + int y = std::max (0, (std::min ((int) current_pointer_y(), o + _view->midi_context().contents_height() - _view->note_height()))); + /* and work out delta */ - return n - _view->y_to_note (grab_y () - y); + return _view->y_to_note (y - o) - _view->y_to_note (grab_y () - o); } void