2024-11-13 04:06:04 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2011-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
|
* Copyright (C) 2024 Ben Loftis <ben@harrisonconsoles.com>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
*/
|
|
|
|
|
|
2024-11-19 17:20:57 +01:00
|
|
|
#include <cassert>
|
2025-02-01 15:15:02 +01:00
|
|
|
#include <ytkmm/widget.h>
|
2024-11-19 17:20:57 +01:00
|
|
|
|
2024-11-13 04:06:04 +01:00
|
|
|
#include "pbd/compose.h"
|
|
|
|
|
|
2025-08-14 00:04:19 +02:00
|
|
|
#include "ardour/audio_track.h"
|
2024-11-19 17:20:57 +01:00
|
|
|
#include "ardour/plugin_insert.h"
|
|
|
|
|
#include "ardour/port_insert.h"
|
|
|
|
|
#include "ardour/route.h"
|
|
|
|
|
#include "ardour/session.h"
|
|
|
|
|
|
2024-11-13 04:06:04 +01:00
|
|
|
#include "gtkmm2ext/gui_thread.h"
|
|
|
|
|
#include "gtkmm2ext/utils.h"
|
|
|
|
|
|
2025-08-14 00:04:19 +02:00
|
|
|
#include "ardour_ui.h"
|
|
|
|
|
#include "mixer_ui.h"
|
2024-11-19 17:20:57 +01:00
|
|
|
#include "plugin_selector.h"
|
|
|
|
|
#include "plugin_ui.h"
|
|
|
|
|
#include "port_insert_ui.h"
|
2024-11-13 04:06:04 +01:00
|
|
|
#include "route_properties_box.h"
|
2024-11-19 17:20:57 +01:00
|
|
|
#include "timers.h"
|
2024-11-26 23:07:18 +01:00
|
|
|
#include "ui_config.h"
|
2024-11-13 04:06:04 +01:00
|
|
|
|
|
|
|
|
#include "pbd/i18n.h"
|
|
|
|
|
|
|
|
|
|
using namespace Gtk;
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
|
using namespace ArdourWidgets;
|
|
|
|
|
|
|
|
|
|
RoutePropertiesBox::RoutePropertiesBox ()
|
2025-08-14 00:04:19 +02:00
|
|
|
: _insert_box (nullptr)
|
|
|
|
|
, _show_insert (false)
|
|
|
|
|
, _idle_refill_processors_id (-1)
|
2024-11-13 04:06:04 +01:00
|
|
|
{
|
2024-11-19 17:20:57 +01:00
|
|
|
_scroller.set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER);
|
|
|
|
|
_scroller.add (_box);
|
|
|
|
|
|
|
|
|
|
_box.set_spacing (4);
|
2025-08-14 00:04:19 +02:00
|
|
|
_insert_frame.set_no_show_all ();
|
2024-11-19 17:20:57 +01:00
|
|
|
|
2025-08-14 00:04:19 +02:00
|
|
|
pack_start (_insert_frame, false, false, 4);
|
2024-11-19 17:20:57 +01:00
|
|
|
pack_start (_scroller, true, true);
|
2024-11-13 04:06:04 +01:00
|
|
|
show_all();
|
2025-08-14 00:04:19 +02:00
|
|
|
|
|
|
|
|
ARDOUR_UI::instance()->ActionsReady.connect_same_thread (_forever_connections, std::bind (&RoutePropertiesBox::ui_actions_ready, this));
|
2024-11-13 04:06:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RoutePropertiesBox::~RoutePropertiesBox ()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-14 00:04:19 +02:00
|
|
|
void
|
|
|
|
|
RoutePropertiesBox::ui_actions_ready ()
|
|
|
|
|
{
|
|
|
|
|
Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Editor"), X_("show-editor-mixer"));
|
|
|
|
|
tact->signal_toggled().connect (sigc::mem_fun (*this, &RoutePropertiesBox::update_processor_box_visibility));
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-13 04:06:04 +01:00
|
|
|
void
|
2024-11-19 17:20:57 +01:00
|
|
|
RoutePropertiesBox::session_going_away ()
|
|
|
|
|
{
|
|
|
|
|
ENSURE_GUI_THREAD (*this, &RoutePropertiesBox::session_going_away);
|
|
|
|
|
SessionHandlePtr::session_going_away ();
|
|
|
|
|
|
2025-08-15 18:53:05 +02:00
|
|
|
_insert_frame.remove ();
|
2024-11-19 17:20:57 +01:00
|
|
|
drop_plugin_uis ();
|
|
|
|
|
drop_route ();
|
2025-08-14 00:04:19 +02:00
|
|
|
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<float> (1.f, UIConfiguration::instance().get_ui_scale());
|
2025-08-15 18:53:05 +02:00
|
|
|
_insert_frame.remove ();
|
2025-08-14 00:04:19 +02:00
|
|
|
_insert_frame.add (*_insert_box);
|
|
|
|
|
_insert_frame.set_padding (4);
|
|
|
|
|
_insert_frame.set_size_request (144 * ui_scale, 236 * ui_scale);
|
2025-09-01 17:07:45 +02:00
|
|
|
|
|
|
|
|
_session->SurroundMasterAddedOrRemoved.connect (_session_connections, invalidator (*this), std::bind (&RoutePropertiesBox::surround_master_added_or_removed, this), gui_context());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
RoutePropertiesBox::surround_master_added_or_removed ()
|
|
|
|
|
{
|
|
|
|
|
set_route (_route, true);
|
2024-11-19 17:20:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2025-09-01 17:07:45 +02:00
|
|
|
RoutePropertiesBox::set_route (std::shared_ptr<Route> r, bool force_update)
|
2024-11-13 04:06:04 +01:00
|
|
|
{
|
2025-09-01 17:07:45 +02:00
|
|
|
if (r == _route && !force_update) {
|
2024-11-23 10:54:02 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2025-08-24 15:01:35 +02:00
|
|
|
|
|
|
|
|
if (!r) {
|
|
|
|
|
drop_route ();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-19 17:20:57 +01:00
|
|
|
_route = r;
|
|
|
|
|
_route_connections.drop_connections ();
|
|
|
|
|
|
2024-11-27 01:07:52 +01:00
|
|
|
_route->processors_changed.connect (_route_connections, invalidator (*this), std::bind (&RoutePropertiesBox::idle_refill_processors, this), gui_context());
|
2024-11-19 17:20:57 +01:00
|
|
|
_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());
|
2025-08-14 00:04:19 +02:00
|
|
|
|
|
|
|
|
std::shared_ptr<AudioTrack> at = std::dynamic_pointer_cast<AudioTrack>(_route);
|
|
|
|
|
if (at) {
|
|
|
|
|
at->FreezeChange.connect (_route_connections, invalidator (*this), std::bind (&RoutePropertiesBox::map_frozen, this), gui_context());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_insert_box->set_route (r);
|
2024-11-19 17:20:57 +01:00
|
|
|
refill_processors ();
|
2024-11-13 04:06:04 +01:00
|
|
|
}
|
|
|
|
|
|
2025-08-14 00:04:19 +02:00
|
|
|
void
|
|
|
|
|
RoutePropertiesBox::map_frozen ()
|
|
|
|
|
{
|
|
|
|
|
ENSURE_GUI_THREAD (*this, &RoutePropertiesBox::map_frozen)
|
|
|
|
|
std::shared_ptr<AudioTrack> at = std::dynamic_pointer_cast<AudioTrack>(_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 ();
|
|
|
|
|
}
|
2025-11-05 01:40:14 +01:00
|
|
|
|
|
|
|
|
#ifndef MIXBUS
|
|
|
|
|
if (_show_insert || !_proc_uis.empty ()) {
|
|
|
|
|
float ui_scale = std::max<float> (1.f, UIConfiguration::instance().get_ui_scale());
|
|
|
|
|
set_size_request (-1, 365 * ui_scale); // match with SelectionPropertiesBox
|
|
|
|
|
} else {
|
|
|
|
|
set_size_request (-1, -1);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2025-08-14 00:04:19 +02:00
|
|
|
}
|
|
|
|
|
|
2024-11-13 04:06:04 +01:00
|
|
|
void
|
|
|
|
|
RoutePropertiesBox::property_changed (const PBD::PropertyChange& what_changed)
|
|
|
|
|
{
|
2024-11-19 17:20:57 +01:00
|
|
|
}
|
2024-11-13 04:06:04 +01:00
|
|
|
|
2024-11-19 17:20:57 +01:00
|
|
|
void
|
|
|
|
|
RoutePropertiesBox::drop_route ()
|
|
|
|
|
{
|
|
|
|
|
drop_plugin_uis ();
|
|
|
|
|
_route.reset ();
|
|
|
|
|
_route_connections.drop_connections ();
|
2024-11-28 13:41:01 +01:00
|
|
|
if (_idle_refill_processors_id >= 0) {
|
|
|
|
|
g_source_destroy (g_main_context_find_source_by_id (NULL, _idle_refill_processors_id));
|
|
|
|
|
_idle_refill_processors_id = -1;
|
|
|
|
|
}
|
2024-11-19 17:20:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
RoutePropertiesBox::drop_plugin_uis ()
|
|
|
|
|
{
|
|
|
|
|
std::list<Gtk::Widget*> children = _box.get_children ();
|
|
|
|
|
for (auto const& child : children) {
|
|
|
|
|
child->hide ();
|
|
|
|
|
_box.remove (*child);
|
|
|
|
|
delete child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (auto const& ui : _proc_uis) {
|
|
|
|
|
ui->stop_updating (0);
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_processor_connections.drop_connections ();
|
|
|
|
|
_proc_uis.clear ();
|
2025-08-14 00:04:19 +02:00
|
|
|
_insert_frame.hide ();
|
2024-11-19 17:20:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
RoutePropertiesBox::add_processor_to_display (std::weak_ptr<Processor> w)
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<Processor> p = w.lock ();
|
|
|
|
|
std::shared_ptr<PlugInsertBase> pib = std::dynamic_pointer_cast<PlugInsertBase> (p);
|
|
|
|
|
if (!pib) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-11-23 22:03:14 +01:00
|
|
|
#ifdef MIXBUS
|
2024-11-26 23:07:18 +01:00
|
|
|
if (std::dynamic_pointer_cast<PluginInsert> (pib)->channelstrip () != Processor::None) {
|
2024-11-25 23:20:49 +01:00
|
|
|
return;
|
2024-11-23 22:03:14 +01:00
|
|
|
}
|
|
|
|
|
#endif
|
2024-11-19 17:20:57 +01:00
|
|
|
GenericPluginUI* plugin_ui = new GenericPluginUI (pib, true, true);
|
2024-11-27 01:07:52 +01:00
|
|
|
if (plugin_ui->empty ()) {
|
|
|
|
|
delete plugin_ui;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//pib->DropReferences.connect (_processor_connections, invalidator (*this), std::bind (&RoutePropertiesBox::refill_processors, this), gui_context());
|
2024-11-19 17:20:57 +01:00
|
|
|
_proc_uis.push_back (plugin_ui);
|
|
|
|
|
|
|
|
|
|
ArdourWidgets::Frame* frame = new ArdourWidgets::Frame ();
|
|
|
|
|
frame->set_label (p->display_name ());
|
|
|
|
|
frame->add (*plugin_ui);
|
2024-11-26 23:07:18 +01:00
|
|
|
frame->set_padding (0);
|
2024-11-19 17:20:57 +01:00
|
|
|
_box.pack_start (*frame, false, false);
|
|
|
|
|
plugin_ui->show ();
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-27 01:07:52 +01:00
|
|
|
int
|
|
|
|
|
RoutePropertiesBox::_idle_refill_processors (gpointer arg)
|
|
|
|
|
{
|
|
|
|
|
static_cast<RoutePropertiesBox*>(arg)->refill_processors ();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
RoutePropertiesBox::idle_refill_processors ()
|
|
|
|
|
{
|
2024-11-28 13:41:01 +01:00
|
|
|
if (_idle_refill_processors_id < 0) {
|
2024-11-27 01:07:52 +01:00
|
|
|
_idle_refill_processors_id = g_idle_add_full (G_PRIORITY_HIGH_IDLE + 10, _idle_refill_processors, this, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-19 17:20:57 +01:00
|
|
|
void
|
|
|
|
|
RoutePropertiesBox::refill_processors ()
|
|
|
|
|
{
|
|
|
|
|
if (!_session || _session->deletion_in_progress()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
drop_plugin_uis ();
|
2024-11-13 04:06:04 +01:00
|
|
|
|
2024-11-19 17:20:57 +01:00
|
|
|
assert (_route);
|
2024-11-28 13:41:01 +01:00
|
|
|
|
|
|
|
|
if (!_route) {
|
|
|
|
|
_idle_refill_processors_id = -1;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-19 17:20:57 +01:00
|
|
|
_route->foreach_processor (sigc::mem_fun (*this, &RoutePropertiesBox::add_processor_to_display));
|
|
|
|
|
if (_proc_uis.empty ()) {
|
|
|
|
|
_scroller.hide ();
|
|
|
|
|
} else {
|
2024-11-26 23:07:18 +01:00
|
|
|
float ui_scale = std::max<float> (1.f, UIConfiguration::instance().get_ui_scale());
|
|
|
|
|
int h = 100 * ui_scale;
|
2024-11-19 17:20:57 +01:00
|
|
|
for (auto const& ui : _proc_uis) {
|
2025-07-16 22:07:24 +02:00
|
|
|
h = std::max<int> (h, ui->get_preferred_height () + /* frame label */ 34 * ui_scale);
|
2024-11-19 17:20:57 +01:00
|
|
|
}
|
2024-11-26 23:07:18 +01:00
|
|
|
h = std::min<int> (h, 300 * ui_scale);
|
|
|
|
|
_box.set_size_request (-1, h);
|
2024-11-19 17:20:57 +01:00
|
|
|
_scroller.show_all ();
|
|
|
|
|
}
|
2025-08-14 00:04:19 +02:00
|
|
|
update_processor_box_visibility ();
|
2024-11-27 01:07:52 +01:00
|
|
|
_idle_refill_processors_id = -1;
|
2024-11-13 04:06:04 +01:00
|
|
|
}
|