From 1721681c7d066ac2a381032c096a2e1db9cb4e91 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 16 Dec 2025 15:29:56 -0700 Subject: [PATCH] fix display of MIDI regions in cue editors even when they do not start at the source start This also shows signs of mild improvements in the initial zoom setting for cue editors, though more work is needed there --- gtk2_ardour/cue_editor.cc | 14 ++++++++------ gtk2_ardour/cue_editor.h | 2 +- gtk2_ardour/pianoroll.cc | 6 +++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/gtk2_ardour/cue_editor.cc b/gtk2_ardour/cue_editor.cc index 6197db0944..42b6adf12c 100644 --- a/gtk2_ardour/cue_editor.cc +++ b/gtk2_ardour/cue_editor.cc @@ -1189,12 +1189,14 @@ CueEditor::max_zoom_extent() const if (show_source) { len = _region->source()->length().beats(); + if (len != Temporal::Beats()) { + return std::make_pair (timepos_t (Temporal::Beats()), timepos_t (_region->end().beats())); + } } else { len = _region->length().beats(); - } - - if (len != Temporal::Beats()) { - return std::make_pair (Temporal::timepos_t (Temporal::Beats()), Temporal::timepos_t (len)); + if (len != Temporal::Beats()) { + return std::make_pair (timepos_t (_region->start().beats()), timepos_t (_region->end().beats())); + } } } @@ -1203,7 +1205,7 @@ CueEditor::max_zoom_extent() const } void -CueEditor::zoom_to_show (Temporal::timecnt_t const & duration) +CueEditor::zoom_to_show (std::pair const & z) { EC_LOCAL_TEMPO_SCOPE; @@ -1212,7 +1214,7 @@ CueEditor::zoom_to_show (Temporal::timecnt_t const & duration) return; } - reset_zoom ((samplecnt_t) floor (duration.samples() / _track_canvas_width)); + reposition_and_zoom (z.first.samples(), (samplecnt_t) floor ((max_extents_scale() * ((z.second.samples() - z.first.samples())) / (double) _track_canvas_width))); } void diff --git a/gtk2_ardour/cue_editor.h b/gtk2_ardour/cue_editor.h index 0e16a582a7..bf6a859105 100644 --- a/gtk2_ardour/cue_editor.h +++ b/gtk2_ardour/cue_editor.h @@ -120,7 +120,7 @@ class CueEditor : public EditingContext, public PBD::HistoryOwner std::pair max_zoom_extent() const; void full_zoom_clicked(); - void zoom_to_show (Temporal::timecnt_t const &); + void zoom_to_show (std::pair const &); bool ruler_event (GdkEvent*); diff --git a/gtk2_ardour/pianoroll.cc b/gtk2_ardour/pianoroll.cc index 92c69f2795..f6eda019e2 100644 --- a/gtk2_ardour/pianoroll.cc +++ b/gtk2_ardour/pianoroll.cc @@ -658,7 +658,7 @@ Pianoroll::canvas_allocate (Gtk::Allocation alloc) if (zoom_in_allocate) { - zoom_to_show (timecnt_t (timepos_t (max_extents_scale() * max_zoom_extent ().second.samples()))); + zoom_to_show (max_zoom_extent()); if (_region) { bg->display_region (*view); } @@ -1468,7 +1468,7 @@ Pianoroll::set_region (std::shared_ptr region) /* Compute zoom level to show entire source plus some margin if possible */ - zoom_to_show (timecnt_t (timepos_t (max_extents_scale() * max_zoom_extent ().second.samples()))); + zoom_to_show (max_zoom_extent()); bg->display_region (*view); @@ -1843,7 +1843,7 @@ Pianoroll::set_session (ARDOUR::Session* s) } if (_session) { - zoom_to_show (timecnt_t (timepos_t (max_extents_scale() * max_zoom_extent ().second.samples()))); + zoom_to_show (max_zoom_extent()); } }