From 7ec2bc4eddcf44d616e2383534f63a265a45fc43 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 15 Jan 2025 15:09:58 -0700 Subject: [PATCH] fix rubber band selection coords so that it works in Editor & Pianoroll --- gtk2_ardour/midi_view.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/midi_view.cc b/gtk2_ardour/midi_view.cc index 28de246c7c..a18d20808a 100644 --- a/gtk2_ardour/midi_view.cc +++ b/gtk2_ardour/midi_view.cc @@ -2566,10 +2566,18 @@ MidiView::update_drag_selection(timepos_t const & start, timepos_t const & end, // Convert to local coordinates const double y = _midi_context.y_position(); - const double x0 = _editing_context.sample_to_pixel_unrounded (max(0, _midi_region->region_relative_position (start).samples())); - const double x1 = _editing_context.sample_to_pixel_unrounded (max(0, _midi_region->region_relative_position (end).samples())); const double y0 = max(0.0, gy0 - y); const double y1 = max(0.0, gy1 - y); + double x0; + double x1; + + if (_midi_region && !_show_source) { + x0 = _editing_context.sample_to_pixel_unrounded (max(0, _midi_region->region_relative_position (start).samples())); + x1 = _editing_context.sample_to_pixel_unrounded (max(0, _midi_region->region_relative_position (end).samples())); + } else { + x0 = _editing_context.sample_to_pixel_unrounded (max(0, start.samples())); + x1 = _editing_context.sample_to_pixel_unrounded (max(0, end.samples())); + } // TODO: Make this faster by storing the last updated selection rect, and only // adjusting things that are in the area that appears/disappeared.