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 set_visible (false);
1043 ProcessorEntry::Control::set_visible (bool v)
1054 /** Called when the Editor might have re-shown things that
1058 ProcessorEntry::Control::hide_things ()
1066 ProcessorEntry::Control::state_id () const
1068 boost::shared_ptr<AutomationControl> c = _control.lock ();
1071 return string_compose (X_("control %1"), c->id().to_s ());
1074 PluginInsertProcessorEntry::PluginInsertProcessorEntry (ProcessorBox* b, boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
1075 : ProcessorEntry (b, p, w)
1076 , _plugin_insert (p)
1078 p->PluginIoReConfigure.connect (
1079 _iomap_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::iomap_changed, this), gui_context()
1081 p->PluginMapChanged.connect (
1082 _iomap_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::iomap_changed, this), gui_context()
1084 p->PluginConfigChanged.connect (
1085 _iomap_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::iomap_changed, this), gui_context()
1090 PluginInsertProcessorEntry::iomap_changed ()
1092 _parent->setup_routing_feeds ();
1093 routing_icon.queue_draw();
1094 output_routing_icon.queue_draw();
1098 PluginInsertProcessorEntry::hide_things ()
1100 ProcessorEntry::hide_things ();
1103 ProcessorEntry::PortIcon::PortIcon(bool input) {
1105 _ports = ARDOUR::ChanCount(ARDOUR::DataType::AUDIO, 1);
1106 set_size_request (-1, std::max (2.f, rintf(2.f * UIConfiguration::instance().get_ui_scale())));
1110 ProcessorEntry::PortIcon::on_expose_event (GdkEventExpose* ev)
1112 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
1114 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
1117 Gtk::Allocation a = get_allocation();
1118 double const width = a.get_width();
1119 double const height = a.get_height();
1121 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
1122 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
1124 cairo_rectangle (cr, 0, 0, width, height);
1127 const double dx = rint(max(2., 2. * UIConfiguration::instance().get_ui_scale()));
1128 for (uint32_t i = 0; i < _ports.n_total(); ++i) {
1129 set_routing_color (cr, i < _ports.n_midi());
1130 const double x = ProcessorEntry::RoutingIcon::pin_x_pos (i, width, _ports.n_total(), 0 , false);
1131 cairo_rectangle (cr, x - .5 - dx * .5, 0, 1 + dx, height);
1139 ProcessorEntry::RoutingIcon::RoutingIcon (bool input)
1143 set_terminal (false);
1147 ProcessorEntry::RoutingIcon::set_terminal (bool b) {
1149 int h = std::max (8.f, rintf(8.f * sqrt (UIConfiguration::instance().get_ui_scale())));
1151 h += std::max (4.f, rintf(4.f * sqrt (UIConfiguration::instance().get_ui_scale())));
1153 set_size_request (-1, h);
1157 ProcessorEntry::RoutingIcon::set (
1158 const ARDOUR::ChanCount& in,
1159 const ARDOUR::ChanCount& out,
1160 const ARDOUR::ChanCount& sinks,
1161 const ARDOUR::ChanCount& sources,
1162 const ARDOUR::ChanMapping& in_map,
1163 const ARDOUR::ChanMapping& out_map,
1164 const ARDOUR::ChanMapping& thru_map)
1172 _thru_map = thru_map;
1176 ProcessorEntry::RoutingIcon::in_identity () const {
1177 if (_thru_map.n_total () > 0) {
1180 if (!_in_map.is_monotonic () || !_in_map.is_identity ()) {
1183 if (_in_map.n_total () != _sinks.n_total () || _in.n_total () != _sinks.n_total ()) {
1190 ProcessorEntry::RoutingIcon::out_identity () const {
1191 if (_thru_map.n_total () > 0) {
1192 // TODO skip if trhu is not connected to any of next's inputs
1195 if (!_out_map.is_monotonic () || !_out_map.is_identity ()) {
1198 if (_out_map.n_total () != _sources.n_total () || _out.n_total () != _sources.n_total ()) {
1205 ProcessorEntry::RoutingIcon::can_coalesce () const {
1206 if (_thru_map.n_total () > 0) {
1209 if (_fed_by && _f_out != _f_sources) {
1212 if (_fed_by && !_f_out_map.is_identity () && !_in_map.is_identity ()) {
1215 if (_input && _sinks == _in && (!_fed_by || _f_out == _in)) {
1222 ProcessorEntry::RoutingIcon::set_fed_by (
1223 const ARDOUR::ChanCount& out,
1224 const ARDOUR::ChanCount& sources,
1225 const ARDOUR::ChanMapping& out_map,
1226 const ARDOUR::ChanMapping& thru_map)
1229 _f_sources = sources;
1230 _f_out_map = out_map;
1231 _f_thru_map = thru_map;
1236 ProcessorEntry::RoutingIcon::set_feeding (
1237 const ARDOUR::ChanCount& in,
1238 const ARDOUR::ChanCount& sinks,
1239 const ARDOUR::ChanMapping& in_map,
1240 const ARDOUR::ChanMapping& thru_map)
1245 _i_thru_map = thru_map;
1250 ProcessorEntry::RoutingIcon::pin_x_pos (uint32_t i, double width, uint32_t n_total, uint32_t n_midi, bool midi)
1252 if (!midi) { i += n_midi; }
1255 return rint (width * .5) +.5;
1257 return rint (width * (.15 + .7 * i / (n_total - 1))) + .5;
1261 ProcessorEntry::RoutingIcon::draw_gnd (cairo_t* cr, double x0, double y0, double height, bool midi)
1263 const double dx = 1 + rint (max(2., 2. * UIConfiguration::instance().get_ui_scale()));
1264 const double y1 = rint (height * .66) + .5;
1267 cairo_translate (cr, x0, y0);
1268 cairo_move_to (cr, 0, height);
1269 cairo_line_to (cr, 0, y1);
1270 cairo_move_to (cr, 0 - dx, y1);
1271 cairo_line_to (cr, 0 + dx, y1);
1273 set_routing_color (cr, midi);
1274 cairo_set_line_width (cr, 1.0);
1280 ProcessorEntry::RoutingIcon::draw_sidechain (cairo_t* cr, double x0, double y0, double height, bool midi)
1282 const double dx = 1 + rint (max(2., 2. * UIConfiguration::instance().get_ui_scale()));
1283 const double y1 = rint (height * .5) - .5;
1286 cairo_translate (cr, x0, y0);
1287 cairo_move_to (cr, 0 - dx, height);
1288 cairo_line_to (cr, 0, y1);
1289 cairo_line_to (cr, 0 + dx, height);
1290 cairo_close_path (cr);
1292 set_routing_color (cr, midi);
1298 ProcessorEntry::RoutingIcon::draw_thru_src (cairo_t* cr, double x0, double y0, double height, bool midi)
1300 const double rad = 1;
1301 const double y1 = height - rad - 1.5;
1303 cairo_arc (cr, x0, y0 + y1, rad, 0, 2. * M_PI);
1304 cairo_move_to (cr, x0, y0 + height - 1.5);
1305 cairo_line_to (cr, x0, y0 + height);
1306 set_routing_color (cr, midi);
1307 cairo_set_line_width (cr, 1.0);
1312 ProcessorEntry::RoutingIcon::draw_thru_sink (cairo_t* cr, double x0, double y0, double height, bool midi)
1314 const double rad = 1;
1315 const double y1 = rad + 1;
1317 cairo_arc (cr, x0, y0 + y1, rad, 0, 2. * M_PI);
1318 cairo_move_to (cr, x0, y0);
1319 cairo_line_to (cr, x0, y0 + 1);
1320 set_routing_color (cr, midi);
1321 cairo_set_line_width (cr, 1.0);
1326 ProcessorEntry::RoutingIcon::draw_connection (cairo_t* cr, double x0, double x1, double y0, double y1, bool midi, bool dashed)
1328 double bz = abs (y1 - y0);
1330 cairo_move_to (cr, x0, y0);
1331 cairo_curve_to (cr, x0, y0 + bz, x1, y1 - bz, x1, y1);
1332 cairo_set_line_width (cr, 1.0);
1333 cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
1334 cairo_set_source_rgb (cr, 1, 0, 0);
1336 const double dashes[] = { 2, 3 };
1337 cairo_set_dash (cr, dashes, 2, 0);
1339 set_routing_color (cr, midi);
1342 cairo_set_dash (cr, 0, 0, 0);
1347 ProcessorEntry::RoutingIcon::on_expose_event (GdkEventExpose* ev)
1349 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
1351 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
1354 cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
1356 Gtk::Allocation a = get_allocation();
1357 double const width = a.get_width();
1358 double const height = a.get_height();
1360 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
1361 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
1363 cairo_rectangle (cr, 0, 0, width, height);
1367 if (can_coalesce ()) {
1368 expose_coalesced_input_map (cr, width, height);
1370 expose_input_map (cr, width, height);
1373 expose_output_map (cr, width, height);
1381 ProcessorEntry::RoutingIcon::expose_coalesced_input_map (cairo_t* cr, const double width, const double height)
1383 const uint32_t pc_in = _sinks.n_total();
1384 const uint32_t pc_in_midi = _sinks.n_midi();
1386 for (uint32_t i = 0; i < pc_in; ++i) {
1387 const bool is_midi = i < pc_in_midi;
1389 uint32_t pn = is_midi ? i : i - pc_in_midi;
1390 DataType dt = is_midi ? DataType::MIDI : DataType::AUDIO;
1391 uint32_t idx = _in_map.get (dt, pn, &valid_in);
1393 double x = pin_x_pos (i, width, pc_in, 0, is_midi);
1394 draw_gnd (cr, x, 0, height, is_midi);
1397 if (idx >= _in.get (dt)) {
1398 // side-chain, probably
1399 double x = pin_x_pos (i, width, pc_in, 0, is_midi);
1400 draw_sidechain (cr, x, 0, height, is_midi);
1404 double c_x1 = pin_x_pos (i, width, pc_in, 0, false);
1408 uint32_t src = _f_out_map.get_src (dt, idx, &valid_src);
1410 double x = pin_x_pos (i, width, pc_in, 0, false);
1412 _f_thru_map.get (dt, idx, &valid_thru);
1414 draw_thru_src (cr, x, 0, height, is_midi);
1416 draw_gnd (cr, x, 0, height, is_midi);
1420 c_x0 = pin_x_pos (src, width, _f_sources.n_total(), _f_sources.n_midi(), is_midi);
1422 c_x0 = pin_x_pos (idx, width, _in.n_total(), _in.n_midi(), is_midi);
1424 draw_connection (cr, c_x0, c_x1, 0, height, is_midi);
1429 ProcessorEntry::RoutingIcon::expose_input_map (cairo_t* cr, const double width, const double height)
1431 const uint32_t n_in = _in.n_total();
1432 const uint32_t n_in_midi = _in.n_midi();
1433 const uint32_t pc_in = _sinks.n_total();
1434 const uint32_t pc_in_midi = _sinks.n_midi();
1436 // draw inputs to this
1437 for (uint32_t i = 0; i < pc_in; ++i) {
1438 const bool is_midi = i < pc_in_midi;
1440 uint32_t pn = is_midi ? i : i - pc_in_midi;
1441 DataType dt = is_midi ? DataType::MIDI : DataType::AUDIO;
1442 uint32_t idx = _in_map.get (dt, pn, &valid_in);
1443 // check if it's fed
1444 bool valid_src = true;
1445 if (valid_in && idx < _in.get (dt) && _fed_by) {
1448 _f_out_map.get_src (dt, idx, &valid_out);
1449 _f_thru_map.get (dt, idx, &valid_thru);
1450 if (!valid_out && !valid_thru) {
1454 if (!valid_in || !valid_src) {
1455 double x = pin_x_pos (i, width, pc_in, 0, is_midi);
1456 draw_gnd (cr, x, 0, height, is_midi);
1459 if (idx >= _in.get (dt)) {
1460 // side-chain, probably
1461 double x = pin_x_pos (i, width, pc_in, 0, is_midi);
1462 draw_sidechain (cr, x, 0, height, is_midi);
1465 double c_x1 = pin_x_pos (i, width, pc_in, 0, false);
1466 double c_x0 = pin_x_pos (idx, width, n_in, n_in_midi, is_midi);
1467 draw_connection (cr, c_x0, c_x1, 0, height, is_midi);
1470 // draw reverse thru
1471 for (uint32_t i = 0; i < n_in; ++i) {
1472 const bool is_midi = i < n_in_midi;
1474 uint32_t pn = is_midi ? i : i - n_in_midi;
1475 DataType dt = is_midi ? DataType::MIDI : DataType::AUDIO;
1476 _thru_map.get_src (dt, pn, &valid_thru);
1480 double x = pin_x_pos (i, width, n_in, 0, is_midi);
1481 draw_thru_sink (cr, x, 0, height, is_midi);
1486 ProcessorEntry::RoutingIcon::expose_output_map (cairo_t* cr, const double width, const double height)
1488 int dh = std::max (4.f, rintf(4.f * UIConfiguration::instance().get_ui_scale()));
1489 double ht = _terminal ? height - dh : height;
1491 // draw outputs of this
1492 const uint32_t pc_out = _sources.n_total();
1493 const uint32_t pc_out_midi = _sources.n_midi();
1494 const uint32_t n_out = _out.n_total();
1495 const uint32_t n_out_midi = _out.n_midi();
1497 for (uint32_t i = 0; i < pc_out; ++i) {
1498 const bool is_midi = i < pc_out_midi;
1500 uint32_t pn = is_midi ? i : i - pc_out_midi;
1501 DataType dt = is_midi ? DataType::MIDI : DataType::AUDIO;
1502 uint32_t idx = _out_map.get (dt, pn, &valid_out);
1506 // skip connections that are not used in the next's input
1508 bool valid_thru, valid_sink;
1509 _i_in_map.get_src (dt, idx, &valid_sink);
1510 _i_thru_map.get_src (dt, idx, &valid_thru);
1511 if (!valid_thru && !valid_sink) {
1512 if (!is_midi || i != 0) { // special case midi-bypass
1517 double c_x0 = pin_x_pos (i, width, pc_out, 0, false);
1518 double c_x1 = pin_x_pos (idx, width, n_out, n_out_midi, is_midi);
1519 draw_connection (cr, c_x0, c_x1, 0, ht, is_midi);
1522 for (uint32_t i = 0; i < n_out; ++i) {
1523 const bool is_midi = i < n_out_midi;
1524 uint32_t pn = is_midi ? i : i - n_out_midi;
1525 DataType dt = is_midi ? DataType::MIDI : DataType::AUDIO;
1526 double x = pin_x_pos (i, width, n_out, 0, is_midi);
1529 bool valid_thru_f = false;
1530 // skip connections that are not used in the next's input
1533 _i_in_map.get_src (dt, pn, &valid_sink);
1534 _i_thru_map.get_src (dt, pn, &valid_thru_f);
1535 if (!valid_thru_f && !valid_sink) {
1536 if (!is_midi || i != 0) { // special case midi-bypass
1543 _out_map.get_src (dt, pn, &valid_src);
1546 uint32_t idx = _thru_map.get (dt, pn, &valid_thru);
1548 if (idx >= _in.get (dt)) {
1549 draw_sidechain (cr, x, 0, height, is_midi);
1551 draw_thru_src (cr, x, 0, height, is_midi);
1553 } else if (valid_thru_f){
1554 // gnd is part of input, unless it's a thru input
1555 // (also only true if !coalesced into one small display)
1556 draw_gnd (cr, x, 0, height, is_midi);
1560 // terminal node, add arrows
1562 _out_map.get_src (dt, pn, &valid_src);
1565 uint32_t idx = _thru_map.get (dt, pn, &valid_thru);
1567 if (idx >= _in.get (dt)) {
1568 draw_sidechain (cr, x, 0, height - dh, is_midi);
1570 draw_thru_src (cr, x, 0, height - dh, is_midi);
1573 draw_gnd (cr, x, 0, height - dh, is_midi);
1577 set_routing_color (cr, is_midi);
1578 cairo_set_line_width (cr, 1.0);
1579 cairo_move_to (cr, x, height - dh);
1580 cairo_line_to (cr, x, height - 2);
1583 const double ar = dh - 1;
1584 cairo_move_to (cr, x - ar, height - ar);
1585 cairo_line_to (cr, x , height - .5);
1586 cairo_line_to (cr, x + ar, height - ar);
1587 cairo_line_to (cr, x , height - ar * .5);
1588 cairo_close_path (cr);
1589 cairo_fill_preserve (cr);
1595 ProcessorEntry::PluginInlineDisplay::PluginInlineDisplay (ProcessorEntry& e, boost::shared_ptr<ARDOUR::Plugin> p, uint32_t max_height)
1596 : PluginDisplay (p, max_height)
1599 , _given_max_height (max_height)
1601 std::string postfix = string_compose(_("\n%1+double-click to toggle inline-display"), Keyboard::tertiary_modifier_name ());
1603 if (_plug->has_editor()) {
1605 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));
1608 string_compose (_("<b>%1</b>\nDouble-click to show generic GUI.%2"), e.name (Wide), postfix));
1614 ProcessorEntry::PluginInlineDisplay::on_button_press_event (GdkEventButton *ev)
1616 assert (_entry.processor ());
1618 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_entry.processor());
1619 // duplicated code :(
1620 // consider some tweaks to pass this up to the DnDVBox somehow:
1621 // select processor, then call (private)
1622 //_entry._parent->processor_button_press_event (ev, &_entry);
1623 if (pi && pi->plugin() && pi->plugin()->has_inline_display()
1624 && Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)
1626 && ev->type == GDK_2BUTTON_PRESS) {
1627 _entry.toggle_inline_display_visibility ();
1630 else if (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS)) {
1631 if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
1632 _entry._parent->generic_edit_processor (_entry.processor ());
1634 _entry._parent->edit_processor (_entry.processor ());
1642 ProcessorEntry::PluginInlineDisplay::on_size_request (Requisition* req)
1645 req->height = _cur_height;
1650 ProcessorEntry::PluginInlineDisplay::update_height_alloc (uint32_t inline_height)
1652 /* work-around scroll-bar + aspect ratio
1653 * show inline-view -> height changes -> scrollbar gets added
1654 * -> width changes -> inline-view, fixed aspect ratio -> height changes
1655 * -> scroll bar is removed [-> width changes ; repeat ]
1657 uint32_t shm = std::min (_max_height, inline_height);
1659 Gtk::Container* pr = get_parent();
1660 for (uint32_t i = 0; i < 4 && pr; ++i) {
1661 // VBox, EventBox, ViewPort, ScrolledWindow
1662 pr = pr->get_parent();
1664 Gtk::ScrolledWindow* sw = dynamic_cast<Gtk::ScrolledWindow*> (pr);
1666 const Gtk::VScrollbar* vsb = sw->get_vscrollbar();
1667 sc = vsb && vsb->is_visible();
1670 if (shm != _cur_height) {
1672 if (!_scroll && sc) {
1675 _max_height = _given_max_height;
1684 ProcessorEntry::PluginInlineDisplay::display_frame (cairo_t* cr, double w, double h)
1686 Gtkmm2ext::rounded_rectangle (cr, .5, -1.5, w - 1, h + 1, 7);
1689 ProcessorEntry::LuaPluginDisplay::LuaPluginDisplay (ProcessorEntry& e, boost::shared_ptr<ARDOUR::LuaProc> p, uint32_t max_height)
1690 : PluginInlineDisplay (e, p, max_height)
1692 , _lua_render_inline (0)
1694 p->setup_lua_inline_gui (&lua_gui);
1696 lua_State* LG = lua_gui.getState ();
1697 LuaInstance::bind_cairo (LG);
1698 luabridge::LuaRef lua_render = luabridge::getGlobal (LG, "render_inline");
1699 assert (lua_render.isFunction ());
1700 _lua_render_inline = new luabridge::LuaRef (lua_render);
1703 ProcessorEntry::LuaPluginDisplay::~LuaPluginDisplay ()
1705 delete (_lua_render_inline);
1709 ProcessorEntry::LuaPluginDisplay::render_inline (cairo_t *cr, uint32_t width)
1711 Cairo::Context ctx (cr);
1713 luabridge::LuaRef rv = (*_lua_render_inline)((Cairo::Context *)&ctx, width, _max_height);
1714 lua_gui.collect_garbage_step ();
1715 if (rv.isTable ()) {
1719 } catch (luabridge::LuaException const& e) {
1721 cerr << "LuaException:" << e.what () << endl;
1728 static std::list<Gtk::TargetEntry> drop_targets()
1730 std::list<Gtk::TargetEntry> tmp;
1731 tmp.push_back (Gtk::TargetEntry ("processor")); // from processor-box to processor-box
1732 tmp.push_back (Gtk::TargetEntry ("PluginInfoPtr")); // from plugin-manager
1733 tmp.push_back (Gtk::TargetEntry ("PluginFavoritePtr")); // from sidebar
1737 static std::list<Gtk::TargetEntry> drag_targets()
1739 std::list<Gtk::TargetEntry> tmp;
1740 tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr")); // to sidebar (optional preset)
1741 tmp.push_back (Gtk::TargetEntry ("processor")); // to processor-box (copy)
1745 static std::list<Gtk::TargetEntry> drag_targets_noplugin()
1747 std::list<Gtk::TargetEntry> tmp;
1748 tmp.push_back (Gtk::TargetEntry ("processor")); // to processor box (sends, faders re-order)
1752 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
1753 ProcessorSelection& psel, MixerStrip* parent, bool owner_is_mixer)
1754 : _parent_strip (parent)
1755 , _owner_is_mixer (owner_is_mixer)
1756 , ab_direction (true)
1757 , _get_plugin_selector (get_plugin_selector)
1759 , _p_selection(psel)
1760 , processor_display (drop_targets())
1761 , _redisplay_pending (false)
1765 /* ProcessorBox actions and bindings created statically by call to
1766 * ProcessorBox::register_actions(), made by ARDOUR_UI so that actions
1767 * are available for context menus.
1770 processor_display.set_data ("ardour-bindings", bindings);
1774 no_processor_redisplay = false;
1776 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
1777 processor_scroller.add (processor_display);
1778 pack_start (processor_scroller, true, true);
1780 processor_display.set_flags (CAN_FOCUS);
1781 processor_display.set_name ("ProcessorList");
1782 processor_display.set_data ("processorbox", this);
1783 processor_display.set_size_request (48, -1);
1784 processor_display.set_spacing (0);
1786 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
1787 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
1789 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
1790 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
1792 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
1793 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
1794 processor_display.DropFromExternal.connect (sigc::mem_fun (*this, &ProcessorBox::plugin_drop));
1796 processor_scroller.show ();
1797 processor_display.show ();
1800 parent->DeliveryChanged.connect (
1801 _mixer_strip_connections, invalidator (*this), boost::bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
1805 set_tooltip (processor_display, _("Right-click to add/remove/edit\nplugins,inserts,sends and more"));
1808 ProcessorBox::~ProcessorBox ()
1810 /* it may appear as if we should delete processor_menu but that is a
1811 * pointer to a widget owned by the UI Manager, and has potentially
1812 * be returned to many other ProcessorBoxes. GTK doesn't really make
1813 * clear the ownership of this widget, which is a menu and thus is
1814 * never packed into any container other than an implict GtkWindow.
1816 * For now, until or if we ever get clarification over the ownership
1817 * story just let it continue to exist. At worst, its a small memory leak.
1822 ProcessorBox::set_route (boost::shared_ptr<Route> r)
1828 _route_connections.drop_connections();
1830 /* new route: any existing block on processor redisplay must be meaningless */
1831 no_processor_redisplay = false;
1834 _route->processors_changed.connect (
1835 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
1838 _route->DropReferences.connect (
1839 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
1842 _route->PropertyChanged.connect (
1843 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
1846 redisplay_processors ();
1850 ProcessorBox::route_going_away ()
1852 no_processor_redisplay = true;
1853 processor_display.clear ();
1857 boost::shared_ptr<Processor>
1858 ProcessorBox::find_drop_position (ProcessorEntry* position)
1860 boost::shared_ptr<Processor> p;
1862 p = position->processor ();
1864 /* dropped on the blank entry (which will be before the
1865 fader), so use the first non-blank child as our
1866 `dropped on' processor */
1867 list<ProcessorEntry*> c = processor_display.children ();
1868 list<ProcessorEntry*>::iterator i = c.begin ();
1870 assert (i != c.end ());
1871 p = (*i)->processor ();
1879 ProcessorBox::_drop_plugin_preset (Gtk::SelectionData const &data, Route::ProcessorList &pl)
1881 const void * d = data.get_data();
1882 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
1884 PluginPresetList nfos;
1886 tv->get_object_drag_data (nfos, &source);
1888 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1889 PluginPresetPtr ppp = (*i);
1890 PluginInfoPtr pip = ppp->_pip;
1891 PluginPtr p = pip->load (*_session);
1896 if (ppp->_preset.valid) {
1897 p->load_preset (ppp->_preset);
1900 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
1901 if (Config->get_new_plugins_active ()) {
1902 processor->enable (true);
1904 pl.push_back (processor);
1909 ProcessorBox::_drop_plugin (Gtk::SelectionData const &data, Route::ProcessorList &pl)
1911 const void * d = data.get_data();
1912 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>*>(d);
1913 PluginInfoList nfos;
1916 tv->get_object_drag_data (nfos, &source);
1918 for (list<PluginInfoPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1919 PluginPtr p = (*i)->load (*_session);
1923 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
1924 if (Config->get_new_plugins_active ()) {
1925 processor->enable (true);
1927 pl.push_back (processor);
1932 ProcessorBox::plugin_drop (Gtk::SelectionData const &data, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
1938 boost::shared_ptr<Processor> p = find_drop_position (position);
1939 Route::ProcessorList pl;
1941 if (data.get_target() == "PluginInfoPtr") {
1942 _drop_plugin (data, pl);
1944 else if (data.get_target() == "PluginFavoritePtr") {
1945 _drop_plugin_preset (data, pl);
1951 Route::ProcessorStreams err;
1952 if (_route->add_processors (pl, p, &err)) {
1954 "Processor Drag/Drop failed. Probably because\n\
1955 the I/O configuration of the plugins could\n\
1956 not match the configuration of this track.");
1957 MessageDialog am (msg);
1963 ProcessorBox::object_drop (DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
1965 if (Gdk::ACTION_LINK == context->get_selected_action()) {
1966 list<ProcessorEntry*> children = source->selection ();
1967 assert (children.size() == 1);
1968 ProcessorEntry* other = *children.begin();
1969 assert (other->can_copy_state (position));
1970 boost::shared_ptr<ARDOUR::Processor> otherproc = other->processor();
1971 boost::shared_ptr<ARDOUR::Processor> proc = position->processor();
1972 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (proc);
1973 assert (otherproc && proc && pi);
1975 PBD::ID id = pi->id();
1976 XMLNode& state = otherproc->get_state ();
1977 /* strip side-chain state (processor inside processor must be a side-chain)
1978 * otherwise we'll end up with duplicate ports-names.
1979 * (this needs a better solution which retains connections)
1981 state.remove_nodes_and_delete ("Processor");
1982 proc->set_state (state, Stateful::loading_state_version);
1983 boost::dynamic_pointer_cast<PluginInsert>(proc)->update_id (id);
1987 boost::shared_ptr<Processor> p = find_drop_position (position);
1989 list<ProcessorEntry*> children = source->selection (true);
1990 list<boost::shared_ptr<Processor> > procs;
1991 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
1992 if ((*i)->processor ()) {
1993 if (boost::dynamic_pointer_cast<UnknownProcessor> ((*i)->processor())) {
1996 if (boost::dynamic_pointer_cast<PortInsert> ((*i)->processor())) {
1999 procs.push_back ((*i)->processor ());
2003 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
2004 XMLNode& state = (*i)->get_state ();
2006 nlist.push_back (&state);
2007 paste_processor_state (nlist, p);
2011 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
2015 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
2016 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
2018 other->delete_dragged_processors (procs);
2024 ProcessorBox::set_width (Width w)
2032 list<ProcessorEntry*> children = processor_display.children ();
2033 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2034 (*i)->set_enum_width (w);
2041 ProcessorBox::build_possible_aux_menu ()
2043 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
2046 /* No aux sends if there are no busses */
2050 if (_route->is_monitor () || _route->is_foldbackbus ()) {
2054 using namespace Menu_Helpers;
2055 Menu* menu = manage (new Menu);
2056 MenuList& items = menu->items();
2058 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
2059 if ((*r)->is_master() || (*r)->is_monitor () || *r == _route) {
2060 /* don't allow sending to master or monitor or to self */
2063 if ((*r)->is_foldbackbus ()) {
2066 if (_route->internal_send_for (*r)) {
2067 /* aux-send to target already exists */
2070 items.push_back (MenuElemNoMnemonic ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
2077 ProcessorBox::build_possible_listener_menu ()
2079 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
2082 /* No aux sends if there are no busses */
2086 if (_route->is_monitor () || _route->is_foldbackbus ()) {
2090 using namespace Menu_Helpers;
2091 Menu* menu = manage (new Menu);
2092 MenuList& items = menu->items();
2094 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
2095 if ((*r)->is_master() || (*r)->is_monitor () || *r == _route) {
2096 /* don't allow sending to master or monitor or to self */
2099 if (!(*r)->is_foldbackbus ()) {
2102 if (_route->internal_send_for (*r)) {
2103 /* aux-send to target already exists */
2106 items.push_back (MenuElemNoMnemonic ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
2113 ProcessorBox::build_possible_remove_listener_menu ()
2115 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
2118 /* No aux sends if there are no busses */
2122 if (_route->is_monitor () || _route->is_foldbackbus ()) {
2126 using namespace Menu_Helpers;
2127 Menu* menu = manage (new Menu);
2128 MenuList& items = menu->items();
2130 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
2131 if ((*r)->is_master() || (*r)->is_monitor () || *r == _route) {
2132 /* don't allow sending to master or monitor or to self */
2135 if (!(*r)->is_foldbackbus ()) {
2138 if (!_route->internal_send_for (*r)) {
2139 /* aux-send to target already exists */
2142 items.push_back (MenuElemNoMnemonic ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_remove_aux), boost::weak_ptr<Route>(*r))));
2149 ProcessorBox::show_processor_menu (int arg)
2151 if (processor_menu == 0) {
2152 processor_menu = build_processor_menu ();
2153 processor_menu->signal_unmap().connect (sigc::mem_fun (*this, &ProcessorBox::processor_menu_unmapped));
2156 /* Sort out the plugin submenu */
2158 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newplugin"));
2160 if (plugin_menu_item) {
2161 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
2164 /* And the aux submenu */
2166 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newaux"));
2168 if (aux_menu_item) {
2169 Menu* m = build_possible_aux_menu();
2170 if (m && !m->items().empty()) {
2171 aux_menu_item->set_submenu (*m);
2172 aux_menu_item->set_sensitive (true);
2175 /* stupid gtkmm: we need to pass a null reference here */
2176 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
2177 aux_menu_item->set_sensitive (false);
2181 Gtk::MenuItem* listen_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newlisten"));
2183 if (listen_menu_item) {
2184 Menu* m = build_possible_listener_menu();
2185 if (m && !m->items().empty()) {
2186 listen_menu_item->set_submenu (*m);
2187 listen_menu_item->set_sensitive (true);
2190 /* stupid gtkmm: we need to pass a null reference here */
2191 gtk_menu_item_set_submenu (listen_menu_item->gobj(), 0);
2192 listen_menu_item->set_sensitive (false);
2196 Gtk::MenuItem* remove_listen_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/removelisten"));
2198 if (remove_listen_menu_item) {
2199 Menu* m = build_possible_remove_listener_menu();
2200 if (m && !m->items().empty()) {
2201 remove_listen_menu_item->set_submenu (*m);
2202 remove_listen_menu_item->set_sensitive (true);
2205 /* stupid gtkmm: we need to pass a null reference here */
2206 gtk_menu_item_set_submenu (remove_listen_menu_item->gobj(), 0);
2207 remove_listen_menu_item->set_sensitive (false);
2211 ActionManager::get_action (X_("ProcessorMenu"), "newinsert")->set_sensitive (!_route->is_monitor () && !_route->is_foldbackbus ());
2212 ActionManager::get_action (X_("ProcessorMenu"), "newsend")->set_sensitive (!_route->is_monitor () && !_route->is_foldbackbus ());
2214 ProcessorEntry* single_selection = 0;
2215 if (processor_display.selection().size() == 1) {
2216 single_selection = processor_display.selection().front();
2219 /* And the controls submenu */
2221 Gtk::MenuItem* controls_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/controls"));
2223 if (controls_menu_item) {
2224 if (single_selection) {
2225 Menu* m = single_selection->build_controls_menu ();
2226 if (m && !m->items().empty()) {
2227 controls_menu_item->set_submenu (*m);
2228 controls_menu_item->set_sensitive (true);
2231 gtk_menu_item_set_submenu (controls_menu_item->gobj(), 0);
2232 controls_menu_item->set_sensitive (false);
2235 controls_menu_item->set_sensitive (false);
2240 Gtk::MenuItem* send_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/send_options"));
2241 if (send_menu_item) {
2242 if (single_selection && !_route->is_monitor()) {
2243 Menu* m = single_selection->build_send_options_menu ();
2244 if (m && !m->items().empty()) {
2245 send_menu_item->set_submenu (*m);
2246 send_menu_item->set_sensitive (true);
2249 gtk_menu_item_set_submenu (send_menu_item->gobj(), 0);
2250 send_menu_item->set_sensitive (false);
2253 send_menu_item->set_sensitive (false);
2257 /* Sensitise actions as approprioate */
2259 const bool sensitive = !processor_display.selection().empty() && ! stub_processor_selected ();
2261 paste_action->set_sensitive (!_p_selection.processors.empty());
2262 cut_action->set_sensitive (sensitive && can_cut ());
2263 copy_action->set_sensitive (sensitive);
2264 delete_action->set_sensitive (sensitive || stub_processor_selected ());
2265 backspace_action->set_sensitive (sensitive || stub_processor_selected ());
2267 edit_action->set_sensitive (one_processor_can_be_edited ());
2268 edit_generic_action->set_sensitive (one_processor_can_be_edited ());
2270 boost::shared_ptr<PluginInsert> pi;
2271 if (single_selection) {
2272 pi = boost::dynamic_pointer_cast<PluginInsert> (single_selection->processor ());
2275 manage_pins_action->set_sensitive (pi != 0);
2276 if (boost::dynamic_pointer_cast<Track>(_route)) {
2277 disk_io_action->set_sensitive (true);
2279 disk_io_action->set_sensitive (false);
2282 /* allow editing with an Ardour-generated UI for plugin inserts with editors */
2283 edit_action->set_sensitive (pi && pi->plugin()->has_editor ());
2285 /* disallow rename for multiple selections, for plugin inserts and for the fader */
2286 rename_action->set_sensitive (single_selection
2288 && !boost::dynamic_pointer_cast<Amp> (single_selection->processor ())
2289 && !boost::dynamic_pointer_cast<UnknownProcessor> (single_selection->processor ()));
2291 processor_menu->popup (1, arg);
2293 /* Add a placeholder gap to the processor list to indicate where a processor would be
2294 inserted were one chosen from the menu.
2297 processor_display.get_pointer (x, y);
2298 _placement = processor_display.add_placeholder (y);
2302 ProcessorBox::enter_notify (GdkEventCrossing*)
2304 processor_display.grab_focus ();
2305 _current_processor_box = this;
2310 ProcessorBox::leave_notify (GdkEventCrossing* ev)
2312 if (ev->detail == GDK_NOTIFY_INFERIOR) {
2316 Widget* top = get_toplevel();
2318 if (top->is_toplevel()) {
2319 Window* win = dynamic_cast<Window*> (top);
2320 gtk_window_set_focus (win->gobj(), 0);
2327 ProcessorBox::processor_operation (ProcessorOperation op)
2329 ProcSelection targets;
2331 get_selected_processors (targets);
2333 /* if (targets.empty()) {
2336 processor_display.get_pointer (x, y);
2338 pair<ProcessorEntry *, double> const pointer = processor_display.get_child_at_position (y);
2340 if (pointer.first && pointer.first->processor()) {
2341 targets.push_back (pointer.first->processor ());
2346 if ((op == ProcessorsDelete) && targets.empty()) {
2347 return false; //nothing to delete. return false so the editor-mixer, because the user was probably intending to delete something in the editor
2351 case ProcessorsSelectAll:
2352 processor_display.select_all ();
2355 case ProcessorsSelectNone:
2356 processor_display.select_none ();
2359 case ProcessorsCopy:
2360 copy_processors (targets);
2364 cut_processors (targets);
2367 case ProcessorsPaste:
2368 // some processors are not selectable (e.g fader, meter), target is empty.
2369 if (targets.empty() && _placement >= 0) {
2371 boost::shared_ptr<Processor> proc = _route->before_processor_for_index (_placement);
2373 targets.push_back (proc);
2376 if (targets.empty()) {
2377 paste_processors ();
2379 paste_processors (targets.front());
2383 case ProcessorsDelete:
2384 delete_processors (targets);
2387 case ProcessorsToggleActive:
2388 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
2389 if (!(*i)->display_to_user ()) {
2390 assert (0); // these should not be selectable to begin with.
2393 if (!boost::dynamic_pointer_cast<PluginInsert> (*i)) {
2397 if (boost::dynamic_pointer_cast<PluginInsert> (*i)->is_channelstrip()) {
2401 (*i)->enable (!(*i)->enabled ());
2416 ProcessorWindowProxy*
2417 ProcessorBox::find_window_proxy (boost::shared_ptr<Processor> processor) const
2419 return processor->window_proxy();
2424 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
2426 boost::shared_ptr<Processor> processor;
2428 processor = child->processor ();
2432 bool selected = processor_display.selected (child);
2434 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (processor);
2435 if (pi && pi->plugin() && pi->plugin()->has_inline_display()
2436 && Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)
2438 && ev->type == GDK_2BUTTON_PRESS) {
2439 child->toggle_inline_display_visibility ();
2443 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
2445 if (!one_processor_can_be_edited ()) {
2448 if (!ARDOUR_UI_UTILS::engine_is_running ()) {
2452 if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
2453 generic_edit_processor (processor);
2455 edit_processor (processor);
2460 } else if (Keyboard::is_context_menu_event (ev)) {
2462 show_processor_menu (ev->time);
2466 } else if (processor && ev->button == 1 && selected) {
2468 // this is purely informational but necessary for route params UI
2469 ProcessorSelected (processor); // emit
2471 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
2474 _get_plugin_selector()->show_manager ();
2481 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
2483 boost::shared_ptr<Processor> processor;
2485 processor = child->processor ();
2488 if (processor && Keyboard::is_delete_event (ev)) {
2490 Glib::signal_idle().connect (sigc::bind (
2491 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
2492 boost::weak_ptr<Processor>(processor)));
2494 } else if (processor && Keyboard::is_button2_event (ev)
2496 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
2500 /* button2-click with no/appropriate modifiers */
2501 processor->enable (!processor->enabled ());
2508 ProcessorBox::build_processor_menu ()
2510 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/ProcessorMenu") );
2511 processor_menu->set_name ("ArdourContextMenu");
2512 return processor_menu;
2516 ProcessorBox::select_all_processors ()
2518 processor_display.select_all ();
2522 ProcessorBox::deselect_all_processors ()
2524 processor_display.select_none ();
2528 ProcessorBox::choose_plugin ()
2530 _get_plugin_selector()->set_interested_object (*this);
2533 /** @return true if an error occurred, otherwise false */
2535 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
2537 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
2539 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
2541 Route::ProcessorStreams err_streams;
2543 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
2544 weird_plugin_dialog (**p, err_streams);
2546 // XXX SHAREDPTR delete plugin here .. do we even need to care?
2547 } else if (plugins.size() == 1 && UIConfiguration::instance().get_open_gui_after_adding_plugin()) {
2548 if (processor->what_can_be_automated ().size () == 0) {
2549 ; /* plugin without controls, don't show ui */
2551 else if (boost::dynamic_pointer_cast<PluginInsert>(processor)->plugin()->has_inline_display() && UIConfiguration::instance().get_prefer_inline_over_gui()) {
2552 ; /* only show inline display */
2554 else if (processor_can_be_edited (processor)) {
2555 if (!ARDOUR_UI_UTILS::engine_is_running()) {
2557 } else if ((*p)->has_editor ()) {
2558 edit_processor (processor);
2559 } else if (boost::dynamic_pointer_cast<PluginInsert>(processor)->plugin()->parameter_count() > 0) {
2560 generic_edit_processor (processor);
2564 /* add next processor below the currently added.
2565 * Note: placement < 0: add the bottom */
2566 if (_placement >= 0) {
2575 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
2577 /* XXX this needs to be re-worked!
2579 * With new pin-management "streams" is no longer correct.
2580 * p.get_info () is also incorrect for variable i/o plugins (always -1,-1).
2582 * Since pin-management was added, this dialog will only show in a very rare
2583 * condition (non-replicated variable i/o configuration failed).
2585 * TODO: simplify the message after the string-freeze is lifted.
2587 ArdourDialog dialog (_("Plugin Incompatibility"));
2590 string text = string_compose(_("You attempted to add the plugin \"%1\" in slot %2.\n"),
2591 p.name(), streams.index);
2593 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
2594 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
2596 text += _("\nThis plugin has:\n");
2598 uint32_t const n = p.get_info()->n_inputs.n_midi ();
2599 text += string_compose (ngettext ("\t%1 MIDI input\n", "\t%1 MIDI inputs\n", n), n);
2602 uint32_t const n = p.get_info()->n_inputs.n_audio ();
2603 text += string_compose (ngettext ("\t%1 audio input\n", "\t%1 audio inputs\n", n), n);
2606 text += _("\nbut at the insertion point, there are:\n");
2608 uint32_t const n = streams.count.n_midi ();
2609 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
2612 uint32_t const n = streams.count.n_audio ();
2613 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
2616 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
2617 label.set_text(text);
2619 dialog.get_vbox()->pack_start (label);
2620 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
2622 dialog.set_name (X_("PluginIODialog"));
2623 dialog.set_modal (true);
2630 ProcessorBox::choose_insert ()
2632 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->pannable(), _route->mute_master()));
2633 _route->add_processor_by_index (processor, _placement);
2636 /* Caller must not hold process lock */
2638 ProcessorBox::choose_send ()
2640 boost::shared_ptr<Send> send (new Send (*_session, _route->pannable (), _route->mute_master()));
2642 /* make an educated guess at the initial number of outputs for the send */
2643 ChanCount outs = (_route->n_outputs().n_audio() && _session->master_out())
2644 ? _session->master_out()->n_outputs()
2645 : _route->n_outputs();
2647 /* XXX need processor lock on route */
2649 Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock());
2650 send->output()->ensure_io (outs, false, this);
2651 } catch (AudioEngine::PortRegistrationFailure& err) {
2652 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
2656 /* let the user adjust the IO setup before creation.
2658 Note: this dialog is NOT modal - we just leave it to run and it will
2659 return when its Finished signal is emitted - typically when the window
2663 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
2666 /* keep a reference to the send so it doesn't get deleted while
2667 the IOSelectorWindow is doing its stuff
2669 _processor_being_created = send;
2671 ios->selector().Finished.connect (sigc::bind (
2672 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
2673 boost::weak_ptr<Processor>(send), ios));
2678 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
2680 boost::shared_ptr<Processor> processor (weak_processor.lock());
2682 /* drop our temporary reference to the new send */
2683 _processor_being_created.reset ();
2690 case IOSelector::Cancelled:
2691 // processor will go away when all shared_ptrs to it vanish
2694 case IOSelector::Accepted:
2695 _route->add_processor_by_index (processor, _placement);
2699 delete_when_idle (ios);
2703 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
2705 boost::shared_ptr<Processor> processor (weak_processor.lock());
2707 /* drop our temporary reference to the new return */
2708 _processor_being_created.reset ();
2715 case IOSelector::Cancelled:
2716 // processor will go away when all shared_ptrs to it vanish
2719 case IOSelector::Accepted:
2720 _route->add_processor_by_index (processor, _placement);
2724 delete_when_idle (ios);
2728 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
2734 boost::shared_ptr<Route> target = wr.lock();
2740 if (target->is_foldbackbus ()) {
2741 _route->add_foldback_send (target);
2743 _session->add_internal_send (target, _placement, _route);
2748 ProcessorBox::remove_aux (boost::weak_ptr<Route> wr)
2754 boost::shared_ptr<Route> target = wr.lock();
2759 boost::shared_ptr<Send> send = _route->internal_send_for (target);
2760 boost::shared_ptr<Processor> proc = boost::dynamic_pointer_cast<Processor> (send);
2761 _route->remove_processor (proc);
2766 ProcessorBox::route_processors_changed (RouteProcessorChange c)
2768 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
2769 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
2773 redisplay_processors ();
2777 ProcessorBox::redisplay_processors ()
2779 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors);
2781 if (no_processor_redisplay) {
2785 processor_display.clear ();
2787 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
2788 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
2789 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_pin_mgr));
2791 setup_entry_positions ();
2794 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
2795 * not already have one.
2798 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
2800 boost::shared_ptr<Processor> p = w.lock ();
2804 if (p->window_proxy()) {
2808 /* see also ProcessorBox::get_editor_window */
2809 bool have_ui = false;
2811 if (boost::dynamic_pointer_cast<PluginInsert> (p)) {
2814 else if (boost::dynamic_pointer_cast<PortInsert> (p)) {
2817 else if (boost::dynamic_pointer_cast<Send> (p)) {
2818 if (!boost::dynamic_pointer_cast<InternalSend> (p)) {
2822 else if (boost::dynamic_pointer_cast<Return> (p)) {
2823 if (!boost::dynamic_pointer_cast<InternalReturn> (p)) {
2832 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
2833 string_compose ("P-%1-%2", _route->id(), p->id()),
2837 const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
2840 wp->set_state (*ui_xml, 0);
2843 p->set_window_proxy (wp);
2844 WM::Manager::instance().register_window (wp);
2848 ProcessorBox::maybe_add_processor_pin_mgr (boost::weak_ptr<Processor> w)
2850 boost::shared_ptr<Processor> p = w.lock ();
2851 if (!p || p->pinmgr_proxy ()) {
2854 if (!boost::dynamic_pointer_cast<PluginInsert> (p)) {
2858 PluginPinWindowProxy* wp = new PluginPinWindowProxy (
2859 string_compose ("PM-%1-%2", _route->id(), p->id()), w);
2860 wp->set_session (_session);
2862 const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
2864 wp->set_state (*ui_xml, 0);
2867 p->set_pingmgr_proxy (wp);
2868 WM::Manager::instance().register_window (wp);
2872 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
2874 boost::shared_ptr<Processor> processor (p.lock ());
2876 if (!processor || ( !processor->display_to_user()
2878 && !show_all_processors
2885 boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
2887 ProcessorEntry* e = 0;
2888 if (plugin_insert) {
2889 e = new PluginInsertProcessorEntry (this, plugin_insert, _width);
2891 e = new ProcessorEntry (this, processor, _width);
2894 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
2895 boost::shared_ptr<PortInsert> ext = boost::dynamic_pointer_cast<PortInsert> (processor);
2896 boost::shared_ptr<UnknownProcessor> stub = boost::dynamic_pointer_cast<UnknownProcessor> (processor);
2898 //faders and meters are not deletable, copy/paste-able, so they shouldn't be selectable
2899 if (!send && !plugin_insert && !ext && !stub)
2900 e->set_selectable(false);
2902 bool mark_send_visible = false;
2903 if (send && _parent_strip) {
2904 /* show controls of new sends by default */
2905 GUIObjectState& st = _parent_strip->gui_object_state ();
2906 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
2908 /* check if state exists, if not it must be a new send */
2909 if (!st.get_node(strip, e->state_id())) {
2910 mark_send_visible = true;
2914 /* Set up this entry's state from the GUIObjectState */
2915 XMLNode* proc = entry_gui_object_state (e);
2917 e->set_control_state (proc);
2920 if (mark_send_visible) {
2921 e->show_all_controls ();
2926 && !plugin_insert->plugin(0)->is_channelstrip()
2930 processor_display.add_child (e, drag_targets());
2932 processor_display.add_child (e, drag_targets_noplugin());
2937 ProcessorBox::reordered ()
2939 compute_processor_sort_keys ();
2940 setup_entry_positions ();
2944 ProcessorBox::setup_routing_feeds ()
2946 list<ProcessorEntry*> children = processor_display.children ();
2947 /* first set the i/o maps for every processor */
2948 list<ProcessorEntry*>::iterator prev = children.begin();
2950 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2951 boost::shared_ptr<ARDOUR::Processor> p = (*i)->processor();
2952 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (p);
2954 list<ProcessorEntry*>::iterator next = i;
2958 ChanCount sinks = pi->natural_input_streams ();
2959 ChanCount sources = pi->natural_output_streams ();
2960 uint32_t count = pi->get_count ();
2962 pi->configured_io (in, out);
2964 ChanCount midi_thru;
2965 ChanCount midi_bypass;
2966 ChanMapping input_map (pi->input_map ());
2967 if (pi->has_midi_thru ()) {
2968 midi_thru.set(DataType::MIDI, 1);
2969 input_map.set (DataType::MIDI, 0, 0);
2971 if (pi->has_midi_bypass ()) {
2972 midi_bypass.set(DataType::MIDI, 1);
2975 (*i)->input_icon.set_ports (sinks * count + midi_thru);
2976 (*i)->output_icon.set_ports (sources * count + midi_bypass);
2978 (*i)->routing_icon.set (
2980 sinks * count + midi_thru,
2981 sources * count + midi_bypass,
2986 if (next != children.end()) {
2987 (*next)->routing_icon.set_fed_by (out, sources * count + midi_bypass,
2988 pi->output_map (), pi->thru_map ());
2992 (*prev)->routing_icon.set_feeding (in, sinks * count + midi_thru,
2993 pi->input_map (), pi->thru_map ());
2997 (*i)->input_icon.set_ports (p->input_streams());
2998 (*i)->output_icon.set_ports (p->output_streams());
2999 ChanMapping inmap (p->input_streams ());
3000 ChanMapping outmap (p->output_streams ());
3001 ChanMapping thrumap;
3002 (*i)->routing_icon.set (
3004 p->output_streams(),
3006 p->output_streams(),
3007 inmap, outmap, thrumap);
3009 if (next != children.end()) {
3010 (*next)->routing_icon.set_fed_by (
3011 p->output_streams(),
3012 p->output_streams(),
3016 (*prev)->routing_icon.set_feeding (
3018 p->output_streams(),
3023 if (i == children.begin()) {
3024 (*i)->routing_icon.unset_fed_by ();
3027 (*i)->input_icon.hide();
3030 /* now set which icons need to be displayed */
3031 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
3032 (*i)->output_routing_icon.copy_state ((*i)->routing_icon);
3034 if ((*i)->routing_icon.in_identity ()) {
3035 (*i)->routing_icon.hide();
3036 if (i == children.begin()) {
3037 (*i)->input_icon.show();
3040 (*i)->routing_icon.show();
3041 (*i)->routing_icon.queue_draw();
3042 (*i)->input_icon.show();
3045 list<ProcessorEntry*>::iterator next = i;
3046 if (++next == children.end()) {
3047 // last processor in the chain
3048 (*i)->output_routing_icon.set_terminal(true);
3049 (*i)->output_routing_icon.unset_feeding ();
3050 if ((*i)->routing_icon.out_identity ()) {
3051 (*i)->output_routing_icon.hide();
3053 (*i)->output_routing_icon.show();
3054 (*i)->output_routing_icon.queue_draw();
3057 (*i)->output_routing_icon.set_terminal(false);
3058 if ( !(*i)->routing_icon.out_identity ()
3059 && !(*next)->routing_icon.in_identity ()
3060 && (*next)->routing_icon.can_coalesce ()) {
3061 (*i)->output_routing_icon.hide();
3062 } else if (!(*i)->routing_icon.out_identity ()) {
3063 (*i)->output_routing_icon.show();
3064 (*i)->output_routing_icon.queue_draw();
3065 (*next)->input_icon.show();
3067 (*i)->output_routing_icon.hide();
3074 ProcessorBox::setup_entry_positions ()
3076 list<ProcessorEntry*> children = processor_display.children ();
3077 bool pre_fader = true;
3080 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
3081 if (boost::dynamic_pointer_cast<Amp>((*i)->processor()) &&
3082 boost::dynamic_pointer_cast<Amp>((*i)->processor())->gain_control()->parameter().type() == GainAutomation) {
3084 (*i)->set_position (ProcessorEntry::Fader, num++);
3087 (*i)->set_position (ProcessorEntry::PreFader, num++);
3089 (*i)->set_position (ProcessorEntry::PostFader, num++);
3093 setup_routing_feeds ();
3097 ProcessorBox::compute_processor_sort_keys ()
3099 list<ProcessorEntry*> children = processor_display.children ();
3100 Route::ProcessorList our_processors;
3102 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
3103 if ((*i)->processor()) {
3104 our_processors.push_back ((*i)->processor ());
3108 if (_route->reorder_processors (our_processors)) {
3109 /* Reorder failed, so report this to the user. As far as I can see this must be done
3110 in an idle handler: it seems that the redisplay_processors() that happens below destroys
3111 widgets that were involved in the drag-and-drop on the processor list, which causes problems
3112 when the drag is torn down after this handler function is finished.
3114 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
3119 ProcessorBox::report_failed_reorder ()
3121 /* reorder failed, so redisplay */
3123 redisplay_processors ();
3125 /* now tell them about the problem */
3127 ArdourDialog dialog (_("Plugin Incompatibility"));
3130 label.set_text (_("\
3131 You cannot reorder these plugins/sends/inserts\n\
3132 in that way because the inputs and\n\
3133 outputs will not work correctly."));
3135 dialog.get_vbox()->set_border_width (12);
3136 dialog.get_vbox()->pack_start (label);
3137 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
3139 dialog.set_name (X_("PluginIODialog"));
3140 dialog.set_modal (true);
3147 ProcessorBox::rename_processors ()
3149 ProcSelection to_be_renamed;
3151 get_selected_processors (to_be_renamed);
3153 if (to_be_renamed.empty()) {
3157 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
3158 rename_processor (*i);
3163 ProcessorBox::can_cut () const
3165 vector<boost::shared_ptr<Processor> > sel;
3167 get_selected_processors (sel);
3169 /* cut_processors () does not cut inserts */
3171 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
3173 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
3174 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
3175 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
3184 ProcessorBox::stub_processor_selected () const
3186 vector<boost::shared_ptr<Processor> > sel;
3188 get_selected_processors (sel);
3190 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
3191 if (boost::dynamic_pointer_cast<UnknownProcessor>((*i)) != 0) {
3200 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
3202 if (to_be_removed.empty()) {
3206 XMLNode* node = new XMLNode (X_("cut"));
3207 Route::ProcessorList to_cut;
3209 no_processor_redisplay = true;
3210 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
3211 // Cut only plugins, sends and returns
3212 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
3213 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
3214 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
3216 Window* w = get_processor_ui (*i);
3222 XMLNode& child ((*i)->get_state());
3223 node->add_child_nocopy (child);
3224 to_cut.push_back (*i);
3228 if (_route->remove_processors (to_cut) != 0) {
3230 no_processor_redisplay = false;
3234 _p_selection.set (node);
3236 no_processor_redisplay = false;
3237 redisplay_processors ();
3241 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
3243 if (to_be_copied.empty()) {
3247 XMLNode* node = new XMLNode (X_("copy"));
3249 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
3250 // Copy only plugins, sends, returns
3251 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
3252 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
3253 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
3254 node->add_child_nocopy ((*i)->get_state());
3258 _p_selection.set (node);
3262 ProcessorBox::delete_processors (const ProcSelection& targets)
3264 if (targets.empty()) {
3268 no_processor_redisplay = true;
3270 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
3272 Window* w = get_processor_ui (*i);
3278 _route->remove_processor(*i);
3281 no_processor_redisplay = false;
3282 redisplay_processors ();
3286 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
3288 list<boost::shared_ptr<Processor> >::const_iterator x;
3290 no_processor_redisplay = true;
3291 for (x = procs.begin(); x != procs.end(); ++x) {
3293 Window* w = get_processor_ui (*x);
3299 _route->remove_processor(*x);
3302 no_processor_redisplay = false;
3303 redisplay_processors ();
3307 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
3309 boost::shared_ptr<Processor> processor (weak_processor.lock());
3315 /* NOT copied to _mixer.selection() */
3317 no_processor_redisplay = true;
3318 _route->remove_processor (processor);
3319 no_processor_redisplay = false;
3320 redisplay_processors ();
3326 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
3328 Prompter name_prompter (true);
3330 name_prompter.set_title (_("Rename Processor"));
3331 name_prompter.set_prompt (_("New name:"));
3332 name_prompter.set_initial_text (processor->name());
3333 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
3334 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
3335 name_prompter.show_all ();
3337 switch (name_prompter.run ()) {
3339 case Gtk::RESPONSE_ACCEPT:
3340 name_prompter.get_result (result);
3341 if (result.length()) {
3344 string test = result;
3346 while (tries < 100) {
3347 if (_session->io_name_is_legal (test)) {
3353 test = string_compose ("%1-%2", result, tries);
3357 processor->set_name (result);
3360 ARDOUR_UI::instance()->popup_error
3361 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
3371 ProcessorBox::paste_processors ()
3373 if (_p_selection.processors.empty()) {
3377 paste_processor_state (_p_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
3381 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
3384 if (_p_selection.processors.empty()) {
3388 paste_processor_state (_p_selection.processors.get_node().children(), before);
3392 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
3394 XMLNodeConstIterator niter;
3395 list<boost::shared_ptr<Processor> > copies;
3397 if (nlist.empty()) {
3401 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
3403 XMLProperty const * type = (*niter)->property ("type");
3404 XMLProperty const * role = (*niter)->property ("role");
3407 boost::shared_ptr<Processor> p;
3409 if (type->value() == "meter" ||
3410 type->value() == "main-outs" ||
3411 type->value() == "amp" ||
3412 type->value() == "intreturn") {
3413 /* do not paste meter, main outs, amp or internal returns */
3416 } else if (type->value() == "intsend") {
3418 /* aux sends are OK, but those used for
3419 * other purposes, are not.
3424 if (role->value() != "Aux") {
3428 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
3429 XMLNode n (**niter);
3430 InternalSend* s = new InternalSend (*_session, sendpan, _route->mute_master(),
3431 _route, boost::shared_ptr<Route>(), Delivery::Aux);
3433 IOProcessor::prepare_for_reset (n, s->name());
3435 if (s->set_state (n, Stateful::loading_state_version)) {
3442 } else if (type->value() == "send") {
3444 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
3445 XMLNode n (**niter);
3447 Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
3449 IOProcessor::prepare_for_reset (n, s->name());
3451 if (s->set_state (n, Stateful::loading_state_version)) {
3458 } else if (type->value() == "return") {
3460 XMLNode n (**niter);
3461 Return* r = new Return (*_session);
3463 IOProcessor::prepare_for_reset (n, r->name());
3465 if (r->set_state (n, Stateful::loading_state_version)) {
3472 } else if (type->value() == "port") {
3474 XMLNode n (**niter);
3475 PortInsert* pi = new PortInsert (*_session, _route->pannable (), _route->mute_master ());
3477 IOProcessor::prepare_for_reset (n, pi->name());
3479 if (pi->set_state (n, Stateful::loading_state_version)) {
3485 /* XXX its a bit limiting to assume that everything else
3488 p.reset (new PluginInsert (*_session));
3489 /* we can't use RAII Stateful::ForceIDRegeneration
3490 * because that'd void copying the state and wrongly bump
3491 * the state-version counter.
3492 * we need to load the state (incl external files) first and
3493 * only then update the ID)
3495 PBD::ID id = p->id();
3496 /* strip side-chain state (processor inside processor must be a side-chain)
3497 * otherwise we'll end up with duplicate ports-names.
3498 * (this needs a better solution which retains connections)
3499 * We really would want Stateful::ForceIDRegeneration here :(
3501 XMLNode state (**niter);
3502 state.remove_nodes_and_delete ("Processor");
3504 p->set_state (state, Stateful::current_state_version);
3505 boost::dynamic_pointer_cast<PluginInsert>(p)->update_id (id);
3508 copies.push_back (p);
3512 error << _("plugin insert constructor failed") << endmsg;
3516 if (copies.empty()) {
3520 if (_route->add_processors (copies, p)) {
3523 "Copying the set of processors on the clipboard failed,\n\
3524 probably because the I/O configuration of the plugins\n\
3525 could not match the configuration of this track.");
3526 MessageDialog am (msg);
3532 ProcessorBox::get_selected_processors (ProcSelection& processors) const
3534 const list<ProcessorEntry*> selection = processor_display.selection (true);
3535 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
3536 processors.push_back ((*i)->processor ());
3541 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
3543 list<ProcessorEntry*> selection = processor_display.selection ();
3544 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
3545 (this->*method) ((*i)->processor ());
3550 ProcessorBox::all_visible_processors_active (bool state)
3552 _route->all_visible_processors_active (state);
3556 ProcessorBox::ab_plugins ()
3558 _route->ab_plugins (ab_direction);
3559 ab_direction = !ab_direction;
3563 ProcessorBox::set_disk_io_position (DiskIOPoint diop)
3565 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (_route);
3567 t->set_disk_io_point (diop);
3572 ProcessorBox::clear_processors ()
3575 vector<string> choices;
3577 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
3578 "(this cannot be undone)"), _route->name());
3580 choices.push_back (_("Cancel"));
3581 choices.push_back (_("Yes, remove them all"));
3583 ArdourWidgets::Choice prompter (_("Remove processors"), prompt, choices);
3585 if (prompter.run () == 1) {
3586 _route->clear_processors (PreFader);
3587 _route->clear_processors (PostFader);
3592 ProcessorBox::clear_processors (Placement p)
3595 vector<string> choices;
3597 if (p == PreFader) {
3598 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
3599 "(this cannot be undone)"), _route->name());
3601 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
3602 "(this cannot be undone)"), _route->name());
3605 choices.push_back (_("Cancel"));
3606 choices.push_back (_("Yes, remove them all"));
3608 ArdourWidgets::Choice prompter (_("Remove processors"), prompt, choices);
3610 if (prompter.run () == 1) {
3611 _route->clear_processors (p);
3616 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
3618 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
3619 if (at && at->freeze_state() == AudioTrack::Frozen) {
3624 boost::dynamic_pointer_cast<Send> (processor) ||
3625 boost::dynamic_pointer_cast<Return> (processor) ||
3626 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
3627 boost::dynamic_pointer_cast<PortInsert> (processor)
3636 ProcessorBox::one_processor_can_be_edited ()
3638 list<ProcessorEntry*> selection = processor_display.selection ();
3639 list<ProcessorEntry*>::iterator i = selection.begin();
3640 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
3644 return (i != selection.end());
3648 ProcessorBox::get_editor_window (boost::shared_ptr<Processor> processor, bool use_custom)
3650 boost::shared_ptr<Send> send;
3651 boost::shared_ptr<InternalSend> internal_send;
3652 boost::shared_ptr<Return> retrn;
3653 boost::shared_ptr<PluginInsert> plugin_insert;
3654 boost::shared_ptr<PortInsert> port_insert;
3657 /* This method may or may not return a Window, but if it does not it
3658 * will modify the parent mixer strip appearance layout to allow
3659 * "editing" the @param processor that was passed in.
3661 * So for example, if the processor is an Amp (gain), the parent strip
3662 * will be forced back into a model where the fader controls the main gain.
3663 * If the processor is a send, then we map the send controls onto the
3666 * Plugins and others will return a window for control.
3669 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
3671 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
3676 if (boost::dynamic_pointer_cast<Amp> (processor) && boost::dynamic_pointer_cast<Amp> (processor)->gain_control()->parameter().type() == GainAutomation) {
3678 if (_parent_strip) {
3679 _parent_strip->revert_to_default_display ();
3682 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
3684 if (!ARDOUR_UI_UTILS::engine_is_running ()) {
3688 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
3690 gidget = new SendUIWindow (send, _session);
3693 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
3695 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
3696 /* no GUI for these */
3700 if (!ARDOUR_UI_UTILS::engine_is_running ()) {
3704 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
3706 ReturnUIWindow *return_ui;
3707 Window* w = get_processor_ui (retrn);
3711 return_ui = new ReturnUIWindow (retrn, _session);
3712 return_ui->set_title (retrn->name ());
3713 set_processor_ui (send, return_ui);
3716 return_ui = dynamic_cast<ReturnUIWindow *> (w);
3721 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
3723 PluginUIWindow *plugin_ui;
3725 /* these are both allowed to be null */
3727 Window* w = get_processor_ui (plugin_insert);
3730 plugin_ui = new PluginUIWindow (plugin_insert, false, use_custom);
3731 plugin_ui->set_title (generate_processor_title (plugin_insert));
3732 set_processor_ui (plugin_insert, plugin_ui);
3735 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
3740 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
3742 if (!ARDOUR_UI_UTILS::engine_is_running ()) {
3746 PortInsertWindow *io_selector;
3748 Window* w = get_processor_ui (port_insert);
3751 io_selector = new PortInsertWindow (_session, port_insert);
3752 set_processor_ui (port_insert, io_selector);
3755 io_selector = dynamic_cast<PortInsertWindow *> (w);
3758 gidget = io_selector;
3765 ProcessorBox::get_generic_editor_window (boost::shared_ptr<Processor> processor)
3767 boost::shared_ptr<PluginInsert> plugin_insert
3768 = boost::dynamic_pointer_cast<PluginInsert>(processor);
3770 if (!plugin_insert) {
3774 PluginUIWindow* win = new PluginUIWindow (plugin_insert, true, false);
3775 win->set_title (generate_processor_title (plugin_insert));
3781 ProcessorBox::register_actions ()
3783 /* We need to use a static object as the owner, since these actions
3784 need to be considered ownable by all ProcessorBox objects
3789 processor_box_actions = ActionManager::create_action_group (bindings, X_("ProcessorMenu"));
3791 Glib::RefPtr<Action> act;
3794 ActionManager::register_action (processor_box_actions, X_("newplugin"), _("New Plugin"),
3795 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
3797 act = ActionManager::register_action (processor_box_actions, X_("newinsert"), _("New Insert"),
3798 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
3799 ActionManager::engine_sensitive_actions.push_back (act);
3800 act = ActionManager::register_action (processor_box_actions, X_("newsend"), _("New External Send ..."),
3801 sigc::ptr_fun (ProcessorBox::rb_choose_send));
3802 ActionManager::engine_sensitive_actions.push_back (act);
3804 ActionManager::register_action (processor_box_actions, X_("newaux"), _("New Aux Send ..."));
3805 ActionManager::register_action (processor_box_actions, X_("newlisten"), _("New Monitor Send ..."));
3806 ActionManager::register_action (processor_box_actions, X_("removelisten"), _("Remove Monitor Send ..."));
3808 ActionManager::register_action (processor_box_actions, X_("controls"), _("Controls"));
3809 ActionManager::register_action (processor_box_actions, X_("send_options"), _("Send Options"));
3811 ActionManager::register_action (processor_box_actions, X_("clear"), _("Clear (all)"),
3812 sigc::ptr_fun (ProcessorBox::rb_clear));
3813 ActionManager::register_action (processor_box_actions, X_("clear_pre"), _("Clear (pre-fader)"),
3814 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
3815 ActionManager::register_action (processor_box_actions, X_("clear_post"), _("Clear (post-fader)"),
3816 sigc::ptr_fun (ProcessorBox::rb_clear_post));
3818 /* standard editing stuff */
3820 cut_action = ActionManager::register_action (processor_box_actions, X_("cut"), _("Cut"),
3821 sigc::ptr_fun (ProcessorBox::rb_cut));
3822 copy_action = ActionManager::register_action (processor_box_actions, X_("copy"), _("Copy"),
3823 sigc::ptr_fun (ProcessorBox::rb_copy));
3824 delete_action = ActionManager::register_action (processor_box_actions, X_("delete"), _("Delete"),
3825 sigc::ptr_fun (ProcessorBox::rb_delete));
3826 backspace_action = ActionManager::register_action (processor_box_actions, X_("backspace"), _("Delete"),
3827 sigc::ptr_fun (ProcessorBox::rb_delete));
3829 ActionManager::plugin_selection_sensitive_actions.push_back (cut_action);
3830 ActionManager::plugin_selection_sensitive_actions.push_back (copy_action);
3831 ActionManager::plugin_selection_sensitive_actions.push_back (delete_action);
3832 ActionManager::plugin_selection_sensitive_actions.push_back (backspace_action);
3834 paste_action = ActionManager::register_action (processor_box_actions, X_("paste"), _("Paste"),
3835 sigc::ptr_fun (ProcessorBox::rb_paste));
3836 rename_action = ActionManager::register_action (processor_box_actions, X_("rename"), _("Rename"),
3837 sigc::ptr_fun (ProcessorBox::rb_rename));
3838 ActionManager::register_action (processor_box_actions, X_("selectall"), _("Select All"),
3839 sigc::ptr_fun (ProcessorBox::rb_select_all));
3840 ActionManager::register_action (processor_box_actions, X_("deselectall"), _("Deselect All"),
3841 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
3843 /* activation etc. */
3845 ActionManager::register_action (processor_box_actions, X_("activate_all"), _("Activate All"),
3846 sigc::ptr_fun (ProcessorBox::rb_activate_all));
3847 ActionManager::register_action (processor_box_actions, X_("deactivate_all"), _("Deactivate All"),
3848 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
3849 ActionManager::register_action (processor_box_actions, X_("ab_plugins"), _("A/B Plugins"),
3850 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
3852 manage_pins_action = ActionManager::register_action (
3853 processor_box_actions, X_("manage-pins"), _("Pin Connections..."),
3854 sigc::ptr_fun (ProcessorBox::rb_manage_pins));
3857 disk_io_action = ActionManager::register_action (processor_box_actions, X_("disk-io-menu"), _("Disk I/O ..."));
3858 ActionManager::register_action (processor_box_actions, X_("disk-io-prefader"), _("Pre-Fader."), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_set_disk_io_position), DiskIOPreFader));
3859 ActionManager::register_action (processor_box_actions, X_("disk-io-postfader"), _("Post-Fader."), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_set_disk_io_position), DiskIOPostFader));
3860 ActionManager::register_action (processor_box_actions, X_("disk-io-custom"), _("Custom."), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_set_disk_io_position), DiskIOCustom));
3863 edit_action = ActionManager::register_action (
3864 processor_box_actions, X_("edit"), _("Edit..."),
3865 sigc::ptr_fun (ProcessorBox::rb_edit));
3867 edit_generic_action = ActionManager::register_action (
3868 processor_box_actions, X_("edit-generic"), _("Edit with generic controls..."),
3869 sigc::ptr_fun (ProcessorBox::rb_edit_generic));
3874 ProcessorBox::rb_edit_generic ()
3876 if (_current_processor_box == 0) {
3880 _current_processor_box->for_selected_processors (&ProcessorBox::generic_edit_processor);
3884 ProcessorBox::rb_ab_plugins ()
3886 if (_current_processor_box == 0) {
3890 _current_processor_box->ab_plugins ();
3894 ProcessorBox::rb_set_disk_io_position (DiskIOPoint diop)
3896 if (_current_processor_box == 0) {
3900 _current_processor_box->set_disk_io_position (diop);
3904 ProcessorBox::rb_manage_pins ()
3906 if (_current_processor_box == 0) {
3910 _current_processor_box->for_selected_processors (&ProcessorBox::manage_pins);
3913 ProcessorBox::rb_choose_plugin ()
3915 if (_current_processor_box == 0) {
3918 _current_processor_box->choose_plugin ();
3922 ProcessorBox::rb_choose_insert ()
3924 if (_current_processor_box == 0) {
3927 _current_processor_box->choose_insert ();
3931 ProcessorBox::rb_choose_send ()
3933 if (_current_processor_box == 0) {
3936 _current_processor_box->choose_send ();
3940 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
3942 if (_current_processor_box == 0) {
3946 _current_processor_box->choose_aux (wr);
3950 ProcessorBox::rb_remove_aux (boost::weak_ptr<Route> wr)
3952 if (_current_processor_box == 0) {
3956 _current_processor_box->remove_aux (wr);
3960 ProcessorBox::rb_clear ()
3962 if (_current_processor_box == 0) {
3966 _current_processor_box->clear_processors ();
3971 ProcessorBox::rb_clear_pre ()
3973 if (_current_processor_box == 0) {
3977 _current_processor_box->clear_processors (PreFader);
3982 ProcessorBox::rb_clear_post ()
3984 if (_current_processor_box == 0) {
3988 _current_processor_box->clear_processors (PostFader);
3992 ProcessorBox::rb_cut ()
3994 if (_current_processor_box == 0) {
3998 _current_processor_box->processor_operation (ProcessorsCut);
4002 ProcessorBox::rb_delete ()
4004 if (_current_processor_box == 0) {
4008 _current_processor_box->processor_operation (ProcessorsDelete);
4012 ProcessorBox::rb_copy ()
4014 if (_current_processor_box == 0) {
4017 _current_processor_box->processor_operation (ProcessorsCopy);
4021 ProcessorBox::rb_paste ()
4023 if (_current_processor_box == 0) {
4027 _current_processor_box->processor_operation (ProcessorsPaste);
4031 ProcessorBox::rb_rename ()
4033 if (_current_processor_box == 0) {
4036 _current_processor_box->rename_processors ();
4040 ProcessorBox::rb_select_all ()
4042 if (_current_processor_box == 0) {
4046 _current_processor_box->processor_operation (ProcessorsSelectAll);
4050 ProcessorBox::rb_deselect_all ()
4052 if (_current_processor_box == 0) {
4056 _current_processor_box->deselect_all_processors ();
4060 ProcessorBox::rb_activate_all ()
4062 if (_current_processor_box == 0) {
4066 _current_processor_box->all_visible_processors_active (true);
4070 ProcessorBox::rb_deactivate_all ()
4072 if (_current_processor_box == 0) {
4075 _current_processor_box->all_visible_processors_active (false);
4079 ProcessorBox::rb_edit ()
4081 if (_current_processor_box == 0) {
4085 _current_processor_box->for_selected_processors (&ProcessorBox::edit_processor);
4089 ProcessorBox::edit_aux_send (boost::shared_ptr<Processor> processor)
4091 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
4095 if (_parent_strip) {
4096 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
4097 if (_parent_strip->current_delivery() == send) {
4098 _parent_strip->revert_to_default_display ();
4100 _parent_strip->show_send(send);
4107 ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
4112 if (edit_aux_send (processor)) {
4115 if (!ARDOUR_UI_UTILS::engine_is_running ()) {
4119 ProcessorWindowProxy* proxy = find_window_proxy (processor);
4122 proxy->set_custom_ui_mode (true);
4123 proxy->show_the_right_window ();
4128 ProcessorBox::generic_edit_processor (boost::shared_ptr<Processor> processor)
4133 if (edit_aux_send (processor)) {
4136 if (!ARDOUR_UI_UTILS::engine_is_running ()) {
4140 ProcessorWindowProxy* proxy = find_window_proxy (processor);
4143 proxy->set_custom_ui_mode (false);
4144 proxy->show_the_right_window ();
4149 ProcessorBox::manage_pins (boost::shared_ptr<Processor> processor)
4154 PluginPinWindowProxy* proxy = processor->pinmgr_proxy ();
4163 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
4165 if (!what_changed.contains (ARDOUR::Properties::name)) {
4169 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
4171 boost::shared_ptr<Processor> processor;
4172 boost::shared_ptr<PluginInsert> plugin_insert;
4173 boost::shared_ptr<Send> send;
4175 list<ProcessorEntry*> children = processor_display.children();
4177 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
4179 processor = (*iter)->processor ();
4185 Window* w = get_processor_ui (processor);
4191 /* rename editor windows for sends and plugins */
4193 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
4194 w->set_title (send->name ());
4195 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
4196 w->set_title (generate_processor_title (plugin_insert));
4202 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
4204 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
4205 string::size_type email_pos;
4207 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
4208 maker = maker.substr (0, email_pos - 1);
4211 if (maker.length() > 32) {
4212 maker = maker.substr (0, 32);
4216 SessionObject* owner = pi->owner();
4219 return string_compose(_("%1: %2 (by %3)"), owner->name(), pi->name(), maker);
4221 return string_compose(_("%1 (by %2)"), pi->name(), maker);
4225 /** @param p Processor.
4226 * @return the UI window for \a p.
4229 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
4231 ProcessorWindowProxy* wp = p->window_proxy();
4238 /** Make a note of the UI window that a processor is using.
4239 * @param p Processor.
4240 * @param w UI window.
4243 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
4245 assert (p->window_proxy());
4246 p->window_proxy()->use_window (*w);
4250 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
4252 boost::shared_ptr<Delivery> d = w.lock ();
4257 list<ProcessorEntry*> children = processor_display.children ();
4258 list<ProcessorEntry*>::const_iterator i = children.begin();
4259 while (i != children.end() && (*i)->processor() != d) {
4263 if (i == children.end()) {
4264 processor_display.set_active (0);
4266 processor_display.set_active (*i);
4270 /** Called to repair the damage of Editor::show_window doing a show_all() */
4272 ProcessorBox::hide_things ()
4274 list<ProcessorEntry*> c = processor_display.children ();
4275 for (list<ProcessorEntry*>::iterator i = c.begin(); i != c.end(); ++i) {
4276 (*i)->hide_things ();
4281 ProcessorBox::processor_menu_unmapped ()
4283 processor_display.remove_placeholder ();
4284 /* make all possibly-desensitized actions sensitive again so that
4285 they be activated by other means (e.g. bindings)
4287 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, true);
4291 ProcessorBox::entry_gui_object_state (ProcessorEntry* entry)
4293 if (!_parent_strip) {
4297 GUIObjectState& st = _parent_strip->gui_object_state ();
4299 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
4301 return st.get_or_add_node (strip, entry->state_id());
4305 ProcessorBox::update_gui_object_state (ProcessorEntry* entry)
4307 XMLNode* proc = entry_gui_object_state (entry);
4312 /* XXX: this is a bit inefficient; we just remove all child nodes and re-add them */
4313 proc->remove_nodes_and_delete (X_("Object"));
4314 entry->add_control_state (proc);
4318 ProcessorBox::is_editor_mixer_strip() const
4320 return _parent_strip && !_parent_strip->mixer_owned();
4323 ProcessorWindowProxy::ProcessorWindowProxy (string const & name, ProcessorBox* box, boost::weak_ptr<Processor> processor)
4324 : WM::ProxyBase (name, string())
4325 , _processor_box (box)
4326 , _processor (processor)
4328 , want_custom (true)
4330 boost::shared_ptr<Processor> p = _processor.lock ();
4334 p->DropReferences.connect (going_away_connection, MISSING_INVALIDATOR, boost::bind (&ProcessorWindowProxy::processor_going_away, this), gui_context());
4336 p->ToggleUI.connect (gui_connections, invalidator (*this), boost::bind (&ProcessorWindowProxy::show_the_right_window, this, false), gui_context());
4337 p->ShowUI.connect (gui_connections, invalidator (*this), boost::bind (&ProcessorWindowProxy::show_the_right_window, this, true), gui_context());
4338 p->HideUI.connect (gui_connections, invalidator (*this), boost::bind (&ProcessorWindowProxy::hide, this), gui_context());
4341 ProcessorWindowProxy::~ProcessorWindowProxy()
4343 /* processor window proxies do not own the windows they create with
4344 * ::get(), so set _window to null before the normal WindowProxy method
4351 ProcessorWindowProxy::processor_going_away ()
4353 gui_connections.drop_connections ();
4356 WM::Manager::instance().remove (this);
4357 /* should be no real reason to do this, since the object that would
4358 send DropReferences is about to be deleted, but lets do it anyway.
4360 going_away_connection.disconnect();
4364 ARDOUR::SessionHandlePtr*
4365 ProcessorWindowProxy::session_handle()
4372 ProcessorWindowProxy::get_state ()
4375 node = &ProxyBase::get_state();
4376 node->set_property (X_("custom-ui"), is_custom);
4381 ProcessorWindowProxy::set_state (const XMLNode& node, int /*version*/)
4383 XMLNodeList children = node.children ();
4384 XMLNodeList::const_iterator i = children.begin ();
4385 while (i != children.end()) {
4387 if ((*i)->name() == X_("Window") && (*i)->get_property (X_("name"), name) && name == _name) {
4393 if (i != children.end()) {
4394 (*i)->get_property (X_("custom-ui"), want_custom);
4397 return ProxyBase::set_state (node, 0);
4401 ProcessorWindowProxy::get (bool create)
4403 boost::shared_ptr<Processor> p = _processor.lock ();
4408 if (_window && (is_custom != want_custom)) {
4409 /* drop existing window - wrong type */
4410 set_state_mask (Gtkmm2ext::WindowProxy::StateMask (state_mask () & ~WindowProxy::Size));
4419 is_custom = want_custom;
4420 _window = _processor_box->get_editor_window (p, is_custom);
4424 _window->show_all ();
4431 ProcessorWindowProxy::show_the_right_window (bool show_not_toggle)
4433 if (_window && (is_custom != want_custom)) {
4434 /* drop existing window - wrong type */
4435 set_state_mask (Gtkmm2ext::WindowProxy::StateMask (state_mask () & ~WindowProxy::Size));
4438 if (_window && fully_visible () && show_not_toggle) {
4445 PluginPinWindowProxy::PluginPinWindowProxy(std::string const &name, boost::weak_ptr<ARDOUR::Processor> processor)
4446 : WM::ProxyBase (name, string())
4447 , _processor (processor)
4449 boost::shared_ptr<Processor> p = _processor.lock ();
4453 p->DropReferences.connect (going_away_connection, MISSING_INVALIDATOR, boost::bind (&PluginPinWindowProxy::processor_going_away, this), gui_context());
4456 PluginPinWindowProxy::~PluginPinWindowProxy()
4461 ARDOUR::SessionHandlePtr*
4462 PluginPinWindowProxy::session_handle ()
4464 ArdourWindow* aw = dynamic_cast<ArdourWindow*> (_window);
4465 if (aw) { return aw; }
4470 PluginPinWindowProxy::get (bool create)
4472 boost::shared_ptr<Processor> p = _processor.lock ();
4473 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (p);
4482 _window = new PluginPinDialog (pi);
4483 ArdourWindow* aw = dynamic_cast<ArdourWindow*> (_window);
4485 aw->set_session (_session);
4487 _window->show_all ();
4493 PluginPinWindowProxy::processor_going_away ()
4497 WM::Manager::instance().remove (this);
4498 going_away_connection.disconnect();
4503 ProcessorBox::load_bindings ()
4505 bindings = Bindings::get_bindings (X_("Processor Box"));