From 844d4589697155cbb7662f8833ddca40e8ca9ba2 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 14 Aug 2025 00:04:19 +0200 Subject: [PATCH] Add optional ProcessorBox to Route-Properties (bottom attachment) --- gtk2_ardour/route_properties_box.cc | 75 +++++++++++++++++++++++++++-- gtk2_ardour/route_properties_box.h | 12 +++++ 2 files changed, 84 insertions(+), 3 deletions(-) diff --git a/gtk2_ardour/route_properties_box.cc b/gtk2_ardour/route_properties_box.cc index 0f111b2d8f..9ebdca7b85 100644 --- a/gtk2_ardour/route_properties_box.cc +++ b/gtk2_ardour/route_properties_box.cc @@ -22,6 +22,7 @@ #include "pbd/compose.h" +#include "ardour/audio_track.h" #include "ardour/plugin_insert.h" #include "ardour/port_insert.h" #include "ardour/route.h" @@ -30,8 +31,8 @@ #include "gtkmm2ext/gui_thread.h" #include "gtkmm2ext/utils.h" -#include "widgets/frame.h" - +#include "ardour_ui.h" +#include "mixer_ui.h" #include "plugin_selector.h" #include "plugin_ui.h" #include "port_insert_ui.h" @@ -46,21 +47,34 @@ using namespace ARDOUR; using namespace ArdourWidgets; RoutePropertiesBox::RoutePropertiesBox () - : _idle_refill_processors_id (-1) + : _insert_box (nullptr) + , _show_insert (false) + , _idle_refill_processors_id (-1) { _scroller.set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER); _scroller.add (_box); _box.set_spacing (4); + _insert_frame.set_no_show_all (); + pack_start (_insert_frame, false, false, 4); pack_start (_scroller, true, true); show_all(); + + ARDOUR_UI::instance()->ActionsReady.connect_same_thread (_forever_connections, std::bind (&RoutePropertiesBox::ui_actions_ready, this)); } RoutePropertiesBox::~RoutePropertiesBox () { } +void +RoutePropertiesBox::ui_actions_ready () +{ + Glib::RefPtr tact = ActionManager::get_toggle_action (X_("Editor"), X_("show-editor-mixer")); + tact->signal_toggled().connect (sigc::mem_fun (*this, &RoutePropertiesBox::update_processor_box_visibility)); +} + void RoutePropertiesBox::session_going_away () { @@ -69,6 +83,24 @@ RoutePropertiesBox::session_going_away () drop_plugin_uis (); drop_route (); + delete _insert_box; + _insert_box = nullptr; +} + +void +RoutePropertiesBox::set_session (ARDOUR::Session* s) { + SessionHandlePtr::set_session (s); + if (!s) { + return; + } + delete _insert_box; + _insert_box = new ProcessorBox (_session, std::bind (&Mixer_UI::plugin_selector, Mixer_UI::instance()), Mixer_UI::instance()->selection(), 0); + _insert_box->show_all (); + + float ui_scale = std::max (1.f, UIConfiguration::instance().get_ui_scale()); + _insert_frame.add (*_insert_box); + _insert_frame.set_padding (4); + _insert_frame.set_size_request (144 * ui_scale, 236 * ui_scale); } void @@ -84,9 +116,44 @@ RoutePropertiesBox::set_route (std::shared_ptr r) _route->processors_changed.connect (_route_connections, invalidator (*this), std::bind (&RoutePropertiesBox::idle_refill_processors, this), gui_context()); _route->PropertyChanged.connect (_route_connections, invalidator (*this), std::bind (&RoutePropertiesBox::property_changed, this, _1), gui_context ()); _route->DropReferences.connect (_route_connections, invalidator (*this), std::bind (&RoutePropertiesBox::drop_route, this), gui_context()); + + std::shared_ptr at = std::dynamic_pointer_cast(_route); + if (at) { + at->FreezeChange.connect (_route_connections, invalidator (*this), std::bind (&RoutePropertiesBox::map_frozen, this), gui_context()); + } + + _insert_box->set_route (r); refill_processors (); } +void +RoutePropertiesBox::map_frozen () +{ + ENSURE_GUI_THREAD (*this, &RoutePropertiesBox::map_frozen) + std::shared_ptr at = std::dynamic_pointer_cast(_route); + if (at && _insert_box) { + switch (at->freeze_state()) { + case AudioTrack::Frozen: + _insert_box->set_sensitive (false); + break; + default: + _insert_box->set_sensitive (true); + break; + } + } +} + +void +RoutePropertiesBox::update_processor_box_visibility () +{ + _show_insert = !ActionManager::get_toggle_action (X_("Editor"), X_("show-editor-mixer"))->get_active (); + if (!_show_insert || _proc_uis.empty ()) { + _insert_frame.hide (); + } else { + _insert_frame.show (); + } +} + void RoutePropertiesBox::property_changed (const PBD::PropertyChange& what_changed) { @@ -121,6 +188,7 @@ RoutePropertiesBox::drop_plugin_uis () _processor_connections.drop_connections (); _proc_uis.clear (); + _insert_frame.hide (); } void @@ -195,5 +263,6 @@ RoutePropertiesBox::refill_processors () _box.set_size_request (-1, h); _scroller.show_all (); } + update_processor_box_visibility (); _idle_refill_processors_id = -1; } diff --git a/gtk2_ardour/route_properties_box.h b/gtk2_ardour/route_properties_box.h index 90340a48e3..2bbe4b9c6e 100644 --- a/gtk2_ardour/route_properties_box.h +++ b/gtk2_ardour/route_properties_box.h @@ -28,6 +28,8 @@ #include "ardour/ardour.h" #include "ardour/session_handle.h" +#include "widgets/frame.h" + namespace ARDOUR { class Route; class Processor; @@ -35,6 +37,7 @@ namespace ARDOUR { } class GenericPluginUI; +class ProcessorBox; class RoutePropertiesBox : public Gtk::HBox, public ARDOUR::SessionHandlePtr { @@ -42,10 +45,14 @@ public: RoutePropertiesBox (); ~RoutePropertiesBox (); + void set_session (ARDOUR::Session*); void set_route (std::shared_ptr); private: void property_changed (const PBD::PropertyChange& what_changed); + void map_frozen (); + void ui_actions_ready (); + void update_processor_box_visibility (); void session_going_away (); void drop_route (); void drop_plugin_uis (); @@ -61,9 +68,14 @@ private: std::shared_ptr _route; std::vector _proc_uis; + ArdourWidgets::Frame _insert_frame; + ProcessorBox* _insert_box; + bool _show_insert; + int _idle_refill_processors_id; PBD::ScopedConnectionList _processor_connections; PBD::ScopedConnectionList _route_connections; + PBD::ScopedConnectionList _forever_connections; };