From 852ad9a7da5f39d9d74a87a9c92c9146e97588e4 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 29 Jan 2025 10:52:51 -0700 Subject: [PATCH] move grid updating code and members into EditingContext --- gtk2_ardour/cue_editor.cc | 1 + gtk2_ardour/editing_context.cc | 24 ++++++++++++++++++++++++ gtk2_ardour/editing_context.h | 3 +++ gtk2_ardour/editor.cc | 23 ----------------------- gtk2_ardour/editor.h | 3 +-- gtk2_ardour/pianoroll.cc | 4 +++- gtk2_ardour/pianoroll.h | 1 - gtk2_ardour/public_editor.h | 1 - 8 files changed, 32 insertions(+), 28 deletions(-) diff --git a/gtk2_ardour/cue_editor.cc b/gtk2_ardour/cue_editor.cc index 3322067343..f1ce559e2e 100644 --- a/gtk2_ardour/cue_editor.cc +++ b/gtk2_ardour/cue_editor.cc @@ -90,6 +90,7 @@ CueEditor::autoscroll_active() const void CueEditor::redisplay_grid (bool immediate_redraw) { + update_grid (); } Temporal::timecnt_t diff --git a/gtk2_ardour/editing_context.cc b/gtk2_ardour/editing_context.cc index 8913d14847..5b2c2edc8d 100644 --- a/gtk2_ardour/editing_context.cc +++ b/gtk2_ardour/editing_context.cc @@ -168,6 +168,7 @@ EditingContext::EditingContext (std::string const & name) , entered_regionview (nullptr) , clear_entered_track (false) , grid_lines (nullptr) + , time_line_group (nullptr) { using namespace Gtk::Menu_Helpers; @@ -254,6 +255,7 @@ EditingContext::EditingContext (std::string const & name) EditingContext::~EditingContext() { + delete grid_lines; } void @@ -3348,3 +3350,25 @@ EditingContext::maybe_draw_grid_lines (ArdourCanvas::Container* group) grid_lines->show(); } + +void +EditingContext::update_grid () +{ + if (!_session) { + return; + } + + if (_grid_type == GridTypeNone) { + hide_grid_lines (); + } else if (grid_musical()) { +// Temporal::TempoMapPoints grid; +// grid.reserve (4096); +// if (bbt_ruler_scale != bbt_show_many) { +// compute_current_bbt_points (grid, _leftmost_sample, _leftmost_sample + current_page_samples()); +// } + maybe_draw_grid_lines (time_line_group); + } else { + maybe_draw_grid_lines (time_line_group); + } +} + diff --git a/gtk2_ardour/editing_context.h b/gtk2_ardour/editing_context.h index 6f54d53065..a5600a3baa 100644 --- a/gtk2_ardour/editing_context.h +++ b/gtk2_ardour/editing_context.h @@ -480,6 +480,8 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider Gtkmm2ext::Bindings* get_bindings() const { return bindings; } + virtual void update_grid (); + protected: std::string _name; bool within_track_canvas; @@ -765,6 +767,7 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider std::vector grid_marks; GridLines* grid_lines; + ArdourCanvas::Container* time_line_group; void drop_grid (); void hide_grid_lines (); diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 45c476b4ac..1517659065 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -154,7 +154,6 @@ #include "selection_properties_box.h" #include "simple_progress_dialog.h" #include "sfdb_ui.h" -#include "grid_lines.h" #include "time_axis_view.h" #include "timers.h" #include "ui_config.h" @@ -318,7 +317,6 @@ Editor::Editor () , _stationary_playhead (false) , _maximised (false) , global_rect_group (0) - , time_line_group (0) , tempo_marker_menu (0) , meter_marker_menu (0) , bbt_marker_menu (0) @@ -3406,27 +3404,6 @@ Editor::cycle_marker_click_behavior () } } -void -Editor::update_grid () -{ - if (!_session) { - return; - } - - if (_grid_type == GridTypeNone) { - hide_grid_lines (); - } else if (grid_musical()) { - Temporal::TempoMapPoints grid; - grid.reserve (4096); - if (bbt_ruler_scale != bbt_show_many) { - compute_current_bbt_points (grid, _leftmost_sample, _leftmost_sample + current_page_samples()); - } - maybe_draw_grid_lines (time_line_group); - } else { - maybe_draw_grid_lines (time_line_group); - } -} - void Editor::toggle_stationary_playhead () { diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index e351554ab2..14eace52ec 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -250,7 +250,7 @@ public: /* tempo */ - void update_grid (); + // void update_grid (); /* analysis window */ @@ -1640,7 +1640,6 @@ private: bool _maximised; ArdourCanvas::Container* global_rect_group; - ArdourCanvas::Container* time_line_group; void new_tempo_section (); diff --git a/gtk2_ardour/pianoroll.cc b/gtk2_ardour/pianoroll.cc index edd312a6d3..b652183f4f 100644 --- a/gtk2_ardour/pianoroll.cc +++ b/gtk2_ardour/pianoroll.cc @@ -538,6 +538,8 @@ Pianoroll::canvas_allocate (Gtk::Allocation alloc) zoom_to_show (timecnt_t (timepos_t (max_extents_scale() * max_zoom_extent ().second.samples()))); zoom_in_allocate = false; } + + update_grid (); } timepos_t @@ -1714,7 +1716,7 @@ Pianoroll::visual_changer (const VisualChange& vc) /* If we are only scrolling vertically there is no need to update these */ if (vc.pending != VisualChange::YOrigin) { // XXX update_fixed_rulers (); - // XXX redisplay_grid (true); + redisplay_grid (true); } } diff --git a/gtk2_ardour/pianoroll.h b/gtk2_ardour/pianoroll.h index f11f1e31c8..6448f90653 100644 --- a/gtk2_ardour/pianoroll.h +++ b/gtk2_ardour/pianoroll.h @@ -188,7 +188,6 @@ class Pianoroll : public CueEditor ArdourCanvas::Container* global_rect_group; ArdourCanvas::Container* no_scroll_group; ArdourCanvas::Container* data_group; - ArdourCanvas::Container* time_line_group; ArdourCanvas::Ruler* bbt_ruler; ArdourCanvas::Rectangle* tempo_bar; ArdourCanvas::Rectangle* meter_bar; diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index 1987b76ba6..7ed5fbfb9f 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -191,7 +191,6 @@ public: add_location_mark_with_flag (where, flags, cue_id); } virtual void add_location_mark_with_flag (Temporal::timepos_t const & where, ARDOUR::Location::Flags, int32_t cue_id) = 0; - virtual void update_grid () = 0; virtual void remove_tracks () = 0; virtual void set_loop_range (Temporal::timepos_t const & start, Temporal::timepos_t const & end, std::string cmd) = 0; virtual void set_punch_range (Temporal::timepos_t const & start, Temporal::timepos_t const & end, std::string cmd) = 0;