Changes to Editor::visual_changer to support Item/Canvas::prepare_for_render

This is necessary to allow calculation of correct intersection of visible
canvas area and items for the new Item::prepare_for_render() API.

samples_per_pixel must be set first to calculate the new horizontal canvas
position in Editor::set_horizontal_position and then
WaveView::set_samples_per_pixel will eventually call
WaveView::prepare_for_render for those items that are visible on the new canvas
position at the new position.

Or if there is not a change to zoom state then call Canvas::prepare_for_render
explicitly.

Also changes so that each method is only called once during
Editor::visual_changer
This commit is contained in:
Tim Mayberry 2017-03-27 13:26:58 +10:00
parent 4ddf97f5a2
commit 5f30d87fd0
3 changed files with 38 additions and 24 deletions

View File

@ -4510,7 +4510,11 @@ Editor::set_samples_per_pixel (framecnt_t spp)
}
samples_per_pixel = spp;
}
void
Editor::on_samples_per_pixel_changed ()
{
if (tempo_lines) {
tempo_lines->tempo_map_changed(_session->tempo_map().music_origin());
}
@ -4630,36 +4634,54 @@ Editor::idle_visual_changer ()
void
Editor::visual_changer (const VisualChange& vc)
{
double const last_time_origin = horizontal_position ();
/**
* Changed first so the correct horizontal canvas position is calculated in
* Editor::set_horizontal_position
*/
if (vc.pending & VisualChange::ZoomLevel) {
set_samples_per_pixel (vc.samples_per_pixel);
compute_fixed_ruler_scale ();
compute_bbt_ruler_scale (vc.time_origin, pending_visual_change.time_origin + current_page_samples());
update_tempo_based_rulers ();
update_video_timeline();
}
if (vc.pending & VisualChange::TimeOrigin) {
set_horizontal_position (sample_to_pixel_unrounded (vc.time_origin));
double new_time_origin = sample_to_pixel_unrounded (vc.time_origin);
set_horizontal_position (new_time_origin);
}
if (vc.pending & VisualChange::YOrigin) {
vertical_adjustment.set_value (vc.y_origin);
}
if (last_time_origin == horizontal_position ()) {
/* changed signal not emitted */
/**
* 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 ();
compute_fixed_ruler_scale ();
compute_bbt_ruler_scale (vc.time_origin, pending_visual_change.time_origin + current_page_samples());
update_tempo_based_rulers ();
}
if (!(vc.pending & VisualChange::ZoomLevel)) {
/**
* 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.
*/
_track_canvas->prepare_for_render();
}
// If we are only scrolling vertically there is no need to update these
if (vc.pending != VisualChange::YOrigin) {
update_fixed_rulers ();
redisplay_tempo (true);
}
if (!(vc.pending & VisualChange::ZoomLevel)) {
update_video_timeline();
}
update_video_timeline();
_summary->set_overlays_dirty ();
}

View File

@ -610,6 +610,7 @@ private:
Editing::ZoomFocus zoom_focus;
void set_samples_per_pixel (framecnt_t);
void on_samples_per_pixel_changed ();
Editing::MouseMode mouse_mode;
Editing::SnapType pre_internal_snap_type;

View File

@ -913,15 +913,6 @@ Editor::set_horizontal_position (double p)
horizontal_adjustment.set_value (p);
leftmost_frame = (framepos_t) floor (p * samples_per_pixel);
update_fixed_rulers ();
redisplay_tempo (true);
if (pending_visual_change.idle_handler_id < 0) {
_summary->set_overlays_dirty ();
}
update_video_timeline();
}
void