pianoroll: update bbt ruler when changing zoom level

This commit is contained in:
Paul Davis 2025-05-16 15:01:44 -06:00
parent 5a0919f2b0
commit c3a4026ace
2 changed files with 15 additions and 13 deletions

View file

@ -1955,18 +1955,9 @@ Pianoroll::visual_changer (const VisualChange& vc)
vertical_adjustment.set_value (vc.y_origin);
}
/**
* Now the canvas is in the final state before render the canvas items that
* support the Item::prepare_for_render interface can calculate the correct
* item to visible canvas intersection.
*/
if (vc.pending & VisualChange::ZoomLevel) {
on_samples_per_pixel_changed ();
// update_tempo_based_rulers ();
}
if (!(vc.pending & VisualChange::ZoomLevel)) {
} else {
/* If the canvas is not being zoomed then the canvas items will not change
* and cause Item::prepare_for_render to be called so do it here manually.
* Not ideal, but I can't think of a better solution atm.
@ -1984,9 +1975,7 @@ Pianoroll::visual_changer (const VisualChange& vc)
void
Pianoroll::on_samples_per_pixel_changed ()
{
if (view) {
view->set_samples_per_pixel (samples_per_pixel);
}
update_tempo_based_rulers ();
}
void
@ -3043,3 +3032,15 @@ Pianoroll::instrument_info () const
return &view->midi_track()->instrument_info ();
}
void
Pianoroll::update_tempo_based_rulers ()
{
if (!_session) {
return;
}
bbt_metric.units_per_pixel = samples_per_pixel;
compute_bbt_ruler_scale (_leftmost_sample, _leftmost_sample + current_page_samples());
bbt_ruler->set_range (_leftmost_sample, _leftmost_sample+current_page_samples());
}

View file

@ -347,4 +347,5 @@ class Pianoroll : public CueEditor
bool bbt_ruler_event (GdkEvent*);
void ruler_locate (GdkEventButton*);
void scrolled ();
void update_tempo_based_rulers ();
};