change API of EditorSections to take an EditingContext& at construction

Then use this instead of PublicEditor::instance() in its code, mostly.
This commit is contained in:
Paul Davis 2025-05-14 11:35:53 -06:00
parent 316947f7dc
commit a8b4345d8f
3 changed files with 14 additions and 10 deletions

View file

@ -540,7 +540,7 @@ Editor::Editor ()
_routes = new EditorRoutes (); _routes = new EditorRoutes ();
_regions = new EditorRegions (this); _regions = new EditorRegions (this);
_sources = new EditorSources (this); _sources = new EditorSources (this);
_sections = new EditorSections (); _sections = new EditorSections (*this);
_snapshots = new EditorSnapshots (); _snapshots = new EditorSnapshots ();
_locations = new EditorLocations (this); _locations = new EditorLocations (this);
_properties_box = new SelectionPropertiesBox (); _properties_box = new SelectionPropertiesBox ();

View file

@ -25,11 +25,11 @@
#include "ardour_ui.h" #include "ardour_ui.h"
#include "context_menu_helper.h" #include "context_menu_helper.h"
#include "editing_context.h"
#include "editor_sections.h" #include "editor_sections.h"
#include "gui_thread.h" #include "gui_thread.h"
#include "keyboard.h" #include "keyboard.h"
#include "main_clock.h" #include "main_clock.h"
#include "public_editor.h"
#include "ui_config.h" #include "ui_config.h"
#include "utils.h" #include "utils.h"
@ -40,8 +40,9 @@ using namespace PBD;
using namespace Gtk; using namespace Gtk;
using namespace ARDOUR; using namespace ARDOUR;
EditorSections::EditorSections () EditorSections::EditorSections (EditingContext& ec)
: _no_redisplay (false) : editing_context (ec)
, _no_redisplay (false)
{ {
_model = ListStore::create (_columns); _model = ListStore::create (_columns);
_view.set_model (_model); _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)); 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 void
@ -234,7 +235,7 @@ EditorSections::update_time_selection ()
_view.get_selection ()->unselect_all (); _view.get_selection ()->unselect_all ();
Selection& selection (PublicEditor::instance ().get_selection ()); Selection& selection (editing_context.get_selection ());
if (selection.time.empty ()) { if (selection.time.empty ()) {
return; return;
@ -264,7 +265,7 @@ EditorSections::selection_changed ()
return; return;
} }
if (PublicEditor::instance ().drag_active ()) { if (editing_context.drag_active ()) {
return; return;
} }
@ -315,7 +316,7 @@ EditorSections::selection_changed ()
break; break;
} }
Selection& s (PublicEditor::instance ().get_selection ()); Selection& s (editing_context.get_selection ());
s.clear (); s.clear ();
s.set (start, end); s.set (start, end);
@ -511,7 +512,7 @@ EditorSections::delete_selected_section ()
} }
redisplay (); redisplay ();
PublicEditor::instance ().get_selection ().clear (); editing_context.get_selection ().clear ();
return true; return true;
} }

View file

@ -29,10 +29,12 @@
#include <ytkmm/treemodel.h> #include <ytkmm/treemodel.h>
#include <ytkmm/treeview.h> #include <ytkmm/treeview.h>
class EditingContext;
class EditorSections : public ARDOUR::SessionHandlePtr, public virtual sigc::trackable class EditorSections : public ARDOUR::SessionHandlePtr, public virtual sigc::trackable
{ {
public: public:
EditorSections (); EditorSections (EditingContext&);
void set_session (ARDOUR::Session*); void set_session (ARDOUR::Session*);
@ -115,6 +117,7 @@ private:
Gtk::TreeView _view; Gtk::TreeView _view;
Gtk::ScrolledWindow _scroller; Gtk::ScrolledWindow _scroller;
EditingContext& editing_context;
LocationRowMap _location_row_map; LocationRowMap _location_row_map;
bool _no_redisplay; bool _no_redisplay;
sigc::connection _scroll_timeout; sigc::connection _scroll_timeout;