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
This commit is contained in:
Paul Davis 2025-12-16 15:29:56 -07:00
parent c05877c801
commit 1721681c7d
3 changed files with 12 additions and 10 deletions

View file

@ -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<Temporal::timepos_t,Temporal::timepos_t> 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

View file

@ -120,7 +120,7 @@ class CueEditor : public EditingContext, public PBD::HistoryOwner
std::pair<Temporal::timepos_t,Temporal::timepos_t> max_zoom_extent() const;
void full_zoom_clicked();
void zoom_to_show (Temporal::timecnt_t const &);
void zoom_to_show (std::pair<Temporal::timepos_t,Temporal::timepos_t> const &);
bool ruler_event (GdkEvent*);

View file

@ -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<ARDOUR::Region> 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());
}
}