From a8b4345d8ff7aceaa611c474ac76e7ca92e93e00 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 14 May 2025 11:35:53 -0600 Subject: [PATCH] change API of EditorSections to take an EditingContext& at construction Then use this instead of PublicEditor::instance() in its code, mostly. --- gtk2_ardour/editor.cc | 2 +- gtk2_ardour/editor_sections.cc | 17 +++++++++-------- gtk2_ardour/editor_sections.h | 5 ++++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 8161bf896c..ec4db97994 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -540,7 +540,7 @@ Editor::Editor () _routes = new EditorRoutes (); _regions = new EditorRegions (this); _sources = new EditorSources (this); - _sections = new EditorSections (); + _sections = new EditorSections (*this); _snapshots = new EditorSnapshots (); _locations = new EditorLocations (this); _properties_box = new SelectionPropertiesBox (); diff --git a/gtk2_ardour/editor_sections.cc b/gtk2_ardour/editor_sections.cc index d37acdddf2..3e88d990d8 100644 --- a/gtk2_ardour/editor_sections.cc +++ b/gtk2_ardour/editor_sections.cc @@ -25,11 +25,11 @@ #include "ardour_ui.h" #include "context_menu_helper.h" +#include "editing_context.h" #include "editor_sections.h" #include "gui_thread.h" #include "keyboard.h" #include "main_clock.h" -#include "public_editor.h" #include "ui_config.h" #include "utils.h" @@ -40,8 +40,9 @@ using namespace PBD; using namespace Gtk; using namespace ARDOUR; -EditorSections::EditorSections () - : _no_redisplay (false) +EditorSections::EditorSections (EditingContext& ec) + : editing_context (ec) + , _no_redisplay (false) { _model = ListStore::create (_columns); _view.set_model (_model); @@ -87,7 +88,7 @@ EditorSections::EditorSections () ARDOUR_UI::instance ()->primary_clock->mode_changed.connect (sigc::mem_fun (*this, &EditorSections::clock_format_changed)); - _selection_change = PublicEditor::instance ().get_selection ().TimeChanged.connect (sigc::mem_fun (*this, &EditorSections::update_time_selection)); + _selection_change = editing_context.get_selection ().TimeChanged.connect (sigc::mem_fun (*this, &EditorSections::update_time_selection)); } void @@ -234,7 +235,7 @@ EditorSections::update_time_selection () _view.get_selection ()->unselect_all (); - Selection& selection (PublicEditor::instance ().get_selection ()); + Selection& selection (editing_context.get_selection ()); if (selection.time.empty ()) { return; @@ -264,7 +265,7 @@ EditorSections::selection_changed () return; } - if (PublicEditor::instance ().drag_active ()) { + if (editing_context.drag_active ()) { return; } @@ -315,7 +316,7 @@ EditorSections::selection_changed () break; } - Selection& s (PublicEditor::instance ().get_selection ()); + Selection& s (editing_context.get_selection ()); s.clear (); s.set (start, end); @@ -511,7 +512,7 @@ EditorSections::delete_selected_section () } redisplay (); - PublicEditor::instance ().get_selection ().clear (); + editing_context.get_selection ().clear (); return true; } diff --git a/gtk2_ardour/editor_sections.h b/gtk2_ardour/editor_sections.h index 95815308d2..7d6c191359 100644 --- a/gtk2_ardour/editor_sections.h +++ b/gtk2_ardour/editor_sections.h @@ -29,10 +29,12 @@ #include #include +class EditingContext; + class EditorSections : public ARDOUR::SessionHandlePtr, public virtual sigc::trackable { public: - EditorSections (); + EditorSections (EditingContext&); void set_session (ARDOUR::Session*); @@ -115,6 +117,7 @@ private: Gtk::TreeView _view; Gtk::ScrolledWindow _scroller; + EditingContext& editing_context; LocationRowMap _location_row_map; bool _no_redisplay; sigc::connection _scroll_timeout;