2 * Copyright (C) 2007-2014 David Robillard <d@drobilla.net>
3 * Copyright (C) 2007-2018 Paul Davis <paul@linuxaudiosystems.com>
4 * Copyright (C) 2007 Doug McLain <doug@nostar.net>
5 * Copyright (C) 2008-2012 Carl Hetherington <carl@carlh.net>
6 * Copyright (C) 2013-2015 John Emmas <john@creativepost.co.uk>
7 * Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
8 * Copyright (C) 2014-2015 Ben Loftis <ben@harrisonconsoles.com>
9 * Copyright (C) 2014-2016 Tim Mayberry <mojofunk@gmail.com>
10 * Copyright (C) 2017 Johannes Mueller <github@johannes-mueller.org>
11 * Copyright (C) 2018 Len Ovens <len@ovenwerks.net>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include "gtk2ardour-config.h"
36 #include <sigc++/bind.h>
38 #include <glibmm/miscutils.h>
39 #include <glibmm/fileutils.h>
41 #include <gtkmm/messagedialog.h>
43 #include "gtkmm2ext/colors.h"
44 #include "gtkmm2ext/gtk_ui.h"
45 #include "gtkmm2ext/menu_elems.h"
46 #include "gtkmm2ext/utils.h"
47 #include "gtkmm2ext/doi.h"
48 #include "gtkmm2ext/rgb_macros.h"
50 #include "widgets/choice.h"
51 #include "widgets/prompter.h"
52 #include "widgets/tooltips.h"
54 #include "ardour/amp.h"
55 #include "ardour/audio_track.h"
56 #include "ardour/audioengine.h"
57 #include "ardour/internal_return.h"
58 #include "ardour/internal_send.h"
59 #include "ardour/luaproc.h"
60 #include "ardour/luascripting.h"
61 #include "ardour/meter.h"
62 #include "ardour/panner_shell.h"
63 #include "ardour/plugin_insert.h"
64 #include "ardour/pannable.h"
65 #include "ardour/port_insert.h"
66 #include "ardour/profile.h"
67 #include "ardour/return.h"
68 #include "ardour/route.h"
69 #include "ardour/send.h"
70 #include "ardour/session.h"
71 #include "ardour/types.h"
72 #include "ardour/value_as_string.h"
74 #include "LuaBridge/LuaBridge.h"
77 #include "ardour_dialog.h"
78 #include "ardour_ui.h"
79 #include "gui_thread.h"
80 #include "io_selector.h"
82 #include "luainstance.h"
84 #include "mixer_strip.h"
85 #include "plugin_pin_dialog.h"
86 #include "plugin_selector.h"
87 #include "plugin_ui.h"
88 #include "port_insert_ui.h"
89 #include "processor_box.h"
90 #include "processor_selection.h"
91 #include "public_editor.h"
92 #include "return_ui.h"
93 #include "script_selector.h"
96 #include "new_plugin_preset_dialog.h"
100 #ifdef AUDIOUNIT_SUPPORT
105 bool ProcessorBox::show_all_processors = false;
109 using namespace ARDOUR;
112 using namespace Glib;
113 using namespace Gtkmm2ext;
114 using namespace ArdourWidgets;
116 ProcessorBox* ProcessorBox::_current_processor_box = 0;
117 RefPtr<Action> ProcessorBox::paste_action;
118 RefPtr<Action> ProcessorBox::cut_action;
119 RefPtr<Action> ProcessorBox::copy_action;
120 RefPtr<Action> ProcessorBox::rename_action;
121 RefPtr<Action> ProcessorBox::delete_action;
122 RefPtr<Action> ProcessorBox::backspace_action;
123 RefPtr<Action> ProcessorBox::manage_pins_action;
124 RefPtr<Action> ProcessorBox::disk_io_action;
125 RefPtr<Action> ProcessorBox::edit_action;
126 RefPtr<Action> ProcessorBox::edit_generic_action;
127 RefPtr<ActionGroup> ProcessorBox::processor_box_actions;
128 Gtkmm2ext::Bindings* ProcessorBox::bindings = 0;
131 // TODO consolidate with PluginPinDialog::set_color
132 static void set_routing_color (cairo_t* cr, bool midi)
134 static const uint32_t audio_port_color = 0x4A8A0EFF; // Green
135 static const uint32_t midi_port_color = 0x960909FF; //Red
138 cairo_set_source_rgb (cr,
139 UINT_RGBA_R_FLT(midi_port_color),
140 UINT_RGBA_G_FLT(midi_port_color),
141 UINT_RGBA_B_FLT(midi_port_color));
143 cairo_set_source_rgb (cr,
144 UINT_RGBA_R_FLT(audio_port_color),
145 UINT_RGBA_G_FLT(audio_port_color),
146 UINT_RGBA_B_FLT(audio_port_color));
150 ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processor> p, Width w)
151 : _button (ArdourButton::led_default_elements)
152 , _position (PreFader)
156 , _unknown_processor(false)
162 , output_routing_icon(false)
167 _button.set_distinct_led_click (true);
168 _button.set_fallthrough_to_parent(true);
169 _button.set_led_left (true);
170 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &ProcessorEntry::led_clicked));
171 _button.set_text (name (_width));
173 if (boost::dynamic_pointer_cast<PeakMeter> (_processor)) {
174 _button.set_elements(ArdourButton::Element(_button.elements() & ~ArdourButton::Indicator));
176 if (boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
177 _button.set_elements(ArdourButton::Element(_button.elements() & ~ArdourButton::Indicator));
178 _unknown_processor = true;
181 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
182 if (pi && pi->plugin()) {
183 _plugin_preset_pointer = PluginPresetPtr (new PluginPreset (pi->plugin()->get_info()));
188 _vbox.pack_start (routing_icon);
189 _vbox.pack_start (input_icon);
190 _vbox.pack_start (_button, true, true);
192 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
193 if (pi && pi->plugin() && pi->plugin()->has_inline_display()) {
194 if (pi->plugin()->get_info()->type != ARDOUR::Lua) {
195 _plugin_display = new PluginInlineDisplay (*this, pi->plugin(),
196 std::max (60.f, rintf(112.f * UIConfiguration::instance().get_ui_scale())));
198 assert (boost::dynamic_pointer_cast<LuaProc>(pi->plugin()));
199 _plugin_display = new LuaPluginDisplay (*this, boost::dynamic_pointer_cast<LuaProc>(pi->plugin()),
200 std::max (60.f, rintf(112.f * UIConfiguration::instance().get_ui_scale())));
202 _vbox.pack_start (*_plugin_display);
203 _plugin_display->set_no_show_all (true);
204 if (UIConfiguration::instance().get_show_inline_display_by_default ()) {
205 _plugin_display->show ();
208 _vbox.pack_end (output_routing_icon);
209 _vbox.pack_end (output_icon);
211 _button.set_active (_processor->enabled ());
213 input_icon.set_no_show_all(true);
214 routing_icon.set_no_show_all(true);
215 output_icon.set_no_show_all(true);
216 output_routing_icon.set_no_show_all(true);
222 output_routing_icon.hide();
224 _processor->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_active_changed, this), gui_context());
225 _processor->PropertyChanged.connect (name_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_property_changed, this, _1), gui_context());
226 _processor->ConfigurationChanged.connect (config_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_configuration_changed, this, _1, _2), gui_context());
228 const uint32_t limit_inline_controls = UIConfiguration::instance().get_max_inline_controls ();
230 set<Evoral::Parameter> p = _processor->what_can_be_automated ();
231 for (set<Evoral::Parameter>::iterator i = p.begin(); i != p.end(); ++i) {
233 std::string label = _processor->describe_parameter (*i);
235 if (label == X_("hidden")) {
239 if (boost::dynamic_pointer_cast<Send> (_processor)) {
241 } else if (boost::dynamic_pointer_cast<Return> (_processor)) {
245 Control* c = new Control (_processor->automation_control (*i), label);
247 _controls.push_back (c);
249 if (boost::dynamic_pointer_cast<Amp> (_processor) == 0) {
250 /* Add non-Amp (Fader & Trim) controls to the processor box */
251 _vbox.pack_start (c->box);
254 if (limit_inline_controls > 0 && _controls.size() >= limit_inline_controls) {
262 _vbox.set_size_request (-1, _button.size_request().height);
266 ProcessorEntry::~ProcessorEntry ()
268 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
271 delete _plugin_display;
275 ProcessorEntry::action_widget ()
281 ProcessorEntry::widget ()
287 ProcessorEntry::drag_text () const
293 ProcessorEntry::can_copy_state (Gtkmm2ext::DnDVBoxChild* o) const
295 ProcessorEntry *other = dynamic_cast<ProcessorEntry*> (o);
299 boost::shared_ptr<ARDOUR::Processor> otherproc = other->processor();
300 boost::shared_ptr<PluginInsert> my_pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
301 boost::shared_ptr<PluginInsert> ot_pi = boost::dynamic_pointer_cast<PluginInsert> (otherproc);
302 if (boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
305 if (boost::dynamic_pointer_cast<UnknownProcessor> (otherproc)) {
308 if (!my_pi || !ot_pi) {
311 if (my_pi->type() != ot_pi->type()) {
314 boost::shared_ptr<Plugin> my_p = my_pi->plugin();
315 boost::shared_ptr<Plugin> ot_p = ot_pi->plugin();
316 if (!my_p || !ot_p) {
319 if (my_p->unique_id() != ot_p->unique_id()) {
326 ProcessorEntry::drag_data_get (Glib::RefPtr<Gdk::DragContext> const, Gtk::SelectionData &data)
328 if (data.get_target() == "PluginPresetPtr") {
329 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
331 if (!_plugin_preset_pointer || !pi) {
332 data.set (data.get_target(), 8, NULL, 0);
336 boost::shared_ptr<ARDOUR::Plugin> plugin = pi->plugin();
339 PluginManager& manager (PluginManager::instance());
340 bool fav = manager.get_status (_plugin_preset_pointer->_pip) == PluginManager::Favorite;
342 NewPluginPresetDialog d (plugin,
343 string_compose(_("New Favorite Preset for \"%1\""),_plugin_preset_pointer->_pip->name), !fav);
345 _plugin_preset_pointer->_preset.valid = false;
348 case Gtk::RESPONSE_CANCEL:
349 data.set (data.get_target(), 8, NULL, 0);
353 case Gtk::RESPONSE_NO:
356 case Gtk::RESPONSE_ACCEPT:
357 if (d.name().empty()) {
362 plugin->remove_preset (d.name ());
365 Plugin::PresetRecord const r = plugin->save_preset (d.name());
367 if (!r.uri.empty ()) {
368 _plugin_preset_pointer->_preset.uri = r.uri;
369 _plugin_preset_pointer->_preset.label = r.label;
370 _plugin_preset_pointer->_preset.user = r.user;
371 _plugin_preset_pointer->_preset.valid = r.valid;
374 data.set (data.get_target(), 8, (const guchar *) &_plugin_preset_pointer, sizeof (PluginPresetPtr));
381 ProcessorEntry::set_position (Position p, uint32_t num)
389 ProcessorEntry::set_visual_state (Gtkmm2ext::VisualState s, bool yn)
392 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() | s));
394 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() & ~s));
399 ProcessorEntry::setup_visuals ()
401 if (_unknown_processor) {
402 _button.set_name ("processor stub");
405 boost::shared_ptr<Send> send;
406 if ((send = boost::dynamic_pointer_cast<Send> (_processor))) {
407 if (send->remove_on_disconnect ()) {
408 _button.set_name ("processor sidechain");
413 boost::shared_ptr<InternalSend> aux;
414 if ((aux = boost::dynamic_pointer_cast<InternalSend> (_processor))) {
415 if (aux->allow_feedback ()) {
416 _button.set_name ("processor auxfeedback");
423 if (_plugin_display) { _plugin_display->set_name ("processor prefader"); }
424 _button.set_name ("processor prefader");
428 _button.set_name ("processor fader");
432 if (_plugin_display) { _plugin_display->set_name ("processor postfader"); }
433 _button.set_name ("processor postfader");
439 boost::shared_ptr<Processor>
440 ProcessorEntry::processor () const
443 return boost::shared_ptr<Processor>();
449 ProcessorEntry::set_enum_width (Width w)
452 _button.set_text (name (_width));
456 ProcessorEntry::led_clicked(GdkEventButton *ev)
458 bool ctrl_shift_pressed = false;
459 Keyboard::ModifierMask ctrl_shift_mask = Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier);
461 if (Keyboard::modifier_state_equals (ev->state, ctrl_shift_mask)) {
462 ctrl_shift_pressed = true;
466 if (_button.get_active ()) {
467 if (ctrl_shift_pressed) {
468 _parent->all_visible_processors_active(false);
470 if (_position == Fader) {
471 _processor->enable (false);
475 _processor->enable (false);
479 if (ctrl_shift_pressed) {
480 _parent->all_visible_processors_active(true);
482 if (_position == Fader) {
483 _processor->enable (true);
487 _processor->enable (true);
494 ProcessorEntry::processor_active_changed ()
497 _button.set_active (_processor->enabled ());
502 ProcessorEntry::processor_property_changed (const PropertyChange& what_changed)
504 if (what_changed.contains (ARDOUR::Properties::name)) {
505 _button.set_text (name (_width));
511 ProcessorEntry::processor_configuration_changed (const ChanCount in, const ChanCount out)
513 _parent->setup_routing_feeds ();
514 input_icon.queue_draw();
515 output_icon.queue_draw();
516 routing_icon.queue_draw();
517 output_routing_icon.queue_draw();
521 ProcessorEntry::setup_tooltip ()
524 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
526 std::string postfix = "";
529 if (pi->plugin()->has_inline_display()) {
530 postfix += string_compose(_("\n%1+double-click to toggle inline-display"), Keyboard::tertiary_modifier_name ());
533 if ((replicated = pi->get_count()) > 1) {
534 postfix += string_compose(_("\nThis plugin has been replicated %1 times."), replicated);
537 if (pi->plugin()->has_editor()) {
538 set_tooltip (_button,
539 string_compose (_("<b>%1</b>\nDouble-click to show GUI.\n%2+double-click to show generic GUI.%3"), name (Wide), Keyboard::secondary_modifier_name (), postfix));
541 set_tooltip (_button,
542 string_compose (_("<b>%1</b>\nDouble-click to show generic GUI.%2"), name (Wide), postfix));
546 if(boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
547 ARDOUR_UI::instance()->set_tip (_button,
548 string_compose (_("<b>%1</b>\nThe Plugin is not available on this system\nand has been replaced by a stub."), name (Wide)));
551 boost::shared_ptr<Send> send;
552 if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
553 !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
554 if (send->remove_on_disconnect ()) {
555 set_tooltip (_button, string_compose ("<b>> %1</b>\nThis (sidechain) send will be removed when disconnected.", _processor->name()));
557 set_tooltip (_button, string_compose ("<b>> %1</b>", _processor->name()));
562 set_tooltip (_button, string_compose ("<b>%1</b>", name (Wide)));
566 ProcessorEntry::name (Width w) const
568 boost::shared_ptr<Send> send;
575 if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
576 !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
579 std::string send_name;
580 bool pretty_ok = true;
582 if (send->remove_on_disconnect ()) {
583 // assume it's a sidechain, find pretty name of connected port(s)
584 PortSet& ps (send->output ()->ports ());
585 for (PortSet::iterator i = ps.begin (); i != ps.end () && pretty_ok; ++i) {
586 vector<string> connections;
587 if (i->get_connections (connections)) {
588 vector<string>::const_iterator ci;
589 for (ci = connections.begin(); ci != connections.end(); ++ci) {
590 std::string pn = AudioEngine::instance()->get_pretty_name_by_name (*ci);
594 if (send_name.empty ()) {
596 } else if (send_name != pn) {
597 // pretty names don't match
610 /* grab the send name out of its overall name */
611 if (send_name.empty()) {
612 send_name = send->name();
613 string::size_type lbracket, rbracket;
614 lbracket = send_name.find ('[');
615 rbracket = send_name.find (']');
616 send_name = send_name.substr (lbracket+1, lbracket-rbracket-1);
621 name_display += send_name;
624 name_display += PBD::short_version (send_name, 5);
629 boost::shared_ptr<ARDOUR::PluginInsert> pi;
630 if ((pi = boost::dynamic_pointer_cast<ARDOUR::PluginInsert> (_processor)) != 0 && pi->get_count() > 1) {
633 name_display += "* ";
643 name_display += _processor->display_name();
646 name_display += PBD::short_version (_processor->display_name(), 5);
655 ProcessorEntry::show_all_controls ()
657 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
658 (*i)->set_visible (true);
661 _parent->update_gui_object_state (this);
665 ProcessorEntry::hide_all_controls ()
667 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
668 (*i)->set_visible (false);
671 _parent->update_gui_object_state (this);
675 ProcessorEntry::add_control_state (XMLNode* node) const
677 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
678 (*i)->add_state (node);
681 if (_plugin_display) {
682 XMLNode* c = new XMLNode (X_("Object"));
683 c->set_property (X_("id"), X_("InlineDisplay"));
684 c->set_property (X_("visible"), _plugin_display->is_visible ());
685 node->add_child_nocopy (*c);
690 ProcessorEntry::set_control_state (XMLNode const * node)
692 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
693 (*i)->set_state (node);
696 if (_plugin_display) {
697 XMLNode* n = GUIObjectState::get_node (node, X_("InlineDisplay"));
701 if (n->get_property (X_("visible"), visible)) {
703 _plugin_display->show ();
705 _plugin_display->hide ();
712 ProcessorEntry::state_id () const
714 return string_compose ("processor %1", _processor->id().to_s());
718 ProcessorEntry::hide_things ()
720 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
721 (*i)->hide_things ();
727 ProcessorEntry::build_controls_menu ()
729 using namespace Menu_Helpers;
731 if (!_plugin_display && _controls.empty ()) {
735 Menu* menu = manage (new Menu);
736 MenuList& items = menu->items ();
738 if (_plugin_display) {
739 items.push_back (CheckMenuElem (_("Inline Display")));
740 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
741 c->set_active (_plugin_display->is_visible ());
742 c->signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::toggle_inline_display_visibility));
745 if (_controls.empty ()) {
748 items.push_back (SeparatorElem ());
752 MenuElem (_("Show All Controls"), sigc::mem_fun (*this, &ProcessorEntry::show_all_controls))
756 MenuElem (_("Hide All Controls"), sigc::mem_fun (*this, &ProcessorEntry::hide_all_controls))
759 items.push_back (SeparatorElem ());
761 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
762 items.push_back (CheckMenuElemNoMnemonic ((*i)->name ()));
763 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
764 c->set_active ((*i)->visible ());
765 c->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &ProcessorEntry::toggle_control_visibility), *i));
772 ProcessorEntry::toggle_inline_display_visibility ()
774 if (_plugin_display->is_visible ()) {
775 _plugin_display->hide();
777 _plugin_display->show();
779 _parent->update_gui_object_state (this);
783 ProcessorEntry::toggle_control_visibility (Control* c)
785 c->set_visible (!c->visible ());
786 _parent->update_gui_object_state (this);
790 ProcessorEntry::build_send_options_menu ()
792 using namespace Menu_Helpers;
793 Menu* menu = manage (new Menu);
794 MenuList& items = menu->items ();
796 if (!ARDOUR::Profile->get_mixbus()) {
797 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (_processor);
799 items.push_back (CheckMenuElem (_("Link panner controls")));
800 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
801 c->set_active (send->panner_shell()->is_linked_to_route());
802 c->signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::toggle_panner_link));
806 boost::shared_ptr<InternalSend> aux = boost::dynamic_pointer_cast<InternalSend> (_processor);
808 items.push_back (CheckMenuElem (_("Allow Feedback Loop")));
809 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
810 c->set_active (aux->allow_feedback());
811 c->signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::toggle_allow_feedback));
817 ProcessorEntry::toggle_panner_link ()
819 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (_processor);
821 send->panner_shell()->set_linked_to_route(!send->panner_shell()->is_linked_to_route());
826 ProcessorEntry::toggle_allow_feedback ()
828 boost::shared_ptr<InternalSend> aux = boost::dynamic_pointer_cast<InternalSend> (_processor);
830 aux->set_allow_feedback (!aux->allow_feedback ());
834 ProcessorEntry::Control::Control (boost::shared_ptr<AutomationControl> c, string const & n)
836 , _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1)
837 , _slider (&_adjustment, boost::shared_ptr<PBD::Controllable>(), 0, max(13.f, rintf(13.f * UIConfiguration::instance().get_ui_scale())))
838 , _slider_persistant_tooltip (&_slider)
839 , _button (ArdourButton::led_default_elements)
840 , _ignore_ui_adjustment (false)
844 _slider.set_controllable (c);
845 box.set_padding(0, 0, 4, 4);
848 _button.set_text (_name);
849 _button.set_led_left (true);
850 _button.set_name ("processor control button");
854 _button.signal_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked));
855 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked_event));
856 c->Changed.connect (_connections, invalidator (*this), boost::bind (&Control::control_changed, this), gui_context ());
858 c->alist()->automation_state_changed.connect (_connections, invalidator (*this), boost::bind (&Control::control_automation_state_changed, this), gui_context());
859 control_automation_state_changed ();
864 _slider.set_name ("ProcessorControlSlider");
865 _slider.set_text (_name);
870 const ARDOUR::ParameterDescriptor& desc = c->desc();
871 double const lo = c->internal_to_interface (desc.lower);
872 double const up = c->internal_to_interface (desc.upper);
873 double const normal = c->internal_to_interface (desc.normal);
874 double const smallstep = c->internal_to_interface (desc.lower + desc.smallstep);
875 double const largestep = c->internal_to_interface (desc.lower + desc.largestep);
877 _adjustment.set_lower (lo);
878 _adjustment.set_upper (up);
879 _adjustment.set_step_increment (smallstep);
880 _adjustment.set_page_increment (largestep);
881 _slider.set_default_value (normal);
883 _slider.StartGesture.connect(sigc::mem_fun(*this, &Control::start_touch));
884 _slider.StopGesture.connect(sigc::mem_fun(*this, &Control::end_touch));
886 _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &Control::slider_adjusted));
887 c->Changed.connect (_connections, invalidator (*this), boost::bind (&Control::control_changed, this), gui_context ());
889 c->alist()->automation_state_changed.connect (_connections, invalidator (*this), boost::bind (&Control::control_automation_state_changed, this), gui_context());
890 control_automation_state_changed ();
897 /* We're providing our own PersistentTooltip */
898 set_no_tooltip_whatsoever (_slider);
901 ProcessorEntry::Control::~Control ()
906 ProcessorEntry::Control::set_tooltip ()
908 boost::shared_ptr<AutomationControl> c = _control.lock ();
913 std::string tt = _name + ": " + ARDOUR::value_as_string (c->desc(), c->get_value ());
914 string sm = Gtkmm2ext::markup_escape_text (tt);
915 _slider_persistant_tooltip.set_tip (sm);
916 ArdourWidgets::set_tooltip (_button, Gtkmm2ext::markup_escape_text (sm));
920 ProcessorEntry::Control::slider_adjusted ()
922 if (_ignore_ui_adjustment) {
926 boost::shared_ptr<AutomationControl> c = _control.lock ();
932 c->set_value ( c->interface_to_internal(_adjustment.get_value ()) , Controllable::NoGroup);
937 ProcessorEntry::Control::start_touch ()
939 boost::shared_ptr<AutomationControl> c = _control.lock ();
943 c->start_touch (c->session().transport_sample());
947 ProcessorEntry::Control::end_touch ()
949 boost::shared_ptr<AutomationControl> c = _control.lock ();
953 c->stop_touch (c->session().transport_sample());
957 ProcessorEntry::Control::button_clicked ()
959 boost::shared_ptr<AutomationControl> c = _control.lock ();
965 bool const n = _button.get_active ();
967 c->set_value (n ? 0 : 1, Controllable::NoGroup);
968 _button.set_active (!n);
973 ProcessorEntry::Control::button_clicked_event (GdkEventButton *ev)
981 ProcessorEntry::Control::control_automation_state_changed ()
983 boost::shared_ptr<AutomationControl> c = _control.lock ();
987 bool x = c->alist()->automation_state() & Play;
989 _button.set_sensitive (!x);
991 _slider.set_sensitive (!x);
996 ProcessorEntry::Control::control_changed ()
998 boost::shared_ptr<AutomationControl> c = _control.lock ();
1003 _ignore_ui_adjustment = true;
1005 if (c->toggled ()) {
1006 _button.set_active (c->get_value() > 0.5);
1008 // Note: the _slider watches the controllable by itself
1009 const double nval = c->internal_to_interface (c->get_value ());
1010 if (_adjustment.get_value() != nval) {
1011 _adjustment.set_value (nval);
1016 _ignore_ui_adjustment = false;
1020 ProcessorEntry::Control::add_state (XMLNode* node) const
1022 XMLNode* c = new XMLNode (X_("Object"));
1023 c->set_property (X_("id"), state_id ());
1024 c->set_property (X_("visible"), _visible);
1025 node->add_child_nocopy (*c);
1029 ProcessorEntry::Control::set_state (XMLNode const * node)
1031 XMLNode* n = GUIObjectState::get_node (node, state_id ());
1034 if (n->get_property (X_("visible"), visible)) {
1035 set_visible (visible);
1038 boost::shared_ptr<AutomationControl> c = _control.lock ();
1039 set_visible (c && (c->flags () & Controllable::InlineControl));
1044 ProcessorEntry::Control::set_visible (bool v)
1055 /** Called when the Editor might have re-shown things that
1059 ProcessorEntry::Control::hide_things ()
1067 ProcessorEntry::Control::state_id () const
1069 boost::shared_ptr<AutomationControl> c = _control.lock ();
1072 return string_compose (X_("control %1"), c->id().to_s ());
1075 PluginInsertProcessorEntry::PluginInsertProcessorEntry (ProcessorBox* b, boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
1076 : ProcessorEntry (b, p, w)
1077 , _plugin_insert (p)
1079 p->PluginIoReConfigure.connect (
1080 _iomap_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::iomap_changed, this), gui_context()
1082 p->PluginMapChanged.connect (
1083 _iomap_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::iomap_changed, this), gui_context()
1085 p->PluginConfigChanged.connect (
1086 _iomap_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::iomap_changed, this), gui_context()
1091 PluginInsertProcessorEntry::iomap_changed ()
1093 _parent->setup_routing_feeds ();
1094 routing_icon.queue_draw();
1095 output_routing_icon.queue_draw();
1099 PluginInsertProcessorEntry::hide_things ()
1101 ProcessorEntry::hide_things ();
1104 ProcessorEntry::PortIcon::PortIcon(bool input) {
1106 _ports = ARDOUR::ChanCount(ARDOUR::DataType::AUDIO, 1);
1107 set_size_request (-1, std::max (2.f, rintf(2.f * UIConfiguration::instance().get_ui_scale())));
1111 ProcessorEntry::PortIcon::on_expose_event (GdkEventExpose* ev)
1113 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
1115 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
1118 Gtk::Allocation a = get_allocation();
1119 double const width = a.get_width();
1120 double const height = a.get_height();
1122 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
1123 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
1125 cairo_rectangle (cr, 0, 0, width, height);
1128 const double dx = rint(max(2., 2. * UIConfiguration::instance().get_ui_scale()));
1129 for (uint32_t i = 0; i < _ports.n_total(); ++i) {
1130 set_routing_color (cr, i < _ports.n_midi());
1131 const double x = ProcessorEntry::RoutingIcon::pin_x_pos (i, width, _ports.n_total(), 0 , false);
1132 cairo_rectangle (cr, x - .5 - dx * .5, 0, 1 + dx, height);
1140 ProcessorEntry::RoutingIcon::RoutingIcon (bool input)
1144 set_terminal (false);
1148 ProcessorEntry::RoutingIcon::set_terminal (bool b) {
1150 int h = std::max (8.f, rintf(8.f * sqrt (UIConfiguration::instance().get_ui_scale())));
1152 h += std::max (4.f, rintf(4.f * sqrt (UIConfiguration::instance().get_ui_scale())));
1154 set_size_request (-1, h);
1158 ProcessorEntry::RoutingIcon::set (
1159 const ARDOUR::ChanCount& in,
1160 const ARDOUR::ChanCount& out,
1161 const ARDOUR::ChanCount& sinks,
1162 const ARDOUR::ChanCount& sources,
1163 const ARDOUR::ChanMapping& in_map,
1164 const ARDOUR::ChanMapping& out_map,
1165 const ARDOUR::ChanMapping& thru_map)
1173 _thru_map = thru_map;
1177 ProcessorEntry::RoutingIcon::in_identity () const {
1178 if (_thru_map.n_total () > 0) {
1181 if (!_in_map.is_monotonic () || !_in_map.is_identity ()) {
1184 if (_in_map.n_total () != _sinks.n_total () || _in.n_total () != _sinks.n_total ()) {
1191 ProcessorEntry::RoutingIcon::out_identity () const {
1192 if (_thru_map.n_total () > 0) {
1193 // TODO skip if trhu is not connected to any of next's inputs
1196 if (!_out_map.is_monotonic () || !_out_map.is_identity ()) {
1199 if (_out_map.n_total () != _sources.n_total () || _out.n_total () != _sources.n_total ()) {
1206 ProcessorEntry::RoutingIcon::can_coalesce () const {
1207 if (_thru_map.n_total () > 0) {
1210 if (_fed_by && _f_out != _f_sources) {
1213 if (_fed_by && !_f_out_map.is_identity () && !_in_map.is_identity ()) {
1216 if (_input && _sinks == _in && (!_fed_by || _f_out == _in)) {
1223 ProcessorEntry::RoutingIcon::set_fed_by (
1224 const ARDOUR::ChanCount& out,
1225 const ARDOUR::ChanCount& sources,
1226 const ARDOUR::ChanMapping& out_map,
1227 const ARDOUR::ChanMapping& thru_map)
1230 _f_sources = sources;
1231 _f_out_map = out_map;
1232 _f_thru_map = thru_map;
1237 ProcessorEntry::RoutingIcon::set_feeding (
1238 const ARDOUR::ChanCount& in,
1239 const ARDOUR::ChanCount& sinks,
1240 const ARDOUR::ChanMapping& in_map,
1241 const ARDOUR::ChanMapping& thru_map)
1246 _i_thru_map = thru_map;
1251 ProcessorEntry::RoutingIcon::pin_x_pos (uint32_t i, double width, uint32_t n_total, uint32_t n_midi, bool midi)
1253 if (!midi) { i += n_midi; }
1256 return rint (width * .5) +.5;
1258 return rint (width * (.15 + .7 * i / (n_total - 1))) + .5;
1262 ProcessorEntry::RoutingIcon::draw_gnd (cairo_t* cr, double x0, double y0, double height, bool midi)
1264 const double dx = 1 + rint (max(2., 2. * UIConfiguration::instance().get_ui_scale()));
1265 const double y1 = rint (height * .66) + .5;
1268 cairo_translate (cr, x0, y0);
1269 cairo_move_to (cr, 0, height);
1270 cairo_line_to (cr, 0, y1);
1271 cairo_move_to (cr, 0 - dx, y1);
1272 cairo_line_to (cr, 0 + dx, y1);
1274 set_routing_color (cr, midi);
1275 cairo_set_line_width (cr, 1.0);
1281 ProcessorEntry::RoutingIcon::draw_sidechain (cairo_t* cr, double x0, double y0, double height, bool midi)
1283 const double dx = 1 + rint (max(2., 2. * UIConfiguration::instance().get_ui_scale()));
1284 const double y1 = rint (height * .5) - .5;
1287 cairo_translate (cr, x0, y0);
1288 cairo_move_to (cr, 0 - dx, height);
1289 cairo_line_to (cr, 0, y1);
1290 cairo_line_to (cr, 0 + dx, height);
1291 cairo_close_path (cr);
1293 set_routing_color (cr, midi);
1299 ProcessorEntry::RoutingIcon::draw_thru_src (cairo_t* cr, double x0, double y0, double height, bool midi)
1301 const double rad = 1;
1302 const double y1 = height - rad - 1.5;
1304 cairo_arc (cr, x0, y0 + y1, rad, 0, 2. * M_PI);
1305 cairo_move_to (cr, x0, y0 + height - 1.5);
1306 cairo_line_to (cr, x0, y0 + height);
1307 set_routing_color (cr, midi);
1308 cairo_set_line_width (cr, 1.0);
1313 ProcessorEntry::RoutingIcon::draw_thru_sink (cairo_t* cr, double x0, double y0, double height, bool midi)
1315 const double rad = 1;
1316 const double y1 = rad + 1;
1318 cairo_arc (cr, x0, y0 + y1, rad, 0, 2. * M_PI);
1319 cairo_move_to (cr, x0, y0);
1320 cairo_line_to (cr, x0, y0 + 1);
1321 set_routing_color (cr, midi);
1322 cairo_set_line_width (cr, 1.0);
1327 ProcessorEntry::RoutingIcon::draw_connection (cairo_t* cr, double x0, double x1, double y0, double y1, bool midi, bool dashed)
1329 double bz = abs (y1 - y0);
1331 cairo_move_to (cr, x0, y0);
1332 cairo_curve_to (cr, x0, y0 + bz, x1, y1 - bz, x1, y1);
1333 cairo_set_line_width (cr, 1.0);
1334 cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
1335 cairo_set_source_rgb (cr, 1, 0, 0);
1337 const double dashes[] = { 2, 3 };
1338 cairo_set_dash (cr, dashes, 2, 0);
1340 set_routing_color (cr, midi);
1343 cairo_set_dash (cr, 0, 0, 0);
1348 ProcessorEntry::RoutingIcon::on_expose_event (GdkEventExpose* ev)
1350 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
1352 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
1355 cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
1357 Gtk::Allocation a = get_allocation();
1358 double const width = a.get_width();
1359 double const height = a.get_height();
1361 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
1362 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
1364 cairo_rectangle (cr, 0, 0, width, height);
1368 if (can_coalesce ()) {
1369 expose_coalesced_input_map (cr, width, height);
1371 expose_input_map (cr, width, height);
1374 expose_output_map (cr, width, height);
1382 ProcessorEntry::RoutingIcon::expose_coalesced_input_map (cairo_t* cr, const double width, const double height)
1384 const uint32_t pc_in = _sinks.n_total();
1385 const uint32_t pc_in_midi = _sinks.n_midi();
1387 for (uint32_t i = 0; i < pc_in; ++i) {
1388 const bool is_midi = i < pc_in_midi;
1390 uint32_t pn = is_midi ? i : i - pc_in_midi;
1391 DataType dt = is_midi ? DataType::MIDI : DataType::AUDIO;
1392 uint32_t idx = _in_map.get (dt, pn, &valid_in);
1394 double x = pin_x_pos (i, width, pc_in, 0, is_midi);
1395 draw_gnd (cr, x, 0, height, is_midi);
1398 if (idx >= _in.get (dt)) {
1399 // side-chain, probably
1400 double x = pin_x_pos (i, width, pc_in, 0, is_midi);
1401 draw_sidechain (cr, x, 0, height, is_midi);
1405 double c_x1 = pin_x_pos (i, width, pc_in, 0, false);
1409 uint32_t src = _f_out_map.get_src (dt, idx, &valid_src);
1411 double x = pin_x_pos (i, width, pc_in, 0, false);
1413 _f_thru_map.get (dt, idx, &valid_thru);
1415 draw_thru_src (cr, x, 0, height, is_midi);
1417 draw_gnd (cr, x, 0, height, is_midi);
1421 c_x0 = pin_x_pos (src, width, _f_sources.n_total(), _f_sources.n_midi(), is_midi);
1423 c_x0 = pin_x_pos (idx, width, _in.n_total(), _in.n_midi(), is_midi);
1425 draw_connection (cr, c_x0, c_x1, 0, height, is_midi);
1430 ProcessorEntry::RoutingIcon::expose_input_map (cairo_t* cr, const double width, const double height)
1432 const uint32_t n_in = _in.n_total();
1433 const uint32_t n_in_midi = _in.n_midi();
1434 const uint32_t pc_in = _sinks.n_total();
1435 const uint32_t pc_in_midi = _sinks.n_midi();
1437 // draw inputs to this
1438 for (uint32_t i = 0; i < pc_in; ++i) {
1439 const bool is_midi = i < pc_in_midi;
1441 uint32_t pn = is_midi ? i : i - pc_in_midi;
1442 DataType dt = is_midi ? DataType::MIDI : DataType::AUDIO;
1443 uint32_t idx = _in_map.get (dt, pn, &valid_in);
1444 // check if it's fed
1445 bool valid_src = true;
1446 if (valid_in && idx < _in.get (dt) && _fed_by) {
1449 _f_out_map.get_src (dt, idx, &valid_out);
1450 _f_thru_map.get (dt, idx, &valid_thru);
1451 if (!valid_out && !valid_thru) {
1455 if (!valid_in || !valid_src) {
1456 double x = pin_x_pos (i, width, pc_in, 0, is_midi);
1457 draw_gnd (cr, x, 0, height, is_midi);
1460 if (idx >= _in.get (dt)) {
1461 // side-chain, probably
1462 double x = pin_x_pos (i, width, pc_in, 0, is_midi);
1463 draw_sidechain (cr, x, 0, height, is_midi);
1466 double c_x1 = pin_x_pos (i, width, pc_in, 0, false);
1467 double c_x0 = pin_x_pos (idx, width, n_in, n_in_midi, is_midi);
1468 draw_connection (cr, c_x0, c_x1, 0, height, is_midi);
1471 // draw reverse thru
1472 for (uint32_t i = 0; i < n_in; ++i) {
1473 const bool is_midi = i < n_in_midi;
1475 uint32_t pn = is_midi ? i : i - n_in_midi;
1476 DataType dt = is_midi ? DataType::MIDI : DataType::AUDIO;
1477 _thru_map.get_src (dt, pn, &valid_thru);
1481 double x = pin_x_pos (i, width, n_in, 0, is_midi);
1482 draw_thru_sink (cr, x, 0, height, is_midi);
1487 ProcessorEntry::RoutingIcon::expose_output_map (cairo_t* cr, const double width, const double height)
1489 int dh = std::max (4.f, rintf(4.f * UIConfiguration::instance().get_ui_scale()));
1490 double ht = _terminal ? height - dh : height;
1492 // draw outputs of this
1493 const uint32_t pc_out = _sources.n_total();
1494 const uint32_t pc_out_midi = _sources.n_midi();
1495 const uint32_t n_out = _out.n_total();
1496 const uint32_t n_out_midi = _out.n_midi();
1498 for (uint32_t i = 0; i < pc_out; ++i) {
1499 const bool is_midi = i < pc_out_midi;
1501 uint32_t pn = is_midi ? i : i - pc_out_midi;
1502 DataType dt = is_midi ? DataType::MIDI : DataType::AUDIO;
1503 uint32_t idx = _out_map.get (dt, pn, &valid_out);
1507 // skip connections that are not used in the next's input
1509 bool valid_thru, valid_sink;
1510 _i_in_map.get_src (dt, idx, &valid_sink);
1511 _i_thru_map.get_src (dt, idx, &valid_thru);
1512 if (!valid_thru && !valid_sink) {
1513 if (!is_midi || i != 0) { // special case midi-bypass
1518 double c_x0 = pin_x_pos (i, width, pc_out, 0, false);
1519 double c_x1 = pin_x_pos (idx, width, n_out, n_out_midi, is_midi);
1520 draw_connection (cr, c_x0, c_x1, 0, ht, is_midi);
1523 for (uint32_t i = 0; i < n_out; ++i) {
1524 const bool is_midi = i < n_out_midi;
1525 uint32_t pn = is_midi ? i : i - n_out_midi;
1526 DataType dt = is_midi ? DataType::MIDI : DataType::AUDIO;
1527 double x = pin_x_pos (i, width, n_out, 0, is_midi);
1530 bool valid_thru_f = false;
1531 // skip connections that are not used in the next's input
1534 _i_in_map.get_src (dt, pn, &valid_sink);
1535 _i_thru_map.get_src (dt, pn, &valid_thru_f);
1536 if (!valid_thru_f && !valid_sink) {
1537 if (!is_midi || i != 0) { // special case midi-bypass
1544 _out_map.get_src (dt, pn, &valid_src);
1547 uint32_t idx = _thru_map.get (dt, pn, &valid_thru);
1549 if (idx >= _in.get (dt)) {
1550 draw_sidechain (cr, x, 0, height, is_midi);
1552 draw_thru_src (cr, x, 0, height, is_midi);
1554 } else if (valid_thru_f){
1555 // gnd is part of input, unless it's a thru input
1556 // (also only true if !coalesced into one small display)
1557 draw_gnd (cr, x, 0, height, is_midi);
1561 // terminal node, add arrows
1563 _out_map.get_src (dt, pn, &valid_src);
1566 uint32_t idx = _thru_map.get (dt, pn, &valid_thru);
1568 if (idx >= _in.get (dt)) {
1569 draw_sidechain (cr, x, 0, height - dh, is_midi);
1571 draw_thru_src (cr, x, 0, height - dh, is_midi);
1574 draw_gnd (cr, x, 0, height - dh, is_midi);
1578 set_routing_color (cr, is_midi);
1579 cairo_set_line_width (cr, 1.0);
1580 cairo_move_to (cr, x, height - dh);
1581 cairo_line_to (cr, x, height - 2);
1584 const double ar = dh - 1;
1585 cairo_move_to (cr, x - ar, height - ar);
1586 cairo_line_to (cr, x , height - .5);
1587 cairo_line_to (cr, x + ar, height - ar);
1588 cairo_line_to (cr, x , height - ar * .5);
1589 cairo_close_path (cr);
1590 cairo_fill_preserve (cr);
1596 ProcessorEntry::PluginInlineDisplay::PluginInlineDisplay (ProcessorEntry& e, boost::shared_ptr<ARDOUR::Plugin> p, uint32_t max_height)
1597 : PluginDisplay (p, max_height)
1600 , _given_max_height (max_height)
1602 std::string postfix = string_compose(_("\n%1+double-click to toggle inline-display"), Keyboard::tertiary_modifier_name ());
1604 if (_plug->has_editor()) {
1606 string_compose (_("<b>%1</b>\nDouble-click to show GUI.\n%2+double-click to show generic GUI.%3"), e.name (Wide), Keyboard::primary_modifier_name (), postfix));
1609 string_compose (_("<b>%1</b>\nDouble-click to show generic GUI.%2"), e.name (Wide), postfix));
1615 ProcessorEntry::PluginInlineDisplay::on_button_press_event (GdkEventButton *ev)
1617 assert (_entry.processor ());
1619 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_entry.processor());
1620 // duplicated code :(
1621 // consider some tweaks to pass this up to the DnDVBox somehow:
1622 // select processor, then call (private)
1623 //_entry._parent->processor_button_press_event (ev, &_entry);
1624 if (pi && pi->plugin() && pi->plugin()->has_inline_display()
1625 && Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)
1627 && ev->type == GDK_2BUTTON_PRESS) {
1628 _entry.toggle_inline_display_visibility ();
1631 else if (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS)) {
1632 if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
1633 _entry._parent->generic_edit_processor (_entry.processor ());
1635 _entry._parent->edit_processor (_entry.processor ());
1643 ProcessorEntry::PluginInlineDisplay::on_size_request (Requisition* req)
1646 req->height = _cur_height;
1651 ProcessorEntry::PluginInlineDisplay::update_height_alloc (uint32_t inline_height)
1653 /* work-around scroll-bar + aspect ratio
1654 * show inline-view -> height changes -> scrollbar gets added
1655 * -> width changes -> inline-view, fixed aspect ratio -> height changes
1656 * -> scroll bar is removed [-> width changes ; repeat ]
1658 uint32_t shm = std::min (_max_height, inline_height);
1660 Gtk::Container* pr = get_parent();
1661 for (uint32_t i = 0; i < 4 && pr; ++i) {
1662 // VBox, EventBox, ViewPort, ScrolledWindow
1663 pr = pr->get_parent();
1665 Gtk::ScrolledWindow* sw = dynamic_cast<Gtk::ScrolledWindow*> (pr);
1667 const Gtk::VScrollbar* vsb = sw->get_vscrollbar();
1668 sc = vsb && vsb->is_visible();
1671 if (shm != _cur_height) {
1673 if (!_scroll && sc) {
1676 _max_height = _given_max_height;
1685 ProcessorEntry::PluginInlineDisplay::display_frame (cairo_t* cr, double w, double h)
1687 Gtkmm2ext::rounded_rectangle (cr, .5, -1.5, w - 1, h + 1, 7);
1690 ProcessorEntry::LuaPluginDisplay::LuaPluginDisplay (ProcessorEntry& e, boost::shared_ptr<ARDOUR::LuaProc> p, uint32_t max_height)
1691 : PluginInlineDisplay (e, p, max_height)
1693 , _lua_render_inline (0)
1695 p->setup_lua_inline_gui (&lua_gui);
1697 lua_State* LG = lua_gui.getState ();
1698 LuaInstance::bind_cairo (LG);
1699 luabridge::LuaRef lua_render = luabridge::getGlobal (LG, "render_inline");
1700 assert (lua_render.isFunction ());
1701 _lua_render_inline = new luabridge::LuaRef (lua_render);
1704 ProcessorEntry::LuaPluginDisplay::~LuaPluginDisplay ()
1706 delete (_lua_render_inline);
1710 ProcessorEntry::LuaPluginDisplay::render_inline (cairo_t *cr, uint32_t width)
1712 Cairo::Context ctx (cr);
1714 luabridge::LuaRef rv = (*_lua_render_inline)((Cairo::Context *)&ctx, width, _max_height);
1715 lua_gui.collect_garbage_step ();
1716 if (rv.isTable ()) {
1720 } catch (luabridge::LuaException const& e) {
1722 cerr << "LuaException:" << e.what () << endl;
1729 static std::list<Gtk::TargetEntry> drop_targets()
1731 std::list<Gtk::TargetEntry> tmp;
1732 tmp.push_back (Gtk::TargetEntry ("processor")); // from processor-box to processor-box
1733 tmp.push_back (Gtk::TargetEntry ("PluginInfoPtr")); // from plugin-manager
1734 tmp.push_back (Gtk::TargetEntry ("PluginFavoritePtr")); // from sidebar
1738 static std::list<Gtk::TargetEntry> drag_targets()
1740 std::list<Gtk::TargetEntry> tmp;
1741 tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr")); // to sidebar (optional preset)
1742 tmp.push_back (Gtk::TargetEntry ("processor")); // to processor-box (copy)
1746 static std::list<Gtk::TargetEntry> drag_targets_noplugin()
1748 std::list<Gtk::TargetEntry> tmp;
1749 tmp.push_back (Gtk::TargetEntry ("processor")); // to processor box (sends, faders re-order)
1753 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
1754 ProcessorSelection& psel, MixerStrip* parent, bool owner_is_mixer)
1755 : _parent_strip (parent)
1756 , _owner_is_mixer (owner_is_mixer)
1757 , ab_direction (true)
1758 , _get_plugin_selector (get_plugin_selector)
1760 , _p_selection(psel)
1761 , processor_display (drop_targets())
1762 , _redisplay_pending (false)
1766 /* ProcessorBox actions and bindings created statically by call to
1767 * ProcessorBox::register_actions(), made by ARDOUR_UI so that actions
1768 * are available for context menus.
1771 processor_display.set_data ("ardour-bindings", bindings);
1775 no_processor_redisplay = false;
1777 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
1778 processor_scroller.add (processor_display);
1779 pack_start (processor_scroller, true, true);
1781 processor_display.set_flags (CAN_FOCUS);
1782 processor_display.set_name ("ProcessorList");
1783 processor_display.set_data ("processorbox", this);
1784 processor_display.set_size_request (48, -1);
1785 processor_display.set_spacing (0);
1787 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
1788 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
1790 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
1791 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
1793 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
1794 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
1795 processor_display.DropFromExternal.connect (sigc::mem_fun (*this, &ProcessorBox::plugin_drop));
1797 processor_scroller.show ();
1798 processor_display.show ();
1801 parent->DeliveryChanged.connect (
1802 _mixer_strip_connections, invalidator (*this), boost::bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
1806 set_tooltip (processor_display, _("Right-click to add/remove/edit\nplugins,inserts,sends and more"));
1809 ProcessorBox::~ProcessorBox ()
1811 /* it may appear as if we should delete processor_menu but that is a
1812 * pointer to a widget owned by the UI Manager, and has potentially
1813 * be returned to many other ProcessorBoxes. GTK doesn't really make
1814 * clear the ownership of this widget, which is a menu and thus is
1815 * never packed into any container other than an implict GtkWindow.
1817 * For now, until or if we ever get clarification over the ownership
1818 * story just let it continue to exist. At worst, its a small memory leak.
1823 ProcessorBox::set_route (boost::shared_ptr<Route> r)
1829 _route_connections.drop_connections();
1831 /* new route: any existing block on processor redisplay must be meaningless */
1832 no_processor_redisplay = false;
1835 _route->processors_changed.connect (
1836 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
1839 _route->DropReferences.connect (
1840 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
1843 _route->PropertyChanged.connect (
1844 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
1847 redisplay_processors ();
1851 ProcessorBox::route_going_away ()
1853 no_processor_redisplay = true;
1854 processor_display.clear ();
1858 boost::shared_ptr<Processor>
1859 ProcessorBox::find_drop_position (ProcessorEntry* position)
1861 boost::shared_ptr<Processor> p;
1863 p = position->processor ();
1865 /* dropped on the blank entry (which will be before the
1866 fader), so use the first non-blank child as our
1867 `dropped on' processor */
1868 list<ProcessorEntry*> c = processor_display.children ();
1869 list<ProcessorEntry*>::iterator i = c.begin ();
1871 assert (i != c.end ());
1872 p = (*i)->processor ();
1880 ProcessorBox::_drop_plugin_preset (Gtk::SelectionData const &data, Route::ProcessorList &pl)
1882 const void * d = data.get_data();
1883 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
1885 PluginPresetList nfos;
1887 tv->get_object_drag_data (nfos, &source);
1889 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1890 PluginPresetPtr ppp = (*i);
1891 PluginInfoPtr pip = ppp->_pip;
1892 PluginPtr p = pip->load (*_session);
1897 if (ppp->_preset.valid) {
1898 p->load_preset (ppp->_preset);
1901 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
1902 if (Config->get_new_plugins_active ()) {
1903 processor->enable (true);
1905 pl.push_back (processor);
1910 ProcessorBox::_drop_plugin (Gtk::SelectionData const &data, Route::ProcessorList &pl)
1912 const void * d = data.get_data();
1913 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>*>(d);
1914 PluginInfoList nfos;
1917 tv->get_object_drag_data (nfos, &source);
1919 for (list<PluginInfoPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1920 PluginPtr p = (*i)->load (*_session);
1924 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
1925 if (Config->get_new_plugins_active ()) {
1926 processor->enable (true);
1928 pl.push_back (processor);
1933 ProcessorBox::plugin_drop (Gtk::SelectionData const &data, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
1939 boost::shared_ptr<Processor> p = find_drop_position (position);
1940 Route::ProcessorList pl;
1942 if (data.get_target() == "PluginInfoPtr") {
1943 _drop_plugin (data, pl);
1945 else if (data.get_target() == "PluginFavoritePtr") {
1946 _drop_plugin_preset (data, pl);
1952 Route::ProcessorStreams err;
1953 if (_route->add_processors (pl, p, &err)) {
1955 "Processor Drag/Drop failed. Probably because\n\
1956 the I/O configuration of the plugins could\n\
1957 not match the configuration of this track.");
1958 MessageDialog am (msg);
1964 ProcessorBox::object_drop (DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
1966 if (Gdk::ACTION_LINK == context->get_selected_action()) {
1967 list<ProcessorEntry*> children = source->selection ();
1968 assert (children.size() == 1);
1969 ProcessorEntry* other = *children.begin();
1970 assert (other->can_copy_state (position));
1971 boost::shared_ptr<ARDOUR::Processor> otherproc = other->processor();
1972 boost::shared_ptr<ARDOUR::Processor> proc = position->processor();
1973 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (proc);
1974 assert (otherproc && proc && pi);
1976 PBD::ID id = pi->id();
1977 XMLNode& state = otherproc->get_state ();
1978 /* strip side-chain state (processor inside processor must be a side-chain)
1979 * otherwise we'll end up with duplicate ports-names.
1980 * (this needs a better solution which retains connections)
1982 state.remove_nodes_and_delete ("Processor");
1983 proc->set_state (state, Stateful::loading_state_version);
1984 boost::dynamic_pointer_cast<PluginInsert>(proc)->update_id (id);
1988 boost::shared_ptr<Processor> p = find_drop_position (position);
1990 list<ProcessorEntry*> children = source->selection (true);
1991 list<boost::shared_ptr<Processor> > procs;
1992 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
1993 if ((*i)->processor ()) {
1994 if (boost::dynamic_pointer_cast<UnknownProcessor> ((*i)->processor())) {
1997 if (boost::dynamic_pointer_cast<PortInsert> ((*i)->processor())) {
2000 procs.push_back ((*i)->processor ());
2004 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
2005 XMLNode& state = (*i)->get_state ();
2007 nlist.push_back (&state);
2008 paste_processor_state (nlist, p);
2012 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
2016 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
2017 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
2019 other->delete_dragged_processors (procs);
2025 ProcessorBox::set_width (Width w)
2033 list<ProcessorEntry*> children = processor_display.children ();
2034 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2035 (*i)->set_enum_width (w);
2042 ProcessorBox::build_possible_aux_menu ()
2044 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
2047 /* No aux sends if there are no busses */
2051 if (_route->is_monitor () || _route->is_foldbackbus ()) {
2055 using namespace Menu_Helpers;
2056 Menu* menu = manage (new Menu);
2057 MenuList& items = menu->items();
2059 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
2060 if ((*r)->is_master() || (*r)->is_monitor () || *r == _route) {
2061 /* don't allow sending to master or monitor or to self */
2064 if ((*r)->is_foldbackbus ()) {
2067 if (_route->internal_send_for (*r)) {
2068 /* aux-send to target already exists */
2071 items.push_back (MenuElemNoMnemonic ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
2078 ProcessorBox::build_possible_listener_menu ()
2080 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
2083 /* No aux sends if there are no busses */
2087 if (_route->is_monitor () || _route->is_foldbackbus ()) {
2091 using namespace Menu_Helpers;
2092 Menu* menu = manage (new Menu);
2093 MenuList& items = menu->items();
2095 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
2096 if ((*r)->is_master() || (*r)->is_monitor () || *r == _route) {
2097 /* don't allow sending to master or monitor or to self */
2100 if (!(*r)->is_foldbackbus ()) {
2103 if (_route->internal_send_for (*r)) {
2104 /* aux-send to target already exists */
2107 items.push_back (MenuElemNoMnemonic ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
2114 ProcessorBox::build_possible_remove_listener_menu ()
2116 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
2119 /* No aux sends if there are no busses */
2123 if (_route->is_monitor () || _route->is_foldbackbus ()) {
2127 using namespace Menu_Helpers;
2128 Menu* menu = manage (new Menu);
2129 MenuList& items = menu->items();
2131 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
2132 if ((*r)->is_master() || (*r)->is_monitor () || *r == _route) {
2133 /* don't allow sending to master or monitor or to self */
2136 if (!(*r)->is_foldbackbus ()) {
2139 if (!_route->internal_send_for (*r)) {
2140 /* aux-send to target already exists */
2143 items.push_back (MenuElemNoMnemonic ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_remove_aux), boost::weak_ptr<Route>(*r))));
2150 ProcessorBox::show_processor_menu (int arg)
2152 if (processor_menu == 0) {
2153 processor_menu = build_processor_menu ();
2154 processor_menu->signal_unmap().connect (sigc::mem_fun (*this, &ProcessorBox::processor_menu_unmapped));
2157 /* Sort out the plugin submenu */
2159 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newplugin"));
2161 if (plugin_menu_item) {
2162 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
2165 /* And the aux submenu */
2167 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newaux"));
2169 if (aux_menu_item) {
2170 Menu* m = build_possible_aux_menu();
2171 if (m && !m->items().empty()) {
2172 aux_menu_item->set_submenu (*m);
2173 aux_menu_item->set_sensitive (true);
2176 /* stupid gtkmm: we need to pass a null reference here */
2177 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
2178 aux_menu_item->set_sensitive (false);
2182 Gtk::MenuItem* listen_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newlisten"));
2184 if (listen_menu_item) {
2185 Menu* m = build_possible_listener_menu();
2186 if (m && !m->items().empty()) {
2187 listen_menu_item->set_submenu (*m);
2188 listen_menu_item->set_sensitive (true);
2191 /* stupid gtkmm: we need to pass a null reference here */
2192 gtk_menu_item_set_submenu (listen_menu_item->gobj(), 0);
2193 listen_menu_item->set_sensitive (false);
2197 Gtk::MenuItem* remove_listen_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/removelisten"));
2199 if (remove_listen_menu_item) {
2200 Menu* m = build_possible_remove_listener_menu();
2201 if (m && !m->items().empty()) {
2202 remove_listen_menu_item->set_submenu (*m);
2203 remove_listen_menu_item->set_sensitive (true);
2206 /* stupid gtkmm: we need to pass a null reference here */
2207 gtk_menu_item_set_submenu (remove_listen_menu_item->gobj(), 0);
2208 remove_listen_menu_item->set_sensitive (false);
2212 ActionManager::get_action (X_("ProcessorMenu"), "newinsert")->set_sensitive (!_route->is_monitor () && !_route->is_foldbackbus ());
2213 ActionManager::get_action (X_("ProcessorMenu"), "newsend")->set_sensitive (!_route->is_monitor () && !_route->is_foldbackbus ());
2215 ProcessorEntry* single_selection = 0;
2216 if (processor_display.selection().size() == 1) {
2217 single_selection = processor_display.selection().front();
2220 /* And the controls submenu */
2222 Gtk::MenuItem* controls_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/controls"));
2224 if (controls_menu_item) {
2225 if (single_selection) {
2226 Menu* m = single_selection->build_controls_menu ();
2227 if (m && !m->items().empty()) {
2228 controls_menu_item->set_submenu (*m);
2229 controls_menu_item->set_sensitive (true);
2232 gtk_menu_item_set_submenu (controls_menu_item->gobj(), 0);
2233 controls_menu_item->set_sensitive (false);
2236 controls_menu_item->set_sensitive (false);
2241 Gtk::MenuItem* send_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/send_options"));
2242 if (send_menu_item) {
2243 if (single_selection && !_route->is_monitor()) {
2244 Menu* m = single_selection->build_send_options_menu ();
2245 if (m && !m->items().empty()) {
2246 send_menu_item->set_submenu (*m);
2247 send_menu_item->set_sensitive (true);
2250 gtk_menu_item_set_submenu (send_menu_item->gobj(), 0);
2251 send_menu_item->set_sensitive (false);
2254 send_menu_item->set_sensitive (false);
2258 /* Sensitise actions as approprioate */
2260 const bool sensitive = !processor_display.selection().empty() && ! stub_processor_selected ();
2262 paste_action->set_sensitive (!_p_selection.processors.empty());
2263 cut_action->set_sensitive (sensitive && can_cut ());
2264 copy_action->set_sensitive (sensitive);
2265 delete_action->set_sensitive (sensitive || stub_processor_selected ());
2266 backspace_action->set_sensitive (sensitive || stub_processor_selected ());
2268 edit_action->set_sensitive (one_processor_can_be_edited ());
2269 edit_generic_action->set_sensitive (one_processor_can_be_edited ());
2271 boost::shared_ptr<PluginInsert> pi;
2272 if (single_selection) {
2273 pi = boost::dynamic_pointer_cast<PluginInsert> (single_selection->processor ());
2276 manage_pins_action->set_sensitive (pi != 0);
2277 if (boost::dynamic_pointer_cast<Track>(_route)) {
2278 disk_io_action->set_sensitive (true);
2280 disk_io_action->set_sensitive (false);
2283 /* allow editing with an Ardour-generated UI for plugin inserts with editors */
2284 edit_action->set_sensitive (pi && pi->plugin()->has_editor ());
2286 /* disallow rename for multiple selections, for plugin inserts and for the fader */
2287 rename_action->set_sensitive (single_selection
2289 && !boost::dynamic_pointer_cast<Amp> (single_selection->processor ())
2290 && !boost::dynamic_pointer_cast<UnknownProcessor> (single_selection->processor ()));
2292 processor_menu->popup (1, arg);
2294 /* Add a placeholder gap to the processor list to indicate where a processor would be
2295 inserted were one chosen from the menu.
2298 processor_display.get_pointer (x, y);
2299 _placement = processor_display.add_placeholder (y);
2303 ProcessorBox::enter_notify (GdkEventCrossing*)
2305 processor_display.grab_focus ();
2306 _current_processor_box = this;
2311 ProcessorBox::leave_notify (GdkEventCrossing* ev)
2313 if (ev->detail == GDK_NOTIFY_INFERIOR) {
2317 Widget* top = get_toplevel();
2319 if (top->is_toplevel()) {
2320 Window* win = dynamic_cast<Window*> (top);
2321 gtk_window_set_focus (win->gobj(), 0);
2328 ProcessorBox::processor_operation (ProcessorOperation op)
2330 ProcSelection targets;
2332 get_selected_processors (targets);
2334 /* if (targets.empty()) {
2337 processor_display.get_pointer (x, y);
2339 pair<ProcessorEntry *, double> const pointer = processor_display.get_child_at_position (y);
2341 if (pointer.first && pointer.first->processor()) {
2342 targets.push_back (pointer.first->processor ());
2347 if ((op == ProcessorsDelete) && targets.empty()) {
2348 return false; //nothing to delete. return false so the editor-mixer, because the user was probably intending to delete something in the editor
2352 case ProcessorsSelectAll:
2353 processor_display.select_all ();
2356 case ProcessorsSelectNone:
2357 processor_display.select_none ();
2360 case ProcessorsCopy:
2361 copy_processors (targets);
2365 cut_processors (targets);
2368 case ProcessorsPaste:
2369 // some processors are not selectable (e.g fader, meter), target is empty.
2370 if (targets.empty() && _placement >= 0) {
2372 boost::shared_ptr<Processor> proc = _route->before_processor_for_index (_placement);
2374 targets.push_back (proc);
2377 if (targets.empty()) {
2378 paste_processors ();
2380 paste_processors (targets.front());
2384 case ProcessorsDelete:
2385 delete_processors (targets);
2388 case ProcessorsToggleActive:
2389 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
2390 if (!(*i)->display_to_user ()) {
2391 assert (0); // these should not be selectable to begin with.
2394 if (!boost::dynamic_pointer_cast<PluginInsert> (*i)) {
2398 if (boost::dynamic_pointer_cast<PluginInsert> (*i)->is_channelstrip()) {
2402 (*i)->enable (!(*i)->enabled ());
2417 ProcessorWindowProxy*
2418 ProcessorBox::find_window_proxy (boost::shared_ptr<Processor> processor) const
2420 return processor->window_proxy();
2425 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
2427 boost::shared_ptr<Processor> processor;
2429 processor = child->processor ();
2433 bool selected = processor_display.selected (child);
2435 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (processor);
2436 if (pi && pi->plugin() && pi->plugin()->has_inline_display()
2437 && Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)
2439 && ev->type == GDK_2BUTTON_PRESS) {
2440 child->toggle_inline_display_visibility ();
2444 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
2446 if (!one_processor_can_be_edited ()) {
2449 if (!ARDOUR_UI_UTILS::engine_is_running ()) {
2453 if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
2454 generic_edit_processor (processor);
2456 edit_processor (processor);
2461 } else if (Keyboard::is_context_menu_event (ev)) {
2463 show_processor_menu (ev->time);
2467 } else if (processor && ev->button == 1 && selected) {
2469 // this is purely informational but necessary for route params UI
2470 ProcessorSelected (processor); // emit
2472 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
2475 _get_plugin_selector()->show_manager ();
2482 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
2484 boost::shared_ptr<Processor> processor;
2486 processor = child->processor ();
2489 if (processor && Keyboard::is_delete_event (ev)) {
2491 Glib::signal_idle().connect (sigc::bind (
2492 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
2493 boost::weak_ptr<Processor>(processor)));
2495 } else if (processor && Keyboard::is_button2_event (ev)
2497 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
2501 /* button2-click with no/appropriate modifiers */
2502 processor->enable (!processor->enabled ());
2509 ProcessorBox::build_processor_menu ()
2511 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/ProcessorMenu") );
2512 processor_menu->set_name ("ArdourContextMenu");
2513 return processor_menu;
2517 ProcessorBox::select_all_processors ()
2519 processor_display.select_all ();
2523 ProcessorBox::deselect_all_processors ()
2525 processor_display.select_none ();
2529 ProcessorBox::choose_plugin ()
2531 _get_plugin_selector()->set_interested_object (*this);
2534 /** @return true if an error occurred, otherwise false */
2536 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
2538 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
2540 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
2542 Route::ProcessorStreams err_streams;
2544 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
2545 weird_plugin_dialog (**p, err_streams);
2547 // XXX SHAREDPTR delete plugin here .. do we even need to care?
2548 } else if (plugins.size() == 1 && UIConfiguration::instance().get_open_gui_after_adding_plugin()) {
2549 if (processor->what_can_be_automated ().size () == 0) {
2550 ; /* plugin without controls, don't show ui */
2552 else if (boost::dynamic_pointer_cast<PluginInsert>(processor)->plugin()->has_inline_display() && UIConfiguration::instance().get_prefer_inline_over_gui()) {
2553 ; /* only show inline display */
2555 else if (processor_can_be_edited (processor)) {
2556 if (!ARDOUR_UI_UTILS::engine_is_running()) {
2558 } else if ((*p)->has_editor ()) {
2559 edit_processor (processor);
2560 } else if (boost::dynamic_pointer_cast<PluginInsert>(processor)->plugin()->parameter_count() > 0) {
2561 generic_edit_processor (processor);
2565 /* add next processor below the currently added.
2566 * Note: placement < 0: add the bottom */
2567 if (_placement >= 0) {
2576 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
2578 /* XXX this needs to be re-worked!
2580 * With new pin-management "streams" is no longer correct.
2581 * p.get_info () is also incorrect for variable i/o plugins (always -1,-1).
2583 * Since pin-management was added, this dialog will only show in a very rare
2584 * condition (non-replicated variable i/o configuration failed).
2586 * TODO: simplify the message after the string-freeze is lifted.
2588 ArdourDialog dialog (_("Plugin Incompatibility"));
2591 string text = string_compose(_("You attempted to add the plugin \"%1\" in slot %2.\n"),
2592 p.name(), streams.index);
2594 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
2595 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
2597 text += _("\nThis plugin has:\n");
2599 uint32_t const n = p.get_info()->n_inputs.n_midi ();
2600 text += string_compose (ngettext ("\t%1 MIDI input\n", "\t%1 MIDI inputs\n", n), n);
2603 uint32_t const n = p.get_info()->n_inputs.n_audio ();
2604 text += string_compose (ngettext ("\t%1 audio input\n", "\t%1 audio inputs\n", n), n);
2607 text += _("\nbut at the insertion point, there are:\n");
2609 uint32_t const n = streams.count.n_midi ();
2610 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
2613 uint32_t const n = streams.count.n_audio ();
2614 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
2617 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
2618 label.set_text(text);
2620 dialog.get_vbox()->pack_start (label);
2621 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
2623 dialog.set_name (X_("PluginIODialog"));
2624 dialog.set_modal (true);
2631 ProcessorBox::choose_insert ()
2633 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->pannable(), _route->mute_master()));
2634 _route->add_processor_by_index (processor, _placement);
2637 /* Caller must not hold process lock */
2639 ProcessorBox::choose_send ()
2641 boost::shared_ptr<Send> send (new Send (*_session, _route->pannable (), _route->mute_master()));
2643 /* make an educated guess at the initial number of outputs for the send */
2644 ChanCount outs = (_route->n_outputs().n_audio() && _session->master_out())
2645 ? _session->master_out()->n_outputs()
2646 : _route->n_outputs();
2648 /* XXX need processor lock on route */
2650 Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock());
2651 send->output()->ensure_io (outs, false, this);
2652 } catch (AudioEngine::PortRegistrationFailure& err) {
2653 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
2657 /* let the user adjust the IO setup before creation.
2659 Note: this dialog is NOT modal - we just leave it to run and it will
2660 return when its Finished signal is emitted - typically when the window
2664 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
2667 /* keep a reference to the send so it doesn't get deleted while
2668 the IOSelectorWindow is doing its stuff
2670 _processor_being_created = send;
2672 ios->selector().Finished.connect (sigc::bind (
2673 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
2674 boost::weak_ptr<Processor>(send), ios));
2679 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
2681 boost::shared_ptr<Processor> processor (weak_processor.lock());
2683 /* drop our temporary reference to the new send */
2684 _processor_being_created.reset ();
2691 case IOSelector::Cancelled:
2692 // processor will go away when all shared_ptrs to it vanish
2695 case IOSelector::Accepted:
2696 _route->add_processor_by_index (processor, _placement);
2700 delete_when_idle (ios);
2704 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
2706 boost::shared_ptr<Processor> processor (weak_processor.lock());
2708 /* drop our temporary reference to the new return */
2709 _processor_being_created.reset ();
2716 case IOSelector::Cancelled:
2717 // processor will go away when all shared_ptrs to it vanish
2720 case IOSelector::Accepted:
2721 _route->add_processor_by_index (processor, _placement);
2725 delete_when_idle (ios);
2729 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
2735 boost::shared_ptr<Route> target = wr.lock();
2741 if (target->is_foldbackbus ()) {
2742 _route->add_foldback_send (target);
2744 _session->add_internal_send (target, _placement, _route);
2749 ProcessorBox::remove_aux (boost::weak_ptr<Route> wr)
2755 boost::shared_ptr<Route> target = wr.lock();
2760 boost::shared_ptr<Send> send = _route->internal_send_for (target);
2761 boost::shared_ptr<Processor> proc = boost::dynamic_pointer_cast<Processor> (send);
2762 _route->remove_processor (proc);
2767 ProcessorBox::route_processors_changed (RouteProcessorChange c)
2769 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
2770 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
2774 redisplay_processors ();
2778 ProcessorBox::redisplay_processors ()
2780 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors);
2782 if (no_processor_redisplay) {
2786 processor_display.clear ();
2788 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
2789 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
2790 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_pin_mgr));
2792 setup_entry_positions ();
2795 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
2796 * not already have one.
2799 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
2801 boost::shared_ptr<Processor> p = w.lock ();
2805 if (p->window_proxy()) {
2809 /* see also ProcessorBox::get_editor_window */
2810 bool have_ui = false;
2812 if (boost::dynamic_pointer_cast<PluginInsert> (p)) {
2815 else if (boost::dynamic_pointer_cast<PortInsert> (p)) {
2818 else if (boost::dynamic_pointer_cast<Send> (p)) {
2819 if (!boost::dynamic_pointer_cast<InternalSend> (p)) {
2823 else if (boost::dynamic_pointer_cast<Return> (p)) {
2824 if (!boost::dynamic_pointer_cast<InternalReturn> (p)) {
2833 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
2834 string_compose ("P-%1-%2", _route->id(), p->id()),
2838 const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
2841 wp->set_state (*ui_xml, 0);
2844 p->set_window_proxy (wp);
2845 WM::Manager::instance().register_window (wp);
2849 ProcessorBox::maybe_add_processor_pin_mgr (boost::weak_ptr<Processor> w)
2851 boost::shared_ptr<Processor> p = w.lock ();
2852 if (!p || p->pinmgr_proxy ()) {
2855 if (!boost::dynamic_pointer_cast<PluginInsert> (p)) {
2859 PluginPinWindowProxy* wp = new PluginPinWindowProxy (
2860 string_compose ("PM-%1-%2", _route->id(), p->id()), w);
2861 wp->set_session (_session);
2863 const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
2865 wp->set_state (*ui_xml, 0);
2868 p->set_pingmgr_proxy (wp);
2869 WM::Manager::instance().register_window (wp);
2873 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
2875 boost::shared_ptr<Processor> processor (p.lock ());
2877 if (!processor || ( !processor->display_to_user()
2879 && !show_all_processors
2886 boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
2888 ProcessorEntry* e = 0;
2889 if (plugin_insert) {
2890 e = new PluginInsertProcessorEntry (this, plugin_insert, _width);
2892 e = new ProcessorEntry (this, processor, _width);
2895 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
2896 boost::shared_ptr<PortInsert> ext = boost::dynamic_pointer_cast<PortInsert> (processor);
2897 boost::shared_ptr<UnknownProcessor> stub = boost::dynamic_pointer_cast<UnknownProcessor> (processor);
2899 //faders and meters are not deletable, copy/paste-able, so they shouldn't be selectable
2900 if (!send && !plugin_insert && !ext && !stub) {
2901 e->set_selectable(false);
2904 /* Set up this entry's state from the GUIObjectState */
2905 XMLNode* proc = entry_gui_object_state (e);
2907 e->set_control_state (proc);
2912 && !plugin_insert->plugin(0)->is_channelstrip()
2916 processor_display.add_child (e, drag_targets());
2918 processor_display.add_child (e, drag_targets_noplugin());
2923 ProcessorBox::reordered ()
2925 compute_processor_sort_keys ();
2926 setup_entry_positions ();
2930 ProcessorBox::setup_routing_feeds ()
2932 list<ProcessorEntry*> children = processor_display.children ();
2933 /* first set the i/o maps for every processor */
2934 list<ProcessorEntry*>::iterator prev = children.begin();
2936 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2937 boost::shared_ptr<ARDOUR::Processor> p = (*i)->processor();
2938 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (p);
2940 list<ProcessorEntry*>::iterator next = i;
2944 ChanCount sinks = pi->natural_input_streams ();
2945 ChanCount sources = pi->natural_output_streams ();
2946 uint32_t count = pi->get_count ();
2948 pi->configured_io (in, out);
2950 ChanCount midi_thru;
2951 ChanCount midi_bypass;
2952 ChanMapping input_map (pi->input_map ());
2953 if (pi->has_midi_thru ()) {
2954 midi_thru.set(DataType::MIDI, 1);
2955 input_map.set (DataType::MIDI, 0, 0);
2957 if (pi->has_midi_bypass ()) {
2958 midi_bypass.set(DataType::MIDI, 1);
2961 (*i)->input_icon.set_ports (sinks * count + midi_thru);
2962 (*i)->output_icon.set_ports (sources * count + midi_bypass);
2964 (*i)->routing_icon.set (
2966 sinks * count + midi_thru,
2967 sources * count + midi_bypass,
2972 if (next != children.end()) {
2973 (*next)->routing_icon.set_fed_by (out, sources * count + midi_bypass,
2974 pi->output_map (), pi->thru_map ());
2978 (*prev)->routing_icon.set_feeding (in, sinks * count + midi_thru,
2979 pi->input_map (), pi->thru_map ());
2983 (*i)->input_icon.set_ports (p->input_streams());
2984 (*i)->output_icon.set_ports (p->output_streams());
2985 ChanMapping inmap (p->input_streams ());
2986 ChanMapping outmap (p->output_streams ());
2987 ChanMapping thrumap;
2988 (*i)->routing_icon.set (
2990 p->output_streams(),
2992 p->output_streams(),
2993 inmap, outmap, thrumap);
2995 if (next != children.end()) {
2996 (*next)->routing_icon.set_fed_by (
2997 p->output_streams(),
2998 p->output_streams(),
3002 (*prev)->routing_icon.set_feeding (
3004 p->output_streams(),
3009 if (i == children.begin()) {
3010 (*i)->routing_icon.unset_fed_by ();
3013 (*i)->input_icon.hide();
3016 /* now set which icons need to be displayed */
3017 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
3018 (*i)->output_routing_icon.copy_state ((*i)->routing_icon);
3020 if ((*i)->routing_icon.in_identity ()) {
3021 (*i)->routing_icon.hide();
3022 if (i == children.begin()) {
3023 (*i)->input_icon.show();
3026 (*i)->routing_icon.show();
3027 (*i)->routing_icon.queue_draw();
3028 (*i)->input_icon.show();
3031 list<ProcessorEntry*>::iterator next = i;
3032 if (++next == children.end()) {
3033 // last processor in the chain
3034 (*i)->output_routing_icon.set_terminal(true);
3035 (*i)->output_routing_icon.unset_feeding ();
3036 if ((*i)->routing_icon.out_identity ()) {
3037 (*i)->output_routing_icon.hide();
3039 (*i)->output_routing_icon.show();
3040 (*i)->output_routing_icon.queue_draw();
3043 (*i)->output_routing_icon.set_terminal(false);
3044 if ( !(*i)->routing_icon.out_identity ()
3045 && !(*next)->routing_icon.in_identity ()
3046 && (*next)->routing_icon.can_coalesce ()) {
3047 (*i)->output_routing_icon.hide();
3048 } else if (!(*i)->routing_icon.out_identity ()) {
3049 (*i)->output_routing_icon.show();
3050 (*i)->output_routing_icon.queue_draw();
3051 (*next)->input_icon.show();
3053 (*i)->output_routing_icon.hide();
3060 ProcessorBox::setup_entry_positions ()
3062 list<ProcessorEntry*> children = processor_display.children ();
3063 bool pre_fader = true;
3066 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
3067 if (boost::dynamic_pointer_cast<Amp>((*i)->processor()) &&
3068 boost::dynamic_pointer_cast<Amp>((*i)->processor())->gain_control()->parameter().type() == GainAutomation) {
3070 (*i)->set_position (ProcessorEntry::Fader, num++);
3073 (*i)->set_position (ProcessorEntry::PreFader, num++);
3075 (*i)->set_position (ProcessorEntry::PostFader, num++);
3079 setup_routing_feeds ();
3083 ProcessorBox::compute_processor_sort_keys ()
3085 list<ProcessorEntry*> children = processor_display.children ();
3086 Route::ProcessorList our_processors;
3088 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
3089 if ((*i)->processor()) {
3090 our_processors.push_back ((*i)->processor ());
3094 if (_route->reorder_processors (our_processors)) {
3095 /* Reorder failed, so report this to the user. As far as I can see this must be done
3096 in an idle handler: it seems that the redisplay_processors() that happens below destroys
3097 widgets that were involved in the drag-and-drop on the processor list, which causes problems
3098 when the drag is torn down after this handler function is finished.
3100 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
3105 ProcessorBox::report_failed_reorder ()
3107 /* reorder failed, so redisplay */
3109 redisplay_processors ();
3111 /* now tell them about the problem */
3113 ArdourDialog dialog (_("Plugin Incompatibility"));
3116 label.set_text (_("\
3117 You cannot reorder these plugins/sends/inserts\n\
3118 in that way because the inputs and\n\
3119 outputs will not work correctly."));
3121 dialog.get_vbox()->set_border_width (12);
3122 dialog.get_vbox()->pack_start (label);
3123 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
3125 dialog.set_name (X_("PluginIODialog"));
3126 dialog.set_modal (true);
3133 ProcessorBox::rename_processors ()
3135 ProcSelection to_be_renamed;
3137 get_selected_processors (to_be_renamed);
3139 if (to_be_renamed.empty()) {
3143 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
3144 rename_processor (*i);
3149 ProcessorBox::can_cut () const
3151 vector<boost::shared_ptr<Processor> > sel;
3153 get_selected_processors (sel);
3155 /* cut_processors () does not cut inserts */
3157 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
3159 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
3160 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
3161 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
3170 ProcessorBox::stub_processor_selected () const
3172 vector<boost::shared_ptr<Processor> > sel;
3174 get_selected_processors (sel);
3176 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
3177 if (boost::dynamic_pointer_cast<UnknownProcessor>((*i)) != 0) {
3186 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
3188 if (to_be_removed.empty()) {
3192 XMLNode* node = new XMLNode (X_("cut"));
3193 Route::ProcessorList to_cut;
3195 no_processor_redisplay = true;
3196 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
3197 // Cut only plugins, sends and returns
3198 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
3199 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
3200 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
3202 Window* w = get_processor_ui (*i);
3208 XMLNode& child ((*i)->get_state());
3209 node->add_child_nocopy (child);
3210 to_cut.push_back (*i);
3214 if (_route->remove_processors (to_cut) != 0) {
3216 no_processor_redisplay = false;
3220 _p_selection.set (node);
3222 no_processor_redisplay = false;
3223 redisplay_processors ();
3227 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
3229 if (to_be_copied.empty()) {
3233 XMLNode* node = new XMLNode (X_("copy"));
3235 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
3236 // Copy only plugins, sends, returns
3237 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
3238 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
3239 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
3240 node->add_child_nocopy ((*i)->get_state());
3244 _p_selection.set (node);
3248 ProcessorBox::delete_processors (const ProcSelection& targets)
3250 if (targets.empty()) {
3254 no_processor_redisplay = true;
3256 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
3258 Window* w = get_processor_ui (*i);
3264 _route->remove_processor(*i);
3267 no_processor_redisplay = false;
3268 redisplay_processors ();
3272 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
3274 list<boost::shared_ptr<Processor> >::const_iterator x;
3276 no_processor_redisplay = true;
3277 for (x = procs.begin(); x != procs.end(); ++x) {
3279 Window* w = get_processor_ui (*x);
3285 _route->remove_processor(*x);
3288 no_processor_redisplay = false;
3289 redisplay_processors ();
3293 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
3295 boost::shared_ptr<Processor> processor (weak_processor.lock());
3301 /* NOT copied to _mixer.selection() */
3303 no_processor_redisplay = true;
3304 _route->remove_processor (processor);
3305 no_processor_redisplay = false;
3306 redisplay_processors ();
3312 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
3314 Prompter name_prompter (true);
3316 name_prompter.set_title (_("Rename Processor"));
3317 name_prompter.set_prompt (_("New name:"));
3318 name_prompter.set_initial_text (processor->name());
3319 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
3320 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
3321 name_prompter.show_all ();
3323 switch (name_prompter.run ()) {
3325 case Gtk::RESPONSE_ACCEPT:
3326 name_prompter.get_result (result);
3327 if (result.length()) {
3330 string test = result;
3332 while (tries < 100) {
3333 if (_session->io_name_is_legal (test)) {
3339 test = string_compose ("%1-%2", result, tries);
3343 processor->set_name (result);
3346 ARDOUR_UI::instance()->popup_error
3347 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
3357 ProcessorBox::paste_processors ()
3359 if (_p_selection.processors.empty()) {
3363 paste_processor_state (_p_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
3367 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
3370 if (_p_selection.processors.empty()) {
3374 paste_processor_state (_p_selection.processors.get_node().children(), before);
3378 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
3380 XMLNodeConstIterator niter;
3381 list<boost::shared_ptr<Processor> > copies;
3383 if (nlist.empty()) {
3387 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
3389 XMLProperty const * type = (*niter)->property ("type");
3390 XMLProperty const * role = (*niter)->property ("role");
3393 boost::shared_ptr<Processor> p;
3395 if (type->value() == "meter" ||
3396 type->value() == "main-outs" ||
3397 type->value() == "amp" ||
3398 type->value() == "intreturn") {
3399 /* do not paste meter, main outs, amp or internal returns */
3402 } else if (type->value() == "intsend") {
3404 /* aux sends are OK, but those used for
3405 * other purposes, are not.
3410 if (role->value() != "Aux") {
3414 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
3415 XMLNode n (**niter);
3416 InternalSend* s = new InternalSend (*_session, sendpan, _route->mute_master(),
3417 _route, boost::shared_ptr<Route>(), Delivery::Aux);
3419 IOProcessor::prepare_for_reset (n, s->name());
3421 if (s->set_state (n, Stateful::loading_state_version)) {
3428 } else if (type->value() == "send") {
3430 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
3431 XMLNode n (**niter);
3433 Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
3435 IOProcessor::prepare_for_reset (n, s->name());
3437 if (s->set_state (n, Stateful::loading_state_version)) {
3444 } else if (type->value() == "return") {
3446 XMLNode n (**niter);
3447 Return* r = new Return (*_session);
3449 IOProcessor::prepare_for_reset (n, r->name());
3451 if (r->set_state (n, Stateful::loading_state_version)) {
3458 } else if (type->value() == "port") {
3460 XMLNode n (**niter);
3461 PortInsert* pi = new PortInsert (*_session, _route->pannable (), _route->mute_master ());
3463 IOProcessor::prepare_for_reset (n, pi->name());
3465 if (pi->set_state (n, Stateful::loading_state_version)) {
3471 /* XXX its a bit limiting to assume that everything else
3474 p.reset (new PluginInsert (*_session));
3475 /* we can't use RAII Stateful::ForceIDRegeneration
3476 * because that'd void copying the state and wrongly bump
3477 * the state-version counter.
3478 * we need to load the state (incl external files) first and
3479 * only then update the ID)
3481 PBD::ID id = p->id();
3482 /* strip side-chain state (processor inside processor must be a side-chain)
3483 * otherwise we'll end up with duplicate ports-names.
3484 * (this needs a better solution which retains connections)
3485 * We really would want Stateful::ForceIDRegeneration here :(
3487 XMLNode state (**niter);
3488 state.remove_nodes_and_delete ("Processor");
3490 p->set_state (state, Stateful::current_state_version);
3491 boost::dynamic_pointer_cast<PluginInsert>(p)->update_id (id);
3494 copies.push_back (p);
3498 error << _("plugin insert constructor failed") << endmsg;
3502 if (copies.empty()) {
3506 if (_route->add_processors (copies, p)) {
3509 "Copying the set of processors on the clipboard failed,\n\
3510 probably because the I/O configuration of the plugins\n\
3511 could not match the configuration of this track.");
3512 MessageDialog am (msg);
3518 ProcessorBox::get_selected_processors (ProcSelection& processors) const
3520 const list<ProcessorEntry*> selection = processor_display.selection (true);
3521 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
3522 processors.push_back ((*i)->processor ());
3527 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
3529 list<ProcessorEntry*> selection = processor_display.selection ();
3530 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
3531 (this->*method) ((*i)->processor ());
3536 ProcessorBox::all_visible_processors_active (bool state)
3538 _route->all_visible_processors_active (state);
3542 ProcessorBox::ab_plugins ()
3544 _route->ab_plugins (ab_direction);
3545 ab_direction = !ab_direction;
3549 ProcessorBox::set_disk_io_position (DiskIOPoint diop)
3551 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (_route);
3553 t->set_disk_io_point (diop);
3558 ProcessorBox::clear_processors ()
3561 vector<string> choices;
3563 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
3564 "(this cannot be undone)"), _route->name());
3566 choices.push_back (_("Cancel"));
3567 choices.push_back (_("Yes, remove them all"));
3569 ArdourWidgets::Choice prompter (_("Remove processors"), prompt, choices);
3571 if (prompter.run () == 1) {
3572 _route->clear_processors (PreFader);
3573 _route->clear_processors (PostFader);
3578 ProcessorBox::clear_processors (Placement p)
3581 vector<string> choices;
3583 if (p == PreFader) {
3584 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
3585 "(this cannot be undone)"), _route->name());
3587 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
3588 "(this cannot be undone)"), _route->name());
3591 choices.push_back (_("Cancel"));
3592 choices.push_back (_("Yes, remove them all"));
3594 ArdourWidgets::Choice prompter (_("Remove processors"), prompt, choices);
3596 if (prompter.run () == 1) {
3597 _route->clear_processors (p);
3602 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
3604 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
3605 if (at && at->freeze_state() == AudioTrack::Frozen) {
3610 boost::dynamic_pointer_cast<Send> (processor) ||
3611 boost::dynamic_pointer_cast<Return> (processor) ||
3612 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
3613 boost::dynamic_pointer_cast<PortInsert> (processor)
3622 ProcessorBox::one_processor_can_be_edited ()
3624 list<ProcessorEntry*> selection = processor_display.selection ();
3625 list<ProcessorEntry*>::iterator i = selection.begin();
3626 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
3630 return (i != selection.end());
3634 ProcessorBox::get_editor_window (boost::shared_ptr<Processor> processor, bool use_custom)
3636 boost::shared_ptr<Send> send;
3637 boost::shared_ptr<InternalSend> internal_send;
3638 boost::shared_ptr<Return> retrn;
3639 boost::shared_ptr<PluginInsert> plugin_insert;
3640 boost::shared_ptr<PortInsert> port_insert;
3643 /* This method may or may not return a Window, but if it does not it
3644 * will modify the parent mixer strip appearance layout to allow
3645 * "editing" the @param processor that was passed in.
3647 * So for example, if the processor is an Amp (gain), the parent strip
3648 * will be forced back into a model where the fader controls the main gain.
3649 * If the processor is a send, then we map the send controls onto the
3652 * Plugins and others will return a window for control.
3655 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
3657 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
3662 if (boost::dynamic_pointer_cast<Amp> (processor) && boost::dynamic_pointer_cast<Amp> (processor)->gain_control()->parameter().type() == GainAutomation) {
3664 if (_parent_strip) {
3665 _parent_strip->revert_to_default_display ();
3668 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
3670 if (!ARDOUR_UI_UTILS::engine_is_running ()) {
3674 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
3676 gidget = new SendUIWindow (send, _session);
3679 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
3681 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
3682 /* no GUI for these */
3686 if (!ARDOUR_UI_UTILS::engine_is_running ()) {
3690 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
3692 ReturnUIWindow *return_ui;
3693 Window* w = get_processor_ui (retrn);
3697 return_ui = new ReturnUIWindow (retrn, _session);
3698 return_ui->set_title (retrn->name ());
3699 set_processor_ui (send, return_ui);
3702 return_ui = dynamic_cast<ReturnUIWindow *> (w);
3707 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
3709 PluginUIWindow *plugin_ui;
3711 /* these are both allowed to be null */
3713 Window* w = get_processor_ui (plugin_insert);
3716 plugin_ui = new PluginUIWindow (plugin_insert, false, use_custom);
3717 plugin_ui->set_title (generate_processor_title (plugin_insert));
3718 set_processor_ui (plugin_insert, plugin_ui);
3721 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
3726 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
3728 if (!ARDOUR_UI_UTILS::engine_is_running ()) {
3732 PortInsertWindow *io_selector;
3734 Window* w = get_processor_ui (port_insert);
3737 io_selector = new PortInsertWindow (_session, port_insert);
3738 set_processor_ui (port_insert, io_selector);
3741 io_selector = dynamic_cast<PortInsertWindow *> (w);
3744 gidget = io_selector;
3751 ProcessorBox::get_generic_editor_window (boost::shared_ptr<Processor> processor)
3753 boost::shared_ptr<PluginInsert> plugin_insert
3754 = boost::dynamic_pointer_cast<PluginInsert>(processor);
3756 if (!plugin_insert) {
3760 PluginUIWindow* win = new PluginUIWindow (plugin_insert, true, false);
3761 win->set_title (generate_processor_title (plugin_insert));
3767 ProcessorBox::register_actions ()
3769 /* We need to use a static object as the owner, since these actions
3770 need to be considered ownable by all ProcessorBox objects
3775 processor_box_actions = ActionManager::create_action_group (bindings, X_("ProcessorMenu"));
3777 Glib::RefPtr<Action> act;
3780 ActionManager::register_action (processor_box_actions, X_("newplugin"), _("New Plugin"),
3781 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
3783 act = ActionManager::register_action (processor_box_actions, X_("newinsert"), _("New Insert"),
3784 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
3785 ActionManager::engine_sensitive_actions.push_back (act);
3786 act = ActionManager::register_action (processor_box_actions, X_("newsend"), _("New External Send ..."),
3787 sigc::ptr_fun (ProcessorBox::rb_choose_send));
3788 ActionManager::engine_sensitive_actions.push_back (act);
3790 ActionManager::register_action (processor_box_actions, X_("newaux"), _("New Aux Send ..."));
3791 ActionManager::register_action (processor_box_actions, X_("newlisten"), _("New Monitor Send ..."));
3792 ActionManager::register_action (processor_box_actions, X_("removelisten"), _("Remove Monitor Send ..."));
3794 ActionManager::register_action (processor_box_actions, X_("controls"), _("Controls"));
3795 ActionManager::register_action (processor_box_actions, X_("send_options"), _("Send Options"));
3797 ActionManager::register_action (processor_box_actions, X_("clear"), _("Clear (all)"),
3798 sigc::ptr_fun (ProcessorBox::rb_clear));
3799 ActionManager::register_action (processor_box_actions, X_("clear_pre"), _("Clear (pre-fader)"),
3800 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
3801 ActionManager::register_action (processor_box_actions, X_("clear_post"), _("Clear (post-fader)"),
3802 sigc::ptr_fun (ProcessorBox::rb_clear_post));
3804 /* standard editing stuff */
3806 cut_action = ActionManager::register_action (processor_box_actions, X_("cut"), _("Cut"),
3807 sigc::ptr_fun (ProcessorBox::rb_cut));
3808 copy_action = ActionManager::register_action (processor_box_actions, X_("copy"), _("Copy"),
3809 sigc::ptr_fun (ProcessorBox::rb_copy));
3810 delete_action = ActionManager::register_action (processor_box_actions, X_("delete"), _("Delete"),
3811 sigc::ptr_fun (ProcessorBox::rb_delete));
3812 backspace_action = ActionManager::register_action (processor_box_actions, X_("backspace"), _("Delete"),
3813 sigc::ptr_fun (ProcessorBox::rb_delete));
3815 ActionManager::plugin_selection_sensitive_actions.push_back (cut_action);
3816 ActionManager::plugin_selection_sensitive_actions.push_back (copy_action);
3817 ActionManager::plugin_selection_sensitive_actions.push_back (delete_action);
3818 ActionManager::plugin_selection_sensitive_actions.push_back (backspace_action);
3820 paste_action = ActionManager::register_action (processor_box_actions, X_("paste"), _("Paste"),
3821 sigc::ptr_fun (ProcessorBox::rb_paste));
3822 rename_action = ActionManager::register_action (processor_box_actions, X_("rename"), _("Rename"),
3823 sigc::ptr_fun (ProcessorBox::rb_rename));
3824 ActionManager::register_action (processor_box_actions, X_("selectall"), _("Select All"),
3825 sigc::ptr_fun (ProcessorBox::rb_select_all));
3826 ActionManager::register_action (processor_box_actions, X_("deselectall"), _("Deselect All"),
3827 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
3829 /* activation etc. */
3831 ActionManager::register_action (processor_box_actions, X_("activate_all"), _("Activate All"),
3832 sigc::ptr_fun (ProcessorBox::rb_activate_all));
3833 ActionManager::register_action (processor_box_actions, X_("deactivate_all"), _("Deactivate All"),
3834 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
3835 ActionManager::register_action (processor_box_actions, X_("ab_plugins"), _("A/B Plugins"),
3836 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
3838 manage_pins_action = ActionManager::register_action (
3839 processor_box_actions, X_("manage-pins"), _("Pin Connections..."),
3840 sigc::ptr_fun (ProcessorBox::rb_manage_pins));
3843 disk_io_action = ActionManager::register_action (processor_box_actions, X_("disk-io-menu"), _("Disk I/O ..."));
3844 ActionManager::register_action (processor_box_actions, X_("disk-io-prefader"), _("Pre-Fader."), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_set_disk_io_position), DiskIOPreFader));
3845 ActionManager::register_action (processor_box_actions, X_("disk-io-postfader"), _("Post-Fader."), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_set_disk_io_position), DiskIOPostFader));
3846 ActionManager::register_action (processor_box_actions, X_("disk-io-custom"), _("Custom."), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_set_disk_io_position), DiskIOCustom));
3849 edit_action = ActionManager::register_action (
3850 processor_box_actions, X_("edit"), _("Edit..."),
3851 sigc::ptr_fun (ProcessorBox::rb_edit));
3853 edit_generic_action = ActionManager::register_action (
3854 processor_box_actions, X_("edit-generic"), _("Edit with generic controls..."),
3855 sigc::ptr_fun (ProcessorBox::rb_edit_generic));
3860 ProcessorBox::rb_edit_generic ()
3862 if (_current_processor_box == 0) {
3866 _current_processor_box->for_selected_processors (&ProcessorBox::generic_edit_processor);
3870 ProcessorBox::rb_ab_plugins ()
3872 if (_current_processor_box == 0) {
3876 _current_processor_box->ab_plugins ();
3880 ProcessorBox::rb_set_disk_io_position (DiskIOPoint diop)
3882 if (_current_processor_box == 0) {
3886 _current_processor_box->set_disk_io_position (diop);
3890 ProcessorBox::rb_manage_pins ()
3892 if (_current_processor_box == 0) {
3896 _current_processor_box->for_selected_processors (&ProcessorBox::manage_pins);
3899 ProcessorBox::rb_choose_plugin ()
3901 if (_current_processor_box == 0) {
3904 _current_processor_box->choose_plugin ();
3908 ProcessorBox::rb_choose_insert ()
3910 if (_current_processor_box == 0) {
3913 _current_processor_box->choose_insert ();
3917 ProcessorBox::rb_choose_send ()
3919 if (_current_processor_box == 0) {
3922 _current_processor_box->choose_send ();
3926 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
3928 if (_current_processor_box == 0) {
3932 _current_processor_box->choose_aux (wr);
3936 ProcessorBox::rb_remove_aux (boost::weak_ptr<Route> wr)
3938 if (_current_processor_box == 0) {
3942 _current_processor_box->remove_aux (wr);
3946 ProcessorBox::rb_clear ()
3948 if (_current_processor_box == 0) {
3952 _current_processor_box->clear_processors ();
3957 ProcessorBox::rb_clear_pre ()
3959 if (_current_processor_box == 0) {
3963 _current_processor_box->clear_processors (PreFader);
3968 ProcessorBox::rb_clear_post ()
3970 if (_current_processor_box == 0) {
3974 _current_processor_box->clear_processors (PostFader);
3978 ProcessorBox::rb_cut ()
3980 if (_current_processor_box == 0) {
3984 _current_processor_box->processor_operation (ProcessorsCut);
3988 ProcessorBox::rb_delete ()
3990 if (_current_processor_box == 0) {
3994 _current_processor_box->processor_operation (ProcessorsDelete);
3998 ProcessorBox::rb_copy ()
4000 if (_current_processor_box == 0) {
4003 _current_processor_box->processor_operation (ProcessorsCopy);
4007 ProcessorBox::rb_paste ()
4009 if (_current_processor_box == 0) {
4013 _current_processor_box->processor_operation (ProcessorsPaste);
4017 ProcessorBox::rb_rename ()
4019 if (_current_processor_box == 0) {
4022 _current_processor_box->rename_processors ();
4026 ProcessorBox::rb_select_all ()
4028 if (_current_processor_box == 0) {
4032 _current_processor_box->processor_operation (ProcessorsSelectAll);
4036 ProcessorBox::rb_deselect_all ()
4038 if (_current_processor_box == 0) {
4042 _current_processor_box->deselect_all_processors ();
4046 ProcessorBox::rb_activate_all ()
4048 if (_current_processor_box == 0) {
4052 _current_processor_box->all_visible_processors_active (true);
4056 ProcessorBox::rb_deactivate_all ()
4058 if (_current_processor_box == 0) {
4061 _current_processor_box->all_visible_processors_active (false);
4065 ProcessorBox::rb_edit ()
4067 if (_current_processor_box == 0) {
4071 _current_processor_box->for_selected_processors (&ProcessorBox::edit_processor);
4075 ProcessorBox::edit_aux_send (boost::shared_ptr<Processor> processor)
4077 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
4081 if (_parent_strip) {
4082 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
4083 if (_parent_strip->current_delivery() == send) {
4084 _parent_strip->revert_to_default_display ();
4086 _parent_strip->show_send(send);
4093 ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
4098 if (edit_aux_send (processor)) {
4101 if (!ARDOUR_UI_UTILS::engine_is_running ()) {
4105 ProcessorWindowProxy* proxy = find_window_proxy (processor);
4108 proxy->set_custom_ui_mode (true);
4109 proxy->show_the_right_window ();
4114 ProcessorBox::generic_edit_processor (boost::shared_ptr<Processor> processor)
4119 if (edit_aux_send (processor)) {
4122 if (!ARDOUR_UI_UTILS::engine_is_running ()) {
4126 ProcessorWindowProxy* proxy = find_window_proxy (processor);
4129 proxy->set_custom_ui_mode (false);
4130 proxy->show_the_right_window ();
4135 ProcessorBox::manage_pins (boost::shared_ptr<Processor> processor)
4140 PluginPinWindowProxy* proxy = processor->pinmgr_proxy ();
4149 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
4151 if (!what_changed.contains (ARDOUR::Properties::name)) {
4155 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
4157 boost::shared_ptr<Processor> processor;
4158 boost::shared_ptr<PluginInsert> plugin_insert;
4159 boost::shared_ptr<Send> send;
4161 list<ProcessorEntry*> children = processor_display.children();
4163 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
4165 processor = (*iter)->processor ();
4171 Window* w = get_processor_ui (processor);
4177 /* rename editor windows for sends and plugins */
4179 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
4180 w->set_title (send->name ());
4181 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
4182 w->set_title (generate_processor_title (plugin_insert));
4188 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
4190 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
4191 string::size_type email_pos;
4193 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
4194 maker = maker.substr (0, email_pos - 1);
4197 if (maker.length() > 32) {
4198 maker = maker.substr (0, 32);
4202 SessionObject* owner = pi->owner();
4205 return string_compose(_("%1: %2 (by %3)"), owner->name(), pi->name(), maker);
4207 return string_compose(_("%1 (by %2)"), pi->name(), maker);
4211 /** @param p Processor.
4212 * @return the UI window for \a p.
4215 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
4217 ProcessorWindowProxy* wp = p->window_proxy();
4224 /** Make a note of the UI window that a processor is using.
4225 * @param p Processor.
4226 * @param w UI window.
4229 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
4231 assert (p->window_proxy());
4232 p->window_proxy()->use_window (*w);
4236 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
4238 boost::shared_ptr<Delivery> d = w.lock ();
4243 list<ProcessorEntry*> children = processor_display.children ();
4244 list<ProcessorEntry*>::const_iterator i = children.begin();
4245 while (i != children.end() && (*i)->processor() != d) {
4249 if (i == children.end()) {
4250 processor_display.set_active (0);
4252 processor_display.set_active (*i);
4256 /** Called to repair the damage of Editor::show_window doing a show_all() */
4258 ProcessorBox::hide_things ()
4260 list<ProcessorEntry*> c = processor_display.children ();
4261 for (list<ProcessorEntry*>::iterator i = c.begin(); i != c.end(); ++i) {
4262 (*i)->hide_things ();
4267 ProcessorBox::processor_menu_unmapped ()
4269 processor_display.remove_placeholder ();
4270 /* make all possibly-desensitized actions sensitive again so that
4271 they be activated by other means (e.g. bindings)
4273 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, true);
4277 ProcessorBox::entry_gui_object_state (ProcessorEntry* entry)
4279 if (!_parent_strip) {
4283 GUIObjectState& st = _parent_strip->gui_object_state ();
4285 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
4287 return st.get_or_add_node (strip, entry->state_id());
4291 ProcessorBox::update_gui_object_state (ProcessorEntry* entry)
4293 XMLNode* proc = entry_gui_object_state (entry);
4298 /* XXX: this is a bit inefficient; we just remove all child nodes and re-add them */
4299 proc->remove_nodes_and_delete (X_("Object"));
4300 entry->add_control_state (proc);
4304 ProcessorBox::is_editor_mixer_strip() const
4306 return _parent_strip && !_parent_strip->mixer_owned();
4309 ProcessorWindowProxy::ProcessorWindowProxy (string const & name, ProcessorBox* box, boost::weak_ptr<Processor> processor)
4310 : WM::ProxyBase (name, string())
4311 , _processor_box (box)
4312 , _processor (processor)
4314 , want_custom (true)
4316 boost::shared_ptr<Processor> p = _processor.lock ();
4320 p->DropReferences.connect (going_away_connection, MISSING_INVALIDATOR, boost::bind (&ProcessorWindowProxy::processor_going_away, this), gui_context());
4322 p->ToggleUI.connect (gui_connections, invalidator (*this), boost::bind (&ProcessorWindowProxy::show_the_right_window, this, false), gui_context());
4323 p->ShowUI.connect (gui_connections, invalidator (*this), boost::bind (&ProcessorWindowProxy::show_the_right_window, this, true), gui_context());
4324 p->HideUI.connect (gui_connections, invalidator (*this), boost::bind (&ProcessorWindowProxy::hide, this), gui_context());
4327 ProcessorWindowProxy::~ProcessorWindowProxy()
4329 /* processor window proxies do not own the windows they create with
4330 * ::get(), so set _window to null before the normal WindowProxy method
4337 ProcessorWindowProxy::processor_going_away ()
4339 gui_connections.drop_connections ();
4342 WM::Manager::instance().remove (this);
4343 /* should be no real reason to do this, since the object that would
4344 send DropReferences is about to be deleted, but lets do it anyway.
4346 going_away_connection.disconnect();
4350 ARDOUR::SessionHandlePtr*
4351 ProcessorWindowProxy::session_handle()
4358 ProcessorWindowProxy::get_state ()
4361 node = &ProxyBase::get_state();
4362 node->set_property (X_("custom-ui"), is_custom);
4367 ProcessorWindowProxy::set_state (const XMLNode& node, int /*version*/)
4369 XMLNodeList children = node.children ();
4370 XMLNodeList::const_iterator i = children.begin ();
4371 while (i != children.end()) {
4373 if ((*i)->name() == X_("Window") && (*i)->get_property (X_("name"), name) && name == _name) {
4379 if (i != children.end()) {
4380 (*i)->get_property (X_("custom-ui"), want_custom);
4383 return ProxyBase::set_state (node, 0);
4387 ProcessorWindowProxy::get (bool create)
4389 boost::shared_ptr<Processor> p = _processor.lock ();
4394 if (_window && (is_custom != want_custom)) {
4395 /* drop existing window - wrong type */
4396 set_state_mask (Gtkmm2ext::WindowProxy::StateMask (state_mask () & ~WindowProxy::Size));
4405 is_custom = want_custom;
4406 _window = _processor_box->get_editor_window (p, is_custom);
4410 _window->show_all ();
4417 ProcessorWindowProxy::show_the_right_window (bool show_not_toggle)
4419 if (_window && (is_custom != want_custom)) {
4420 /* drop existing window - wrong type */
4421 set_state_mask (Gtkmm2ext::WindowProxy::StateMask (state_mask () & ~WindowProxy::Size));
4424 if (_window && fully_visible () && show_not_toggle) {
4431 PluginPinWindowProxy::PluginPinWindowProxy(std::string const &name, boost::weak_ptr<ARDOUR::Processor> processor)
4432 : WM::ProxyBase (name, string())
4433 , _processor (processor)
4435 boost::shared_ptr<Processor> p = _processor.lock ();
4439 p->DropReferences.connect (going_away_connection, MISSING_INVALIDATOR, boost::bind (&PluginPinWindowProxy::processor_going_away, this), gui_context());
4442 PluginPinWindowProxy::~PluginPinWindowProxy()
4447 ARDOUR::SessionHandlePtr*
4448 PluginPinWindowProxy::session_handle ()
4450 ArdourWindow* aw = dynamic_cast<ArdourWindow*> (_window);
4451 if (aw) { return aw; }
4456 PluginPinWindowProxy::get (bool create)
4458 boost::shared_ptr<Processor> p = _processor.lock ();
4459 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (p);
4468 _window = new PluginPinDialog (pi);
4469 ArdourWindow* aw = dynamic_cast<ArdourWindow*> (_window);
4471 aw->set_session (_session);
4473 _window->show_all ();
4479 PluginPinWindowProxy::processor_going_away ()
4483 WM::Manager::instance().remove (this);
4484 going_away_connection.disconnect();
4489 ProcessorBox::load_bindings ()
4491 bindings = Bindings::get_bindings (X_("Processor Box"));