2 Copyright (C) 2000-2004 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "gtk2ardour-config.h"
28 #include <sigc++/bind.h>
30 #include "pbd/convert.h"
31 #include "canvas/utils.h"
33 #include <glibmm/miscutils.h>
34 #include <glibmm/fileutils.h>
36 #include <gtkmm/messagedialog.h>
38 #include <gtkmm2ext/gtk_ui.h>
39 #include <gtkmm2ext/utils.h>
40 #include <gtkmm2ext/choice.h>
41 #include <gtkmm2ext/utils.h>
42 #include <gtkmm2ext/doi.h>
43 #include <gtkmm2ext/rgb_macros.h>
45 #include "ardour/amp.h"
46 #include "ardour/audio_track.h"
47 #include "ardour/audioengine.h"
48 #include "ardour/internal_return.h"
49 #include "ardour/internal_send.h"
50 #include "ardour/luaproc.h"
51 #include "ardour/luascripting.h"
52 #include "ardour/meter.h"
53 #include "ardour/panner_shell.h"
54 #include "ardour/plugin_insert.h"
55 #include "ardour/pannable.h"
56 #include "ardour/port_insert.h"
57 #include "ardour/profile.h"
58 #include "ardour/return.h"
59 #include "ardour/route.h"
60 #include "ardour/send.h"
61 #include "ardour/session.h"
62 #include "ardour/types.h"
64 #include "LuaBridge/LuaBridge.h"
67 #include "ardour_dialog.h"
68 #include "ardour_ui.h"
69 #include "gui_thread.h"
70 #include "io_selector.h"
72 #include "luainstance.h"
74 #include "mixer_strip.h"
75 #include "plugin_pin_dialog.h"
76 #include "plugin_selector.h"
77 #include "plugin_ui.h"
78 #include "port_insert_ui.h"
79 #include "processor_box.h"
80 #include "public_editor.h"
81 #include "return_ui.h"
82 #include "route_processor_selection.h"
83 #include "script_selector.h"
87 #include "new_plugin_preset_dialog.h"
91 #ifdef AUDIOUNIT_SUPPORT
96 bool ProcessorBox::show_all_processors = false;
100 using namespace ARDOUR;
103 using namespace Glib;
104 using namespace Gtkmm2ext;
106 ProcessorBox* ProcessorBox::_current_processor_box = 0;
107 RefPtr<Action> ProcessorBox::paste_action;
108 RefPtr<Action> ProcessorBox::cut_action;
109 RefPtr<Action> ProcessorBox::copy_action;
110 RefPtr<Action> ProcessorBox::rename_action;
111 RefPtr<Action> ProcessorBox::delete_action;
112 RefPtr<Action> ProcessorBox::manage_pins_action;
113 RefPtr<Action> ProcessorBox::edit_action;
114 RefPtr<Action> ProcessorBox::edit_generic_action;
115 RefPtr<ActionGroup> ProcessorBox::processor_box_actions;
116 Gtkmm2ext::ActionMap ProcessorBox::myactions (X_("processor box"));
117 Gtkmm2ext::Bindings* ProcessorBox::bindings = 0;
120 // TODO consolidate with PluginPinDialog::set_color
121 static void set_routing_color (cairo_t* cr, bool midi)
123 static const uint32_t audio_port_color = 0x4A8A0EFF; // Green
124 static const uint32_t midi_port_color = 0x960909FF; //Red
127 cairo_set_source_rgb (cr,
128 UINT_RGBA_R_FLT(midi_port_color),
129 UINT_RGBA_G_FLT(midi_port_color),
130 UINT_RGBA_B_FLT(midi_port_color));
132 cairo_set_source_rgb (cr,
133 UINT_RGBA_R_FLT(audio_port_color),
134 UINT_RGBA_G_FLT(audio_port_color),
135 UINT_RGBA_B_FLT(audio_port_color));
139 ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processor> p, Width w)
140 : _button (ArdourButton::led_default_elements)
141 , _position (PreFader)
145 , _unknown_processor(false)
151 , output_routing_icon(false)
156 _button.set_distinct_led_click (true);
157 _button.set_fallthrough_to_parent(true);
158 _button.set_led_left (true);
159 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &ProcessorEntry::led_clicked));
160 _button.set_text (name (_width));
162 if (boost::dynamic_pointer_cast<PeakMeter> (_processor)) {
163 _button.set_elements(ArdourButton::Element(_button.elements() & ~ArdourButton::Indicator));
165 if (boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
166 _button.set_elements(ArdourButton::Element(_button.elements() & ~ArdourButton::Indicator));
167 _unknown_processor = true;
170 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
171 if (pi && pi->plugin() && pi->plugin()->get_info()->type != ARDOUR::Lua) {
172 _plugin_preset_pointer = PluginPresetPtr (new PluginPreset (pi->plugin()->get_info()));
177 _vbox.pack_start (routing_icon);
178 _vbox.pack_start (input_icon);
179 _vbox.pack_start (_button, true, true);
181 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
182 if (pi && pi->plugin() && pi->plugin()->has_inline_display()) {
183 if (pi->plugin()->get_info()->type != ARDOUR::Lua) {
184 _plugin_display = new PluginDisplay (pi->plugin(),
185 std::max (60.f, rintf(112.f * UIConfiguration::instance().get_ui_scale())));
187 assert (boost::dynamic_pointer_cast<LuaProc>(pi->plugin()));
188 _plugin_display = new LuaPluginDisplay (boost::dynamic_pointer_cast<LuaProc>(pi->plugin()),
189 std::max (60.f, rintf(112.f * UIConfiguration::instance().get_ui_scale())));
191 _vbox.pack_start (*_plugin_display);
192 _plugin_display->set_no_show_all (true);
193 if (UIConfiguration::instance().get_show_inline_display_by_default ()) {
194 _plugin_display->show ();
197 _vbox.pack_end (output_routing_icon);
198 _vbox.pack_end (output_icon);
200 _button.set_active (_processor->active());
202 routing_icon.set_no_show_all(true);
203 input_icon.set_no_show_all(true);
209 output_routing_icon.hide();
211 _processor->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_active_changed, this), gui_context());
212 _processor->PropertyChanged.connect (name_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_property_changed, this, _1), gui_context());
213 _processor->ConfigurationChanged.connect (config_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_configuration_changed, this, _1, _2), gui_context());
215 set<Evoral::Parameter> p = _processor->what_can_be_automated ();
216 for (set<Evoral::Parameter>::iterator i = p.begin(); i != p.end(); ++i) {
218 std::string label = _processor->describe_parameter (*i);
220 if (boost::dynamic_pointer_cast<Send> (_processor)) {
222 } else if (boost::dynamic_pointer_cast<Return> (_processor)) {
226 Control* c = new Control (_processor->automation_control (*i), label);
228 _controls.push_back (c);
230 if (boost::dynamic_pointer_cast<Amp> (_processor) == 0) {
231 /* Add non-Amp (Fader & Trim) controls to the processor box */
232 _vbox.pack_start (c->box);
239 _vbox.set_size_request (-1, _button.size_request().height);
243 ProcessorEntry::~ProcessorEntry ()
245 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
248 delete _plugin_display;
252 ProcessorEntry::action_widget ()
258 ProcessorEntry::widget ()
264 ProcessorEntry::drag_text () const
270 ProcessorEntry::can_copy_state (Gtkmm2ext::DnDVBoxChild* o) const
272 ProcessorEntry *other = dynamic_cast<ProcessorEntry*> (o);
276 boost::shared_ptr<ARDOUR::Processor> otherproc = other->processor();
277 boost::shared_ptr<PluginInsert> my_pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
278 boost::shared_ptr<PluginInsert> ot_pi = boost::dynamic_pointer_cast<PluginInsert> (otherproc);
279 if (boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
282 if (boost::dynamic_pointer_cast<UnknownProcessor> (otherproc)) {
285 if (!my_pi || !ot_pi) {
288 if (my_pi->type() != ot_pi->type()) {
291 boost::shared_ptr<Plugin> my_p = my_pi->plugin();
292 boost::shared_ptr<Plugin> ot_p = ot_pi->plugin();
293 if (!my_p || !ot_p) {
296 if (my_p->unique_id() != ot_p->unique_id()) {
303 ProcessorEntry::drag_data_get (Glib::RefPtr<Gdk::DragContext> const, Gtk::SelectionData &data)
305 if (data.get_target() == "PluginPresetPtr") {
306 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
308 if (!_plugin_preset_pointer || !pi) {
309 data.set (data.get_target(), 8, NULL, 0);
313 boost::shared_ptr<ARDOUR::Plugin> plugin = pi->plugin();
316 PluginManager& manager (PluginManager::instance());
317 bool fav = manager.get_status (_plugin_preset_pointer->_pip) == PluginManager::Favorite;
319 NewPluginPresetDialog d (plugin,
320 string_compose(_("New Favorite Preset for \"%1\""),_plugin_preset_pointer->_pip->name), !fav);
322 _plugin_preset_pointer->_preset.valid = false;
325 case Gtk::RESPONSE_CANCEL:
326 data.set (data.get_target(), 8, NULL, 0);
330 case Gtk::RESPONSE_NO:
333 case Gtk::RESPONSE_ACCEPT:
334 if (d.name().empty()) {
339 plugin->remove_preset (d.name ());
342 Plugin::PresetRecord const r = plugin->save_preset (d.name());
344 if (!r.uri.empty ()) {
345 _plugin_preset_pointer->_preset.uri = r.uri;
346 _plugin_preset_pointer->_preset.label = r.label;
347 _plugin_preset_pointer->_preset.user = r.user;
348 _plugin_preset_pointer->_preset.valid = r.valid;
351 data.set (data.get_target(), 8, (const guchar *) &_plugin_preset_pointer, sizeof (PluginPresetPtr));
358 ProcessorEntry::set_position (Position p, uint32_t num)
366 ProcessorEntry::set_visual_state (Gtkmm2ext::VisualState s, bool yn)
369 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() | s));
371 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() & ~s));
376 ProcessorEntry::setup_visuals ()
378 if (_unknown_processor) {
379 _button.set_name ("processor stub");
385 if (_plugin_display) { _plugin_display->set_name ("processor prefader"); }
386 _button.set_name ("processor prefader");
390 _button.set_name ("processor fader");
394 if (_plugin_display) { _plugin_display->set_name ("processor postfader"); }
395 _button.set_name ("processor postfader");
401 boost::shared_ptr<Processor>
402 ProcessorEntry::processor () const
405 return boost::shared_ptr<Processor>();
411 ProcessorEntry::set_enum_width (Width w)
414 _button.set_text (name (_width));
418 ProcessorEntry::led_clicked(GdkEventButton *ev)
420 bool ctrl_shift_pressed = false;
421 Keyboard::ModifierMask ctrl_shift_mask = Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier);
423 if (Keyboard::modifier_state_equals (ev->state, ctrl_shift_mask)) {
424 ctrl_shift_pressed = true;
428 if (_button.get_active ()) {
429 if (ctrl_shift_pressed) {
430 _parent->all_visible_processors_active(false);
432 if (_position == Fader) {
433 _processor->deactivate ();
437 _processor->deactivate ();
441 if (ctrl_shift_pressed) {
442 _parent->all_visible_processors_active(true);
444 if (_position == Fader) {
445 _processor->activate ();
449 _processor->activate ();
456 ProcessorEntry::processor_active_changed ()
459 _button.set_active (_processor->active());
464 ProcessorEntry::processor_property_changed (const PropertyChange& what_changed)
466 if (what_changed.contains (ARDOUR::Properties::name)) {
467 _button.set_text (name (_width));
473 ProcessorEntry::processor_configuration_changed (const ChanCount in, const ChanCount out)
475 _parent->setup_routing_feeds ();
476 input_icon.queue_draw();
477 output_icon.queue_draw();
478 routing_icon.queue_draw();
479 output_routing_icon.queue_draw();
483 ProcessorEntry::setup_tooltip ()
486 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
488 std::string postfix = "";
490 if ((replicated = pi->get_count()) > 1) {
491 postfix = string_compose(_("\nThis mono plugin has been replicated %1 times."), replicated);
493 if (pi->plugin()->has_editor()) {
494 ARDOUR_UI_UTILS::set_tooltip (_button,
495 string_compose (_("<b>%1</b>\nDouble-click to show GUI.\n%2+double-click to show generic GUI.%3"), name (Wide), Keyboard::primary_modifier_name (), postfix));
497 ARDOUR_UI_UTILS::set_tooltip (_button,
498 string_compose (_("<b>%1</b>\nDouble-click to show generic GUI.%2"), name (Wide), postfix));
502 if(boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
503 ARDOUR_UI::instance()->set_tip (_button,
504 string_compose (_("<b>%1</b>\nThe Plugin is not available on this system\nand has been replaced by a stub."), name (Wide)));
508 ARDOUR_UI_UTILS::set_tooltip (_button, string_compose ("<b>%1</b>", name (Wide)));
512 ProcessorEntry::name (Width w) const
514 boost::shared_ptr<Send> send;
521 if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
522 !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
526 /* grab the send name out of its overall name */
528 string::size_type lbracket, rbracket;
529 lbracket = send->name().find ('[');
530 rbracket = send->name().find (']');
534 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
537 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
542 boost::shared_ptr<ARDOUR::PluginInsert> pi;
544 if ((pi = boost::dynamic_pointer_cast<ARDOUR::PluginInsert> (_processor)) != 0
545 && (replicated = pi->get_count()) > 1)
547 name_display += string_compose(_("(%1x1) "), replicated);
552 name_display += _processor->display_name();
555 name_display += PBD::short_version (_processor->display_name(), 5);
565 ProcessorEntry::show_all_controls ()
567 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
568 (*i)->set_visible (true);
571 _parent->update_gui_object_state (this);
575 ProcessorEntry::hide_all_controls ()
577 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
578 (*i)->set_visible (false);
581 _parent->update_gui_object_state (this);
585 ProcessorEntry::add_control_state (XMLNode* node) const
587 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
588 (*i)->add_state (node);
591 if (_plugin_display) {
592 XMLNode* c = new XMLNode (X_("Object"));
593 c->add_property (X_("id"), X_("InlineDisplay"));
594 c->add_property (X_("visible"), _plugin_display->is_visible ());
595 node->add_child_nocopy (*c);
600 ProcessorEntry::set_control_state (XMLNode const * node)
602 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
603 (*i)->set_state (node);
606 if (_plugin_display) {
607 XMLNode* n = GUIObjectState::get_node (node, X_("InlineDisplay"));
608 XMLProperty* p = n ? n->property (X_("visible")) : NULL;
610 if (string_is_affirmative (p->value ())) {
611 _plugin_display->show();
613 _plugin_display->hide();
620 ProcessorEntry::state_id () const
622 return string_compose ("processor %1", _processor->id().to_s());
626 ProcessorEntry::hide_things ()
628 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
629 (*i)->hide_things ();
635 ProcessorEntry::build_controls_menu ()
637 using namespace Menu_Helpers;
638 Menu* menu = manage (new Menu);
639 MenuList& items = menu->items ();
641 if (_plugin_display) {
642 items.push_back (CheckMenuElem (_("Inline Display")));
643 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
644 c->set_active (_plugin_display->is_visible ());
645 c->signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::toggle_inline_display_visibility));
646 items.push_back (SeparatorElem ());
650 MenuElem (_("Show All Controls"), sigc::mem_fun (*this, &ProcessorEntry::show_all_controls))
654 MenuElem (_("Hide All Controls"), sigc::mem_fun (*this, &ProcessorEntry::hide_all_controls))
657 if (!_controls.empty ()) {
658 items.push_back (SeparatorElem ());
661 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
662 items.push_back (CheckMenuElem ((*i)->name ()));
663 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
664 c->set_active ((*i)->visible ());
665 c->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &ProcessorEntry::toggle_control_visibility), *i));
672 ProcessorEntry::toggle_inline_display_visibility ()
674 if (_plugin_display->is_visible ()) {
675 _plugin_display->hide();
677 _plugin_display->show();
679 _parent->update_gui_object_state (this);
683 ProcessorEntry::toggle_control_visibility (Control* c)
685 c->set_visible (!c->visible ());
686 _parent->update_gui_object_state (this);
690 ProcessorEntry::build_send_options_menu ()
692 using namespace Menu_Helpers;
693 Menu* menu = manage (new Menu);
694 MenuList& items = menu->items ();
696 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (_processor);
699 items.push_back (CheckMenuElem (_("Link panner controls")));
700 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
701 c->set_active (send->panner_shell()->is_linked_to_route());
702 c->signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::toggle_panner_link));
709 ProcessorEntry::toggle_panner_link ()
711 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (_processor);
713 send->panner_shell()->set_linked_to_route(!send->panner_shell()->is_linked_to_route());
717 ProcessorEntry::Control::Control (boost::shared_ptr<AutomationControl> c, string const & n)
719 , _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1)
720 , _slider (&_adjustment, boost::shared_ptr<PBD::Controllable>(), 0, max(13.f, rintf(13.f * UIConfiguration::instance().get_ui_scale())))
721 , _slider_persistant_tooltip (&_slider)
722 , _button (ArdourButton::led_default_elements)
723 , _ignore_ui_adjustment (false)
727 _slider.set_controllable (c);
728 box.set_padding(0, 0, 4, 4);
731 _button.set_text (_name);
732 _button.set_led_left (true);
733 _button.set_name ("processor control button");
737 _button.signal_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked));
738 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked_event));
739 // dup. currently timers are used :(
740 //c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
744 _slider.set_name ("ProcessorControlSlider");
745 _slider.set_text (_name);
750 const ARDOUR::ParameterDescriptor& desc = c->desc();
751 double const lo = c->internal_to_interface(desc.lower);
752 double const up = c->internal_to_interface(desc.upper);
753 double const normal = c->internal_to_interface(desc.normal);
754 double smallstep = desc.smallstep;
755 double largestep = desc.largestep;
757 if (smallstep == 0.0) {
758 smallstep = up / 1000.;
760 smallstep = c->internal_to_interface(desc.lower + smallstep);
763 if (largestep == 0.0) {
764 largestep = up / 40.;
766 largestep = c->internal_to_interface(desc.lower + largestep);
769 _adjustment.set_lower (lo);
770 _adjustment.set_upper (up);
771 _adjustment.set_step_increment (smallstep);
772 _adjustment.set_page_increment (largestep);
773 _slider.set_default_value (normal);
775 _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &Control::slider_adjusted));
776 // dup. currently timers are used :(
777 //c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
780 // yuck, do we really need to do this?
781 // according to c404374 this is only needed for send automation
782 timer_connection = Timers::rapid_connect (sigc::mem_fun (*this, &Control::control_changed));
787 /* We're providing our own PersistentTooltip */
788 set_no_tooltip_whatsoever (_slider);
791 ProcessorEntry::Control::~Control ()
793 timer_connection.disconnect ();
797 ProcessorEntry::Control::set_tooltip ()
799 boost::shared_ptr<AutomationControl> c = _control.lock ();
806 snprintf (tmp, sizeof(tmp), "%s: %s", _name.c_str(), c->get_value() > 0.5 ? _("on") : _("off"));
808 snprintf (tmp, sizeof(tmp), "%s: %.2f", _name.c_str(), c->internal_to_user (c->get_value ()));
811 string sm = Gtkmm2ext::markup_escape_text (tmp);
812 _slider_persistant_tooltip.set_tip (sm);
813 ARDOUR_UI_UTILS::set_tooltip (_button, sm);
817 ProcessorEntry::Control::slider_adjusted ()
819 if (_ignore_ui_adjustment) {
823 boost::shared_ptr<AutomationControl> c = _control.lock ();
829 c->set_value ( c->interface_to_internal(_adjustment.get_value ()) , Controllable::NoGroup);
834 ProcessorEntry::Control::button_clicked ()
836 boost::shared_ptr<AutomationControl> c = _control.lock ();
842 bool const n = _button.get_active ();
844 c->set_value (n ? 0 : 1, Controllable::NoGroup);
845 _button.set_active (!n);
850 ProcessorEntry::Control::button_clicked_event (GdkEventButton *ev)
858 ProcessorEntry::Control::control_changed ()
860 boost::shared_ptr<AutomationControl> c = _control.lock ();
865 _ignore_ui_adjustment = true;
869 _button.set_active (c->get_value() > 0.5);
872 // as long as rapid timers are used, only update the tooltip
873 // if the value has changed.
874 const double nval = c->internal_to_interface (c->get_value ());
875 if (_adjustment.get_value() != nval) {
876 _adjustment.set_value (nval);
881 _ignore_ui_adjustment = false;
885 ProcessorEntry::Control::add_state (XMLNode* node) const
887 XMLNode* c = new XMLNode (X_("Object"));
888 c->add_property (X_("id"), state_id ());
889 c->add_property (X_("visible"), _visible);
890 node->add_child_nocopy (*c);
894 ProcessorEntry::Control::set_state (XMLNode const * node)
896 XMLNode* n = GUIObjectState::get_node (node, state_id ());
898 XMLProperty* p = n->property (X_("visible"));
899 set_visible (p && string_is_affirmative (p->value ()));
906 ProcessorEntry::Control::set_visible (bool v)
917 /** Called when the Editor might have re-shown things that
921 ProcessorEntry::Control::hide_things ()
929 ProcessorEntry::Control::state_id () const
931 boost::shared_ptr<AutomationControl> c = _control.lock ();
934 return string_compose (X_("control %1"), c->id().to_s ());
937 PluginInsertProcessorEntry::PluginInsertProcessorEntry (ProcessorBox* b, boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
938 : ProcessorEntry (b, p, w)
941 p->PluginIoReConfigure.connect (
942 _iomap_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::iomap_changed, this), gui_context()
944 p->PluginMapChanged.connect (
945 _iomap_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::iomap_changed, this), gui_context()
947 p->PluginConfigChanged.connect (
948 _iomap_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::iomap_changed, this), gui_context()
953 PluginInsertProcessorEntry::iomap_changed ()
955 _parent->setup_routing_feeds ();
956 routing_icon.queue_draw();
957 output_routing_icon.queue_draw();
961 PluginInsertProcessorEntry::hide_things ()
963 ProcessorEntry::hide_things ();
966 ProcessorEntry::PortIcon::PortIcon(bool input) {
968 _ports = ARDOUR::ChanCount(ARDOUR::DataType::AUDIO, 1);
969 set_size_request (-1, std::max (2.f, rintf(2.f * UIConfiguration::instance().get_ui_scale())));
973 ProcessorEntry::PortIcon::on_expose_event (GdkEventExpose* ev)
975 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
977 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
980 Gtk::Allocation a = get_allocation();
981 double const width = a.get_width();
982 double const height = a.get_height();
984 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
985 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
987 cairo_rectangle (cr, 0, 0, width, height);
990 const double dx = rint(max(2., 2. * UIConfiguration::instance().get_ui_scale()));
991 if (_ports.n_total() > 1) {
992 for (uint32_t i = 0; i < _ports.n_total(); ++i) {
993 set_routing_color (cr, i < _ports.n_midi());
994 const float x = rintf(width * (.2f + .6f * i / (_ports.n_total() - 1.f)));
995 cairo_rectangle (cr, x-dx * .5, 0, 1+dx, height);
998 } else if (_ports.n_total() == 1) {
999 set_routing_color (cr, _ports.n_midi() == 1);
1000 const float x = rintf(width * .5);
1001 cairo_rectangle (cr, x-dx * .5, 0, 1+dx, height);
1010 ProcessorEntry::RoutingIcon::RoutingIcon (bool input)
1015 set_size_request (-1, std::max (7.f, rintf(8.f * UIConfiguration::instance().get_ui_scale())));
1017 set_size_request (-1, std::max (10.f, rintf(12.f * UIConfiguration::instance().get_ui_scale())));
1022 ProcessorEntry::RoutingIcon::set (
1023 const ARDOUR::ChanCount& in,
1024 const ARDOUR::ChanCount& out,
1025 const ARDOUR::ChanCount& sinks,
1026 const ARDOUR::ChanCount& sources,
1027 const ARDOUR::ChanMapping& in_map,
1028 const ARDOUR::ChanMapping& out_map)
1030 _in = in; _out = out;
1031 _sources = sources; _sinks = sinks;
1032 _in_map = in_map; _out_map = out_map;
1037 ProcessorEntry::RoutingIcon::identity () const {
1038 if (!_in_map.is_monotonic () || !_in_map.is_identity ()) {
1041 if (_in_map.count () != _sinks.n_total () || _in.n_total () != _sinks.n_total ()) {
1045 if (!_f_out_map.is_monotonic () || !_f_out_map.is_identity ()) {
1048 if (_f_out_map.count () != _f_sources.n_total () || _sinks != _f_sources) {
1056 ProcessorEntry::RoutingIcon::out_identity () const {
1057 if (!_out_map.is_monotonic () || !_out_map.is_identity ()) {
1060 if (_out_map.count () != _sources.n_total () || _out.n_total () != _sources.n_total ()) {
1067 ProcessorEntry::RoutingIcon::set_feed (
1068 const ARDOUR::ChanCount& out,
1069 const ARDOUR::ChanCount& sources,
1070 const ARDOUR::ChanMapping& out_map)
1073 _f_sources = sources;
1074 _f_out_map = out_map;
1079 ProcessorEntry::RoutingIcon::pin_x_pos (uint32_t i, double width, uint32_t n_total, uint32_t n_midi, bool midi)
1081 if (!midi) { i += n_midi; }
1084 return rint (width * .5) +.5;
1086 return rint (width * (.2 + .6 * i / (n_total - 1))) + .5;
1090 ProcessorEntry::RoutingIcon::draw_X (cairo_t* cr, double x0, double height, bool midi)
1092 const double y0 = rint (height * .4) + .5;
1093 const double dx = min (y0 - .5, 1. + rint (max(2., 2. * UIConfiguration::instance().get_ui_scale())));
1095 cairo_move_to (cr, x0, 0);
1096 cairo_line_to (cr, x0, y0);
1097 cairo_move_to (cr, x0 - dx, y0 - dx);
1098 cairo_line_to (cr, x0 + dx, y0 + dx);
1099 cairo_move_to (cr, x0 - dx, y0 + dx);
1100 cairo_line_to (cr, x0 + dx, y0 - dx);
1102 set_routing_color (cr, midi);
1103 cairo_set_line_width (cr, 1.0);
1104 cairo_stroke_preserve (cr);
1105 cairo_set_source_rgba (cr, 0, 0, 0, .4); // darken
1110 ProcessorEntry::RoutingIcon::draw_gnd (cairo_t* cr, double x0, double height, bool midi)
1112 const double dx = 1 + rint (max(2., 2. * UIConfiguration::instance().get_ui_scale()));
1113 const double y0 = rint (height * .66) + .5;
1115 cairo_move_to (cr, x0, height);
1116 cairo_line_to (cr, x0, y0);
1117 cairo_move_to (cr, x0 - dx, y0);
1118 cairo_line_to (cr, x0 + dx, y0);
1120 set_routing_color (cr, midi);
1121 cairo_set_line_width (cr, 1.0);
1126 ProcessorEntry::RoutingIcon::draw_sidechain (cairo_t* cr, double x0, double height, bool midi)
1128 const double dx = 1 + rint (max(2., 2. * UIConfiguration::instance().get_ui_scale()));
1129 const double y0 = rint (height * .66) + .5;
1131 cairo_move_to (cr, x0 - dx, height);
1132 cairo_line_to (cr, x0, y0);
1133 cairo_line_to (cr, x0 + dx, height);
1134 cairo_close_path (cr);
1136 set_routing_color (cr, midi);
1137 cairo_set_line_width (cr, 1.0);
1142 ProcessorEntry::RoutingIcon::draw_connection (cairo_t* cr, double x0, double x1, double y0, double y1, bool midi, bool dashed)
1144 double bz = abs (y1 - y0);
1146 cairo_move_to (cr, x0, y0);
1147 cairo_curve_to (cr, x0, y0 + bz, x1, y1 - bz, x1, y1);
1148 cairo_set_line_width (cr, 1.0);
1149 cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
1150 cairo_set_source_rgb (cr, 1, 0, 0);
1152 const double dashes[] = { 2, 3 };
1153 cairo_set_dash (cr, dashes, 2, 0);
1155 set_routing_color (cr, midi);
1158 cairo_set_dash (cr, 0, 0, 0);
1163 ProcessorEntry::RoutingIcon::on_expose_event (GdkEventExpose* ev)
1165 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
1167 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
1170 cairo_set_line_width (cr, max (1.f, UIConfiguration::instance().get_ui_scale()));
1171 cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
1173 Gtk::Allocation a = get_allocation();
1174 double const width = a.get_width();
1175 double const height = a.get_height();
1177 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
1178 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
1180 cairo_rectangle (cr, 0, 0, width, height);
1184 expose_input_map (cr, width, height);
1186 expose_output_map (cr, width, height);
1194 ProcessorEntry::RoutingIcon::expose_input_map (cairo_t* cr, const double width, const double height)
1196 const uint32_t pc_in = _sinks.n_total();
1197 const uint32_t pc_in_midi = _sinks.n_midi();
1199 // TODO indicate midi-bypass ??
1200 // TODO indicate side-chain
1202 for (uint32_t i = 0; i < pc_in; ++i) {
1203 const bool is_midi = i < pc_in_midi;
1205 uint32_t pn = is_midi ? i : i - pc_in_midi;
1206 DataType dt = is_midi ? DataType::MIDI : DataType::AUDIO;
1207 uint32_t idx = _in_map.get (dt, pn, &valid_in);
1209 double x = pin_x_pos (i, width, pc_in, 0, is_midi);
1210 draw_gnd (cr, x, height, is_midi);
1213 if (idx >= _in.get (dt)) {
1214 // side-chain, probably
1215 double x = pin_x_pos (i, width, pc_in, 0, is_midi);
1216 draw_sidechain (cr, x, height, is_midi);
1220 double c_x1 = pin_x_pos (i, width, pc_in, 0, false);
1224 uint32_t src = _f_out_map.get_src (dt, idx, &valid_src);
1226 double x = pin_x_pos (i, width, pc_in, 0, false);
1227 draw_gnd (cr, x, height, is_midi);
1230 c_x0 = pin_x_pos (src, width, _f_sources.n_total(), _f_sources.n_midi(), is_midi);
1232 c_x0 = pin_x_pos (idx, width, _in.n_total(), _in.n_midi(), is_midi);
1234 draw_connection (cr, c_x0, c_x1, 0, height, is_midi);
1239 ProcessorEntry::RoutingIcon::expose_output_map (cairo_t* cr, const double width, const double height)
1241 const uint32_t pc_out = _sources.n_total();
1242 const uint32_t pc_out_midi = _sources.n_midi();
1244 const uint32_t n_out = _out.n_total();
1245 const uint32_t n_out_midi = _out.n_midi();
1247 for (uint32_t i = 0; i < pc_out; ++i) {
1248 const bool is_midi = i < pc_out_midi;
1250 uint32_t pn = is_midi ? i : i - pc_out_midi;
1251 DataType dt = is_midi ? DataType::MIDI : DataType::AUDIO;
1252 uint32_t idx = _out_map.get (dt, pn, &valid_out);
1254 double x = pin_x_pos (i, width, pc_out, 0, is_midi);
1255 draw_X (cr, x, height - 5, is_midi);
1258 double c_x0 = pin_x_pos (i, width, pc_out, 0, false);
1259 double c_x1 = pin_x_pos (idx, width, n_out, n_out_midi, is_midi);
1260 draw_connection (cr, c_x0, c_x1, 0, height - 3, is_midi);
1264 for (uint32_t i = 0; i < n_out; ++i) {
1265 const bool is_midi = i < n_out_midi;
1266 double x = pin_x_pos (i, width, n_out, 0, is_midi);
1267 uint32_t pn = is_midi ? i : i - n_out_midi;
1268 DataType dt = is_midi ? DataType::MIDI : DataType::AUDIO;
1270 _out_map.get_src (dt, pn, &valid_src);
1272 draw_gnd (cr, x, height, is_midi);
1274 set_routing_color (cr, is_midi);
1275 cairo_move_to (cr, x , height);
1276 cairo_line_to (cr, x - 3, height - 3);
1277 cairo_line_to (cr, x + 3, height - 3);
1278 cairo_close_path (cr);
1283 ProcessorEntry::PluginDisplay::PluginDisplay (boost::shared_ptr<ARDOUR::Plugin> p, uint32_t max_height)
1286 , _max_height (max_height)
1290 set_name ("processor prefader");
1291 _plug->QueueDraw.connect (_qdraw_connection, invalidator (*this),
1292 boost::bind (&Gtk::Widget::queue_draw, this), gui_context ());
1295 ProcessorEntry::PluginDisplay::~PluginDisplay ()
1298 cairo_surface_destroy (_surf);
1303 ProcessorEntry::PluginDisplay::on_size_request (Gtk::Requisition* req)
1306 req->height = _cur_height;
1311 ProcessorEntry::PluginDisplay::update_height_alloc (uint32_t inline_height)
1313 /* work-around scroll-bar + aspect ratio
1314 * show inline-view -> height changes -> scrollbar gets added
1315 * -> width changes -> inline-view, fixed aspect ratio -> height changes
1316 * -> scroll bar is removed [-> width changes ; repeat ]
1318 uint32_t shm = std::min (_max_height, inline_height);
1320 Gtk::Container* pr = get_parent();
1321 for (uint32_t i = 0; i < 4 && pr; ++i) {
1322 // VBox, EventBox, ViewPort, ScrolledWindow
1323 pr = pr->get_parent();
1325 Gtk::ScrolledWindow* sw = dynamic_cast<Gtk::ScrolledWindow*> (pr);
1327 const Gtk::VScrollbar* vsb = sw->get_vscrollbar();
1328 sc = vsb && vsb->is_visible();
1331 if (shm != _cur_height) {
1332 if (_scroll == sc || _cur_height < shm) {
1341 ProcessorEntry::PluginDisplay::render_inline (cairo_t* cr, uint32_t width)
1343 Plugin::Display_Image_Surface* dis = _plug->render_inline_display (width, _max_height);
1348 /* allocate a local image-surface,
1349 * We cannot re-use the data via cairo_image_surface_create_for_data(),
1350 * since pixman keeps a reference to it.
1351 * we'd need to hand over the data and ha cairo_surface_destroy to free it.
1352 * it might be possible to work around via cairo_surface_set_user_data().
1355 || dis->width != cairo_image_surface_get_width (_surf)
1356 || dis->height != cairo_image_surface_get_height (_surf)
1359 cairo_surface_destroy (_surf);
1361 _surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, dis->width, dis->height);
1364 if (cairo_image_surface_get_stride (_surf) == dis->stride) {
1365 memcpy (cairo_image_surface_get_data (_surf), dis->data, dis->stride * dis->height);
1367 unsigned char *src = dis->data;
1368 unsigned char *dst = cairo_image_surface_get_data (_surf);
1369 const int dst_stride = cairo_image_surface_get_stride (_surf);
1370 for (int y = 0; y < dis->height; ++y) {
1371 memcpy (dst, src, dis->width * 4 /*ARGB32*/);
1377 cairo_surface_mark_dirty(_surf);
1378 const double xc = floor ((width - dis->width) * .5);
1379 cairo_set_source_surface(cr, _surf, xc, 0);
1386 ProcessorEntry::PluginDisplay::on_expose_event (GdkEventExpose* ev)
1388 Gtk::Allocation a = get_allocation();
1389 double const width = a.get_width();
1390 double const height = a.get_height();
1392 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
1393 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
1396 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
1397 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
1398 cairo_rectangle (cr, 0, 0, width, height);
1402 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
1403 Gtkmm2ext::rounded_rectangle (cr, .5, -1.5, width - 1, height + 1, 7);
1405 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1407 uint32_t ht = render_inline (cr, width);
1412 if (_cur_height != 1) {
1419 update_height_alloc (ht);
1422 bool failed = false;
1423 std::string name = get_name();
1424 ArdourCanvas::Color fill_color = UIConfiguration::instance().color (string_compose ("%1: fill active", name), &failed);
1426 Gtkmm2ext::rounded_rectangle (cr, .5, -1.5, width - 1, height + 1, 7);
1427 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1428 cairo_set_line_width(cr, 1.0);
1429 ArdourCanvas::set_source_rgb_a (cr, fill_color, 1.0);
1436 ProcessorEntry::LuaPluginDisplay::LuaPluginDisplay (boost::shared_ptr<ARDOUR::LuaProc> p, uint32_t max_height)
1437 : PluginDisplay (p, max_height)
1439 , _lua_render_inline (0)
1441 p->setup_lua_inline_gui (&lua_gui);
1443 lua_State* LG = lua_gui.getState ();
1444 LuaInstance::bind_cairo (LG);
1445 luabridge::LuaRef lua_render = luabridge::getGlobal (LG, "render_inline");
1446 assert (lua_render.isFunction ());
1447 _lua_render_inline = new luabridge::LuaRef (lua_render);
1450 ProcessorEntry::LuaPluginDisplay::~LuaPluginDisplay ()
1452 delete (_lua_render_inline);
1456 ProcessorEntry::LuaPluginDisplay::render_inline (cairo_t *cr, uint32_t width)
1458 Cairo::Context ctx (cr);
1460 luabridge::LuaRef rv = (*_lua_render_inline)((Cairo::Context *)&ctx, width, _max_height);
1461 if (rv.isTable ()) {
1465 } catch (luabridge::LuaException const& e) {
1472 static std::list<Gtk::TargetEntry> drop_targets()
1474 std::list<Gtk::TargetEntry> tmp;
1475 tmp.push_back (Gtk::TargetEntry ("processor")); // from processor-box to processor-box
1476 tmp.push_back (Gtk::TargetEntry ("PluginInfoPtr")); // from plugin-manager
1477 tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr")); // from sidebar
1481 static std::list<Gtk::TargetEntry> drag_targets()
1483 std::list<Gtk::TargetEntry> tmp;
1484 tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr")); // to sidebar (optional preset)
1485 tmp.push_back (Gtk::TargetEntry ("processor")); // to processor-box (copy)
1489 static std::list<Gtk::TargetEntry> drag_targets_noplugin()
1491 std::list<Gtk::TargetEntry> tmp;
1492 tmp.push_back (Gtk::TargetEntry ("processor")); // to processor box (sends, faders re-order)
1496 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
1497 RouteProcessorSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
1498 : _parent_strip (parent)
1499 , _owner_is_mixer (owner_is_mixer)
1500 , ab_direction (true)
1501 , _get_plugin_selector (get_plugin_selector)
1503 , _visible_prefader_processors (0)
1504 , _rr_selection(rsel)
1505 , processor_display (drop_targets())
1506 , _redisplay_pending (false)
1510 /* ProcessorBox actions and bindings created statically by call to
1511 * ProcessorBox::register_actions(), made by ARDOUR_UI so that actions
1512 * are available for context menus.
1515 processor_display.set_data ("ardour-bindings", bindings);
1519 no_processor_redisplay = false;
1521 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
1522 processor_scroller.add (processor_display);
1523 pack_start (processor_scroller, true, true);
1525 processor_display.set_flags (CAN_FOCUS);
1526 processor_display.set_name ("ProcessorList");
1527 processor_display.set_data ("processorbox", this);
1528 processor_display.set_size_request (48, -1);
1529 processor_display.set_spacing (0);
1531 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
1532 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
1534 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
1535 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
1537 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
1538 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
1539 processor_display.DropFromExternal.connect (sigc::mem_fun (*this, &ProcessorBox::plugin_drop));
1541 processor_scroller.show ();
1542 processor_display.show ();
1545 parent->DeliveryChanged.connect (
1546 _mixer_strip_connections, invalidator (*this), boost::bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
1550 ARDOUR_UI_UTILS::set_tooltip (processor_display, _("Right-click to add/remove/edit\nplugins,inserts,sends and more"));
1553 ProcessorBox::~ProcessorBox ()
1555 /* it may appear as if we should delete processor_menu but that is a
1556 * pointer to a widget owned by the UI Manager, and has potentially
1557 * be returned to many other ProcessorBoxes. GTK doesn't really make
1558 * clear the ownership of this widget, which is a menu and thus is
1559 * never packed into any container other than an implict GtkWindow.
1561 * For now, until or if we ever get clarification over the ownership
1562 * story just let it continue to exist. At worst, its a small memory leak.
1567 ProcessorBox::set_route (boost::shared_ptr<Route> r)
1573 _route_connections.drop_connections();
1575 /* new route: any existing block on processor redisplay must be meaningless */
1576 no_processor_redisplay = false;
1579 _route->processors_changed.connect (
1580 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
1583 _route->DropReferences.connect (
1584 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
1587 _route->PropertyChanged.connect (
1588 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
1591 redisplay_processors ();
1595 ProcessorBox::route_going_away ()
1597 /* don't keep updating display as processors are deleted */
1598 no_processor_redisplay = true;
1602 boost::shared_ptr<Processor>
1603 ProcessorBox::find_drop_position (ProcessorEntry* position)
1605 boost::shared_ptr<Processor> p;
1607 p = position->processor ();
1609 /* dropped on the blank entry (which will be before the
1610 fader), so use the first non-blank child as our
1611 `dropped on' processor */
1612 list<ProcessorEntry*> c = processor_display.children ();
1613 list<ProcessorEntry*>::iterator i = c.begin ();
1615 assert (i != c.end ());
1616 p = (*i)->processor ();
1624 ProcessorBox::_drop_plugin_preset (Gtk::SelectionData const &data, Route::ProcessorList &pl)
1626 const void * d = data.get_data();
1627 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
1629 PluginPresetList nfos;
1631 tv->get_object_drag_data (nfos, &source);
1633 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1634 PluginPresetPtr ppp = (*i);
1635 PluginInfoPtr pip = ppp->_pip;
1636 PluginPtr p = pip->load (*_session);
1641 if (ppp->_preset.valid) {
1642 p->load_preset (ppp->_preset);
1645 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
1646 if (Config->get_new_plugins_active ()) {
1647 processor->activate ();
1649 pl.push_back (processor);
1654 ProcessorBox::_drop_plugin (Gtk::SelectionData const &data, Route::ProcessorList &pl)
1656 const void * d = data.get_data();
1657 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>*>(d);
1658 PluginInfoList nfos;
1661 tv->get_object_drag_data (nfos, &source);
1663 for (list<PluginInfoPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1664 PluginPtr p = (*i)->load (*_session);
1668 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
1669 if (Config->get_new_plugins_active ()) {
1670 processor->activate ();
1672 pl.push_back (processor);
1677 ProcessorBox::plugin_drop (Gtk::SelectionData const &data, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
1683 boost::shared_ptr<Processor> p = find_drop_position (position);
1684 Route::ProcessorList pl;
1686 if (data.get_target() == "PluginInfoPtr") {
1687 _drop_plugin (data, pl);
1689 else if (data.get_target() == "PluginPresetPtr") {
1690 _drop_plugin_preset (data, pl);
1696 Route::ProcessorStreams err;
1697 if (_route->add_processors (pl, p, &err)) {
1699 "Processor Drag/Drop failed. Probably because\n\
1700 the I/O configuration of the plugins could\n\
1701 not match the configuration of this track.");
1702 MessageDialog am (msg);
1708 ProcessorBox::object_drop (DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
1710 if (Gdk::ACTION_LINK == context->get_selected_action()) {
1711 list<ProcessorEntry*> children = source->selection ();
1712 assert (children.size() == 1);
1713 ProcessorEntry* other = *children.begin();
1714 assert (other->can_copy_state (position));
1715 boost::shared_ptr<ARDOUR::Processor> otherproc = other->processor();
1716 boost::shared_ptr<ARDOUR::Processor> proc = position->processor();
1717 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (proc);
1718 assert (otherproc && proc && pi);
1720 PBD::ID id = pi->id();
1721 XMLNode& state = otherproc->get_state ();
1722 proc->set_state (state, Stateful::loading_state_version);
1723 boost::dynamic_pointer_cast<PluginInsert>(proc)->update_id (id);
1727 boost::shared_ptr<Processor> p = find_drop_position (position);
1729 list<ProcessorEntry*> children = source->selection ();
1730 list<boost::shared_ptr<Processor> > procs;
1731 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
1732 if ((*i)->processor ()) {
1733 if (boost::dynamic_pointer_cast<UnknownProcessor> ((*i)->processor())) {
1736 procs.push_back ((*i)->processor ());
1740 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
1741 XMLNode& state = (*i)->get_state ();
1743 nlist.push_back (&state);
1744 paste_processor_state (nlist, p);
1748 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
1752 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
1753 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
1755 other->delete_dragged_processors (procs);
1761 ProcessorBox::set_width (Width w)
1769 list<ProcessorEntry*> children = processor_display.children ();
1770 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1771 (*i)->set_enum_width (w);
1778 ProcessorBox::build_possible_aux_menu ()
1780 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
1783 /* No aux sends if there are no busses */
1787 if (_route->is_monitor ()) {
1791 using namespace Menu_Helpers;
1792 Menu* menu = manage (new Menu);
1793 MenuList& items = menu->items();
1795 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
1796 if (!_route->internal_send_for (*r) && *r != _route) {
1797 items.push_back (MenuElem ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
1805 ProcessorBox::show_processor_menu (int arg)
1807 if (processor_menu == 0) {
1808 processor_menu = build_processor_menu ();
1809 processor_menu->signal_unmap().connect (sigc::mem_fun (*this, &ProcessorBox::processor_menu_unmapped));
1812 /* Sort out the plugin submenu */
1814 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newplugin"));
1816 if (plugin_menu_item) {
1817 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
1820 /* And the aux submenu */
1822 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newaux"));
1824 if (aux_menu_item) {
1825 Menu* m = build_possible_aux_menu();
1826 if (m && !m->items().empty()) {
1827 aux_menu_item->set_submenu (*m);
1828 aux_menu_item->set_sensitive (true);
1830 /* stupid gtkmm: we need to pass a null reference here */
1831 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
1832 aux_menu_item->set_sensitive (false);
1836 ActionManager::get_action (X_("ProcessorMenu"), "newinsert")->set_sensitive (!_route->is_monitor ());
1837 ActionManager::get_action (X_("ProcessorMenu"), "newsend")->set_sensitive (!_route->is_monitor ());
1839 ProcessorEntry* single_selection = 0;
1840 if (processor_display.selection().size() == 1) {
1841 single_selection = processor_display.selection().front();
1844 /* And the controls submenu */
1846 Gtk::MenuItem* controls_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/controls"));
1848 if (controls_menu_item) {
1849 if (single_selection) {
1850 Menu* m = single_selection->build_controls_menu ();
1851 if (m && !m->items().empty()) {
1852 controls_menu_item->set_submenu (*m);
1853 controls_menu_item->set_sensitive (true);
1855 gtk_menu_item_set_submenu (controls_menu_item->gobj(), 0);
1856 controls_menu_item->set_sensitive (false);
1859 controls_menu_item->set_sensitive (false);
1863 Gtk::MenuItem* send_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/send_options"));
1864 if (send_menu_item) {
1865 if (single_selection && !_route->is_monitor()) {
1866 Menu* m = single_selection->build_send_options_menu ();
1867 if (m && !m->items().empty()) {
1868 send_menu_item->set_submenu (*m);
1869 send_menu_item->set_sensitive (true);
1871 gtk_menu_item_set_submenu (send_menu_item->gobj(), 0);
1872 send_menu_item->set_sensitive (false);
1875 send_menu_item->set_sensitive (false);
1879 /* Sensitise actions as approprioate */
1882 const bool sensitive = !processor_display.selection().empty() && ! stub_processor_selected ();
1884 paste_action->set_sensitive (!_rr_selection.processors.empty());
1885 cut_action->set_sensitive (sensitive && can_cut ());
1886 copy_action->set_sensitive (sensitive);
1887 delete_action->set_sensitive (sensitive || stub_processor_selected ());
1889 edit_action->set_sensitive (one_processor_can_be_edited ());
1890 edit_generic_action->set_sensitive (one_processor_can_be_edited ());
1892 boost::shared_ptr<PluginInsert> pi;
1893 if (single_selection) {
1894 pi = boost::dynamic_pointer_cast<PluginInsert> (single_selection->processor ());
1897 manage_pins_action->set_sensitive (pi != 0);
1899 /* allow editing with an Ardour-generated UI for plugin inserts with editors */
1900 edit_action->set_sensitive (pi && pi->plugin()->has_editor ());
1902 /* disallow rename for multiple selections, for plugin inserts and for the fader */
1903 rename_action->set_sensitive (single_selection
1905 && !boost::dynamic_pointer_cast<Amp> (single_selection->processor ())
1906 && !boost::dynamic_pointer_cast<UnknownProcessor> (single_selection->processor ()));
1908 processor_menu->popup (1, arg);
1910 /* Add a placeholder gap to the processor list to indicate where a processor would be
1911 inserted were one chosen from the menu.
1914 processor_display.get_pointer (x, y);
1915 _placement = processor_display.add_placeholder (y);
1917 if (_visible_prefader_processors == 0 && _placement > 0) {
1923 ProcessorBox::enter_notify (GdkEventCrossing*)
1925 processor_display.grab_focus ();
1926 _current_processor_box = this;
1931 ProcessorBox::leave_notify (GdkEventCrossing* ev)
1933 if (ev->detail == GDK_NOTIFY_INFERIOR) {
1937 Widget* top = get_toplevel();
1939 if (top->is_toplevel()) {
1940 Window* win = dynamic_cast<Window*> (top);
1941 gtk_window_set_focus (win->gobj(), 0);
1948 ProcessorBox::processor_operation (ProcessorOperation op)
1950 ProcSelection targets;
1952 get_selected_processors (targets);
1954 /* if (targets.empty()) {
1957 processor_display.get_pointer (x, y);
1959 pair<ProcessorEntry *, double> const pointer = processor_display.get_child_at_position (y);
1961 if (pointer.first && pointer.first->processor()) {
1962 targets.push_back (pointer.first->processor ());
1967 if ((op == ProcessorsDelete) && targets.empty()) {
1968 return false; //nothing to delete. return false so the editor-mixer, because the user was probably intending to delete something in the editor
1972 case ProcessorsSelectAll:
1973 processor_display.select_all ();
1976 case ProcessorsSelectNone:
1977 processor_display.select_none ();
1980 case ProcessorsCopy:
1981 copy_processors (targets);
1985 cut_processors (targets);
1988 case ProcessorsPaste:
1989 // some processors are not selectable (e.g fader, meter), target is empty.
1990 if (targets.empty() && _placement >= 0) {
1992 boost::shared_ptr<Processor> proc = _route->before_processor_for_index (_placement);
1994 targets.push_back (proc);
1997 if (targets.empty()) {
1998 paste_processors ();
2000 paste_processors (targets.front());
2004 case ProcessorsDelete:
2005 delete_processors (targets);
2008 case ProcessorsToggleActive:
2009 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
2010 if ((*i)->active()) {
2011 (*i)->deactivate ();
2029 ProcessorWindowProxy*
2030 ProcessorBox::find_window_proxy (boost::shared_ptr<Processor> processor) const
2032 return processor->window_proxy();
2037 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
2039 boost::shared_ptr<Processor> processor;
2041 processor = child->processor ();
2045 bool selected = processor_display.selected (child);
2047 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
2049 if (_session->engine().connected()) {
2050 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
2052 if (!one_processor_can_be_edited ()) {
2056 if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
2057 generic_edit_processor (processor);
2059 edit_processor (processor);
2065 } else if (Keyboard::is_context_menu_event (ev)) {
2067 show_processor_menu (ev->time);
2071 } else if (processor && ev->button == 1 && selected) {
2073 // this is purely informational but necessary for route params UI
2074 ProcessorSelected (processor); // emit
2076 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
2079 _get_plugin_selector()->show_manager ();
2086 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
2088 boost::shared_ptr<Processor> processor;
2090 processor = child->processor ();
2093 if (processor && Keyboard::is_delete_event (ev)) {
2095 Glib::signal_idle().connect (sigc::bind (
2096 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
2097 boost::weak_ptr<Processor>(processor)));
2099 } else if (processor && Keyboard::is_button2_event (ev)
2101 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
2105 /* button2-click with no/appropriate modifiers */
2107 if (processor->active()) {
2108 processor->deactivate ();
2110 processor->activate ();
2118 ProcessorBox::build_processor_menu ()
2120 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/ProcessorMenu") );
2121 processor_menu->set_name ("ArdourContextMenu");
2122 return processor_menu;
2126 ProcessorBox::select_all_processors ()
2128 processor_display.select_all ();
2132 ProcessorBox::deselect_all_processors ()
2134 processor_display.select_none ();
2138 ProcessorBox::choose_plugin ()
2140 _get_plugin_selector()->set_interested_object (*this);
2143 /** @return true if an error occurred, otherwise false */
2145 ProcessorBox::choose_lua ()
2147 LuaScriptInfoPtr spi;
2149 ScriptSelector ss (_("Add Lua DSP Processor"), LuaScriptInfo::DSP);
2150 switch (ss.run ()) {
2151 case Gtk::RESPONSE_ACCEPT:
2161 LuaPluginInfoPtr lpi (new LuaPluginInfo(spi));
2162 p = (lpi->load (*_session));
2165 "Failed to instantiate Lua DSP Processor,\n"
2166 "probably because the script is invalid (no dsp function).");
2167 MessageDialog am (msg);
2172 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
2174 Route::ProcessorStreams err_streams;
2175 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
2177 "Failed to add Lua DSP Processor at the given position,\n"
2178 "probably because the I/O configuration of the plugins\n"
2179 "could not match the configuration of this track.");
2180 MessageDialog am (msg);
2186 /** @return true if an error occurred, otherwise false */
2188 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
2190 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
2192 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
2194 Route::ProcessorStreams err_streams;
2196 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
2197 weird_plugin_dialog (**p, err_streams);
2199 // XXX SHAREDPTR delete plugin here .. do we even need to care?
2200 } else if (plugins.size() == 1 && UIConfiguration::instance().get_open_gui_after_adding_plugin()) {
2201 if (boost::dynamic_pointer_cast<PluginInsert>(processor)->plugin()->has_inline_display() && UIConfiguration::instance().get_prefer_inline_over_gui()) {
2203 } else if (_session->engine().connected () && processor_can_be_edited (processor)) {
2204 if ((*p)->has_editor ()) {
2205 edit_processor (processor);
2207 generic_edit_processor (processor);
2217 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
2219 ArdourDialog dialog (_("Plugin Incompatibility"));
2222 string text = string_compose(_("You attempted to add the plugin \"%1\" in slot %2.\n"),
2223 p.name(), streams.index);
2225 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
2226 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
2228 text += _("\nThis plugin has:\n");
2230 uint32_t const n = p.get_info()->n_inputs.n_midi ();
2231 text += string_compose (ngettext ("\t%1 MIDI input\n", "\t%1 MIDI inputs\n", n), n);
2234 uint32_t const n = p.get_info()->n_inputs.n_audio ();
2235 text += string_compose (ngettext ("\t%1 audio input\n", "\t%1 audio inputs\n", n), n);
2238 text += _("\nbut at the insertion point, there are:\n");
2240 uint32_t const n = streams.count.n_midi ();
2241 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
2244 uint32_t const n = streams.count.n_audio ();
2245 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
2248 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
2249 label.set_text(text);
2251 dialog.get_vbox()->pack_start (label);
2252 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
2254 dialog.set_name (X_("PluginIODialog"));
2255 dialog.set_modal (true);
2262 ProcessorBox::choose_insert ()
2264 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->pannable(), _route->mute_master()));
2265 _route->add_processor_by_index (processor, _placement);
2268 /* Caller must not hold process lock */
2270 ProcessorBox::choose_send ()
2272 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
2273 boost::shared_ptr<Send> send (new Send (*_session, sendpan, _route->mute_master()));
2275 /* make an educated guess at the initial number of outputs for the send */
2276 ChanCount outs = (_session->master_out())
2277 ? _session->master_out()->n_outputs()
2278 : _route->n_outputs();
2280 /* XXX need processor lock on route */
2282 Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock());
2283 send->output()->ensure_io (outs, false, this);
2284 } catch (AudioEngine::PortRegistrationFailure& err) {
2285 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
2289 /* let the user adjust the IO setup before creation.
2291 Note: this dialog is NOT modal - we just leave it to run and it will
2292 return when its Finished signal is emitted - typically when the window
2296 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
2299 /* keep a reference to the send so it doesn't get deleted while
2300 the IOSelectorWindow is doing its stuff
2302 _processor_being_created = send;
2304 ios->selector().Finished.connect (sigc::bind (
2305 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
2306 boost::weak_ptr<Processor>(send), ios));
2311 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
2313 boost::shared_ptr<Processor> processor (weak_processor.lock());
2315 /* drop our temporary reference to the new send */
2316 _processor_being_created.reset ();
2323 case IOSelector::Cancelled:
2324 // processor will go away when all shared_ptrs to it vanish
2327 case IOSelector::Accepted:
2328 _route->add_processor_by_index (processor, _placement);
2332 delete_when_idle (ios);
2336 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
2338 boost::shared_ptr<Processor> processor (weak_processor.lock());
2340 /* drop our temporary reference to the new return */
2341 _processor_being_created.reset ();
2348 case IOSelector::Cancelled:
2349 // processor will go away when all shared_ptrs to it vanish
2352 case IOSelector::Accepted:
2353 _route->add_processor_by_index (processor, _placement);
2357 delete_when_idle (ios);
2361 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
2367 boost::shared_ptr<Route> target = wr.lock();
2373 _session->add_internal_send (target, _placement, _route);
2377 ProcessorBox::route_processors_changed (RouteProcessorChange c)
2379 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
2380 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
2384 redisplay_processors ();
2388 ProcessorBox::redisplay_processors ()
2390 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors);
2393 if (no_processor_redisplay) {
2397 processor_display.clear ();
2399 _visible_prefader_processors = 0;
2402 _route->foreach_processor (sigc::bind (sigc::mem_fun (*this, &ProcessorBox::help_count_visible_prefader_processors),
2403 &_visible_prefader_processors, &fader_seen));
2405 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
2406 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
2407 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_pin_mgr));
2409 setup_entry_positions ();
2412 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
2413 * not already have one.
2416 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
2418 boost::shared_ptr<Processor> p = w.lock ();
2422 if (p->window_proxy()) {
2426 /* not on the list; add it */
2429 #if 0 // is this still needed? Why?
2430 if (_parent_strip) {
2431 if (_parent_strip->mixer_owned()) {
2443 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
2444 string_compose ("%1-%2-%3", loc, _route->id(), p->id()),
2448 const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
2451 wp->set_state (*ui_xml, 0);
2454 void* existing_ui = p->get_ui ();
2457 wp->use_window (*(reinterpret_cast<Gtk::Window*>(existing_ui)));
2460 p->set_window_proxy (wp);
2461 WM::Manager::instance().register_window (wp);
2465 ProcessorBox::maybe_add_processor_pin_mgr (boost::weak_ptr<Processor> w)
2467 boost::shared_ptr<Processor> p = w.lock ();
2468 if (!p || p->pinmgr_proxy ()) {
2472 PluginPinWindowProxy* wp = new PluginPinWindowProxy (
2473 string_compose ("PM-%2-%3", _route->id(), p->id()), w);
2474 wp->set_session (_session);
2476 const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
2478 wp->set_state (*ui_xml, 0);
2481 void* existing_ui = p->get_ui ();
2484 wp->use_window (*(reinterpret_cast<Gtk::Window*>(existing_ui)));
2487 p->set_pingmgr_proxy (wp);
2488 WM::Manager::instance().register_window (wp);
2491 ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor> p, uint32_t* cnt, bool* amp_seen)
2493 boost::shared_ptr<Processor> processor (p.lock ());
2495 if (processor && ( processor->display_to_user()
2497 || show_all_processors
2502 if (boost::dynamic_pointer_cast<Amp>(processor) &&
2503 boost::dynamic_pointer_cast<Amp>(processor)->gain_control()->parameter().type() == GainAutomation) {
2514 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
2516 boost::shared_ptr<Processor> processor (p.lock ());
2518 if (!processor || ( !processor->display_to_user()
2520 && !show_all_processors
2527 boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
2529 ProcessorEntry* e = 0;
2530 if (plugin_insert) {
2531 e = new PluginInsertProcessorEntry (this, plugin_insert, _width);
2533 e = new ProcessorEntry (this, processor, _width);
2536 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
2537 boost::shared_ptr<PortInsert> ext = boost::dynamic_pointer_cast<PortInsert> (processor);
2538 boost::shared_ptr<UnknownProcessor> stub = boost::dynamic_pointer_cast<UnknownProcessor> (processor);
2540 //faders and meters are not deletable, copy/paste-able, so they shouldn't be selectable
2541 if (!send && !plugin_insert && !ext && !stub)
2542 e->set_selectable(false);
2544 bool mark_send_visible = false;
2545 if (send && _parent_strip) {
2546 /* show controls of new sends by default */
2547 GUIObjectState& st = _parent_strip->gui_object_state ();
2548 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
2550 /* check if state exists, if not it must be a new send */
2551 if (!st.get_node(strip, e->state_id())) {
2552 mark_send_visible = true;
2556 /* Set up this entry's state from the GUIObjectState */
2557 XMLNode* proc = entry_gui_object_state (e);
2559 e->set_control_state (proc);
2562 if (mark_send_visible) {
2563 e->show_all_controls ();
2568 && !plugin_insert->plugin(0)->is_channelstrip()
2572 processor_display.add_child (e, drag_targets());
2574 processor_display.add_child (e, drag_targets_noplugin());
2579 ProcessorBox::reordered ()
2581 compute_processor_sort_keys ();
2582 setup_entry_positions ();
2586 ProcessorBox::setup_routing_feeds ()
2588 list<ProcessorEntry*> children = processor_display.children ();
2589 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2590 boost::shared_ptr<ARDOUR::Processor> p = (*i)->processor();
2591 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (p);
2593 list<ProcessorEntry*>::iterator next = i;
2597 ChanCount sinks = pi->natural_input_streams ();
2598 ChanCount sources = pi->natural_output_streams ();
2599 uint32_t count = pi->get_count ();
2601 pi->configured_io (in, out);
2603 ChanCount midi_bypass;
2604 if (pi->has_midi_bypass ()) {
2605 midi_bypass.set(DataType::MIDI, 1);
2608 (*i)->input_icon.set_ports (sinks * count);
2609 (*i)->output_icon.set_ports (sources * count + midi_bypass);
2611 (*i)->routing_icon.set (
2614 sources * count + midi_bypass,
2618 if (next != children.end()) {
2619 (*next)->routing_icon.set_feed (out, sources * count + midi_bypass, pi->output_map ());
2623 (*i)->input_icon.set_ports (p->input_streams());
2624 (*i)->output_icon.set_ports (p->output_streams());
2625 ChanMapping inmap (p->input_streams ());
2626 ChanMapping outmap (p->input_streams ());
2627 (*i)->routing_icon.set (
2629 p->output_streams(),
2631 p->output_streams(),
2634 if (next != children.end()) {
2635 (*next)->routing_icon.set_feed (p->output_streams(), p->output_streams(), outmap);
2639 if (i == children.begin()) {
2640 (*i)->routing_icon.unset_feed ();
2644 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2645 if ((*i)->routing_icon.identity ()) {
2646 (*i)->routing_icon.hide();
2647 if (i == children.begin()) {
2648 (*i)->input_icon.show();
2650 (*i)->input_icon.hide();
2653 (*i)->routing_icon.show();
2654 (*i)->routing_icon.queue_draw();
2655 (*i)->input_icon.show();
2658 list<ProcessorEntry*>::iterator next = i;
2659 if (++next == children.end()) {
2660 // show additional wires if outputs of last processor are not an identity map.
2661 if ((*i)->routing_icon.out_identity ()) {
2662 (*i)->output_routing_icon.hide();
2664 (*i)->output_routing_icon.copy_state ((*i)->routing_icon);
2665 (*i)->output_routing_icon.show();
2668 (*i)->output_routing_icon.hide();
2674 ProcessorBox::setup_entry_positions ()
2676 list<ProcessorEntry*> children = processor_display.children ();
2677 bool pre_fader = true;
2680 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2681 if (boost::dynamic_pointer_cast<Amp>((*i)->processor()) &&
2682 boost::dynamic_pointer_cast<Amp>((*i)->processor())->gain_control()->parameter().type() == GainAutomation) {
2684 (*i)->set_position (ProcessorEntry::Fader, num++);
2687 (*i)->set_position (ProcessorEntry::PreFader, num++);
2689 (*i)->set_position (ProcessorEntry::PostFader, num++);
2693 setup_routing_feeds ();
2697 ProcessorBox::compute_processor_sort_keys ()
2699 list<ProcessorEntry*> children = processor_display.children ();
2700 Route::ProcessorList our_processors;
2702 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2703 if ((*i)->processor()) {
2704 our_processors.push_back ((*i)->processor ());
2708 if (_route->reorder_processors (our_processors)) {
2709 /* Reorder failed, so report this to the user. As far as I can see this must be done
2710 in an idle handler: it seems that the redisplay_processors() that happens below destroys
2711 widgets that were involved in the drag-and-drop on the processor list, which causes problems
2712 when the drag is torn down after this handler function is finished.
2714 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
2719 ProcessorBox::report_failed_reorder ()
2721 /* reorder failed, so redisplay */
2723 redisplay_processors ();
2725 /* now tell them about the problem */
2727 ArdourDialog dialog (_("Plugin Incompatibility"));
2730 label.set_text (_("\
2731 You cannot reorder these plugins/sends/inserts\n\
2732 in that way because the inputs and\n\
2733 outputs will not work correctly."));
2735 dialog.get_vbox()->set_border_width (12);
2736 dialog.get_vbox()->pack_start (label);
2737 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
2739 dialog.set_name (X_("PluginIODialog"));
2740 dialog.set_modal (true);
2747 ProcessorBox::rename_processors ()
2749 ProcSelection to_be_renamed;
2751 get_selected_processors (to_be_renamed);
2753 if (to_be_renamed.empty()) {
2757 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
2758 rename_processor (*i);
2763 ProcessorBox::can_cut () const
2765 vector<boost::shared_ptr<Processor> > sel;
2767 get_selected_processors (sel);
2769 /* cut_processors () does not cut inserts */
2771 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
2773 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
2774 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
2775 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
2784 ProcessorBox::stub_processor_selected () const
2786 vector<boost::shared_ptr<Processor> > sel;
2788 get_selected_processors (sel);
2790 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
2791 if (boost::dynamic_pointer_cast<UnknownProcessor>((*i)) != 0) {
2800 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
2802 if (to_be_removed.empty()) {
2806 XMLNode* node = new XMLNode (X_("cut"));
2807 Route::ProcessorList to_cut;
2809 no_processor_redisplay = true;
2810 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
2811 // Cut only plugins, sends and returns
2812 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
2813 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
2814 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
2816 Window* w = get_processor_ui (*i);
2822 XMLNode& child ((*i)->get_state());
2823 node->add_child_nocopy (child);
2824 to_cut.push_back (*i);
2828 if (_route->remove_processors (to_cut) != 0) {
2830 no_processor_redisplay = false;
2834 _rr_selection.set (node);
2836 no_processor_redisplay = false;
2837 redisplay_processors ();
2841 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
2843 if (to_be_copied.empty()) {
2847 XMLNode* node = new XMLNode (X_("copy"));
2849 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
2850 // Copy only plugins, sends, returns
2851 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
2852 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
2853 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
2854 node->add_child_nocopy ((*i)->get_state());
2858 _rr_selection.set (node);
2862 ProcessorBox::delete_processors (const ProcSelection& targets)
2864 if (targets.empty()) {
2868 no_processor_redisplay = true;
2870 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
2872 Window* w = get_processor_ui (*i);
2878 _route->remove_processor(*i);
2881 no_processor_redisplay = false;
2882 redisplay_processors ();
2886 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
2888 list<boost::shared_ptr<Processor> >::const_iterator x;
2890 no_processor_redisplay = true;
2891 for (x = procs.begin(); x != procs.end(); ++x) {
2893 Window* w = get_processor_ui (*x);
2899 _route->remove_processor(*x);
2902 no_processor_redisplay = false;
2903 redisplay_processors ();
2907 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
2909 boost::shared_ptr<Processor> processor (weak_processor.lock());
2915 /* NOT copied to _mixer.selection() */
2917 no_processor_redisplay = true;
2918 _route->remove_processor (processor);
2919 no_processor_redisplay = false;
2920 redisplay_processors ();
2926 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
2928 ArdourPrompter name_prompter (true);
2930 name_prompter.set_title (_("Rename Processor"));
2931 name_prompter.set_prompt (_("New name:"));
2932 name_prompter.set_initial_text (processor->name());
2933 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
2934 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
2935 name_prompter.show_all ();
2937 switch (name_prompter.run ()) {
2939 case Gtk::RESPONSE_ACCEPT:
2940 name_prompter.get_result (result);
2941 if (result.length()) {
2944 string test = result;
2946 while (tries < 100) {
2947 if (_session->io_name_is_legal (test)) {
2953 test = string_compose ("%1-%2", result, tries);
2957 processor->set_name (result);
2960 ARDOUR_UI::instance()->popup_error
2961 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
2971 ProcessorBox::paste_processors ()
2973 if (_rr_selection.processors.empty()) {
2977 paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
2981 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
2984 if (_rr_selection.processors.empty()) {
2988 paste_processor_state (_rr_selection.processors.get_node().children(), before);
2992 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
2994 XMLNodeConstIterator niter;
2995 list<boost::shared_ptr<Processor> > copies;
2997 if (nlist.empty()) {
3001 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
3003 XMLProperty const * type = (*niter)->property ("type");
3004 XMLProperty const * role = (*niter)->property ("role");
3007 boost::shared_ptr<Processor> p;
3009 if (type->value() == "meter" ||
3010 type->value() == "main-outs" ||
3011 type->value() == "amp" ||
3012 type->value() == "intreturn") {
3013 /* do not paste meter, main outs, amp or internal returns */
3016 } else if (type->value() == "intsend") {
3018 /* aux sends are OK, but those used for
3019 * other purposes, are not.
3024 if (role->value() != "Aux") {
3028 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
3029 XMLNode n (**niter);
3030 InternalSend* s = new InternalSend (*_session, sendpan, _route->mute_master(),
3031 _route, boost::shared_ptr<Route>(), Delivery::Aux);
3033 IOProcessor::prepare_for_reset (n, s->name());
3035 if (s->set_state (n, Stateful::loading_state_version)) {
3042 } else if (type->value() == "send") {
3044 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
3045 XMLNode n (**niter);
3047 Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
3049 IOProcessor::prepare_for_reset (n, s->name());
3051 if (s->set_state (n, Stateful::loading_state_version)) {
3058 } else if (type->value() == "return") {
3060 XMLNode n (**niter);
3061 Return* r = new Return (*_session);
3063 IOProcessor::prepare_for_reset (n, r->name());
3065 if (r->set_state (n, Stateful::loading_state_version)) {
3072 } else if (type->value() == "port") {
3074 XMLNode n (**niter);
3075 PortInsert* pi = new PortInsert (*_session, _route->pannable (), _route->mute_master ());
3077 IOProcessor::prepare_for_reset (n, pi->name());
3079 if (pi->set_state (n, Stateful::loading_state_version)) {
3085 /* XXX its a bit limiting to assume that everything else
3088 p.reset (new PluginInsert (*_session));
3089 PBD::ID id = p->id();
3090 p->set_state (**niter, Stateful::current_state_version);
3091 boost::dynamic_pointer_cast<PluginInsert>(p)->update_id (id);
3094 copies.push_back (p);
3098 error << _("plugin insert constructor failed") << endmsg;
3102 if (copies.empty()) {
3106 if (_route->add_processors (copies, p)) {
3109 "Copying the set of processors on the clipboard failed,\n\
3110 probably because the I/O configuration of the plugins\n\
3111 could not match the configuration of this track.");
3112 MessageDialog am (msg);
3118 ProcessorBox::get_selected_processors (ProcSelection& processors) const
3120 const list<ProcessorEntry*> selection = processor_display.selection ();
3121 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
3122 processors.push_back ((*i)->processor ());
3127 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
3129 list<ProcessorEntry*> selection = processor_display.selection ();
3130 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
3131 (this->*method) ((*i)->processor ());
3136 ProcessorBox::all_visible_processors_active (bool state)
3138 _route->all_visible_processors_active (state);
3142 ProcessorBox::ab_plugins ()
3144 _route->ab_plugins (ab_direction);
3145 ab_direction = !ab_direction;
3150 ProcessorBox::clear_processors ()
3153 vector<string> choices;
3155 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
3156 "(this cannot be undone)"), _route->name());
3158 choices.push_back (_("Cancel"));
3159 choices.push_back (_("Yes, remove them all"));
3161 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
3163 if (prompter.run () == 1) {
3164 _route->clear_processors (PreFader);
3165 _route->clear_processors (PostFader);
3170 ProcessorBox::clear_processors (Placement p)
3173 vector<string> choices;
3175 if (p == PreFader) {
3176 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
3177 "(this cannot be undone)"), _route->name());
3179 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
3180 "(this cannot be undone)"), _route->name());
3183 choices.push_back (_("Cancel"));
3184 choices.push_back (_("Yes, remove them all"));
3186 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
3188 if (prompter.run () == 1) {
3189 _route->clear_processors (p);
3194 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
3196 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
3197 if (at && at->freeze_state() == AudioTrack::Frozen) {
3202 boost::dynamic_pointer_cast<Send> (processor) ||
3203 boost::dynamic_pointer_cast<Return> (processor) ||
3204 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
3205 boost::dynamic_pointer_cast<PortInsert> (processor)
3214 ProcessorBox::one_processor_can_be_edited ()
3216 list<ProcessorEntry*> selection = processor_display.selection ();
3217 list<ProcessorEntry*>::iterator i = selection.begin();
3218 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
3222 return (i != selection.end());
3226 ProcessorBox::get_editor_window (boost::shared_ptr<Processor> processor, bool use_custom)
3228 boost::shared_ptr<Send> send;
3229 boost::shared_ptr<InternalSend> internal_send;
3230 boost::shared_ptr<Return> retrn;
3231 boost::shared_ptr<PluginInsert> plugin_insert;
3232 boost::shared_ptr<PortInsert> port_insert;
3235 /* This method may or may not return a Window, but if it does not it
3236 * will modify the parent mixer strip appearance layout to allow
3237 * "editing" the @param processor that was passed in.
3239 * So for example, if the processor is an Amp (gain), the parent strip
3240 * will be forced back into a model where the fader controls the main gain.
3241 * If the processor is a send, then we map the send controls onto the
3244 * Plugins and others will return a window for control.
3247 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
3249 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
3254 if (boost::dynamic_pointer_cast<Amp> (processor) && boost::dynamic_pointer_cast<Amp> (processor)->gain_control()->parameter().type() == GainAutomation) {
3256 if (_parent_strip) {
3257 _parent_strip->revert_to_default_display ();
3260 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
3262 if (!_session->engine().connected()) {
3266 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
3268 gidget = new SendUIWindow (send, _session);
3271 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
3273 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
3274 /* no GUI for these */
3278 if (!_session->engine().connected()) {
3282 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
3284 ReturnUIWindow *return_ui;
3285 Window* w = get_processor_ui (retrn);
3289 return_ui = new ReturnUIWindow (retrn, _session);
3290 return_ui->set_title (retrn->name ());
3291 set_processor_ui (send, return_ui);
3294 return_ui = dynamic_cast<ReturnUIWindow *> (w);
3299 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
3301 PluginUIWindow *plugin_ui;
3303 /* these are both allowed to be null */
3305 Window* w = get_processor_ui (plugin_insert);
3308 plugin_ui = new PluginUIWindow (plugin_insert, false, use_custom);
3309 plugin_ui->set_title (generate_processor_title (plugin_insert));
3310 set_processor_ui (plugin_insert, plugin_ui);
3313 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
3318 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
3320 if (!_session->engine().connected()) {
3321 MessageDialog msg ( _("Not connected to audio engine - no I/O changes are possible"));
3326 PortInsertWindow *io_selector;
3328 Window* w = get_processor_ui (port_insert);
3331 io_selector = new PortInsertWindow (_session, port_insert);
3332 set_processor_ui (port_insert, io_selector);
3335 io_selector = dynamic_cast<PortInsertWindow *> (w);
3338 gidget = io_selector;
3345 ProcessorBox::get_generic_editor_window (boost::shared_ptr<Processor> processor)
3347 boost::shared_ptr<PluginInsert> plugin_insert
3348 = boost::dynamic_pointer_cast<PluginInsert>(processor);
3350 if (!plugin_insert) {
3354 PluginUIWindow* win = new PluginUIWindow (plugin_insert, true, false);
3355 win->set_title (generate_processor_title (plugin_insert));
3361 ProcessorBox::register_actions ()
3363 processor_box_actions = myactions.create_action_group (X_("ProcessorMenu"));
3365 Glib::RefPtr<Action> act;
3368 myactions.register_action (processor_box_actions, X_("newplugin"), _("New Plugin"),
3369 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
3371 act = myactions.register_action (processor_box_actions, X_("newlua"), _("New Lua Proc"),
3372 sigc::ptr_fun (ProcessorBox::rb_choose_lua));
3373 act = myactions.register_action (processor_box_actions, X_("newinsert"), _("New Insert"),
3374 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
3375 ActionManager::engine_sensitive_actions.push_back (act);
3376 act = myactions.register_action (processor_box_actions, X_("newsend"), _("New External Send ..."),
3377 sigc::ptr_fun (ProcessorBox::rb_choose_send));
3378 ActionManager::engine_sensitive_actions.push_back (act);
3380 myactions.register_action (processor_box_actions, X_("newaux"), _("New Aux Send ..."));
3382 myactions.register_action (processor_box_actions, X_("controls"), _("Controls"));
3383 myactions.register_action (processor_box_actions, X_("send_options"), _("Send Options"));
3385 myactions.register_action (processor_box_actions, X_("clear"), _("Clear (all)"),
3386 sigc::ptr_fun (ProcessorBox::rb_clear));
3387 myactions.register_action (processor_box_actions, X_("clear_pre"), _("Clear (pre-fader)"),
3388 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
3389 myactions.register_action (processor_box_actions, X_("clear_post"), _("Clear (post-fader)"),
3390 sigc::ptr_fun (ProcessorBox::rb_clear_post));
3392 /* standard editing stuff */
3394 cut_action = myactions.register_action (processor_box_actions, X_("cut"), _("Cut"),
3395 sigc::ptr_fun (ProcessorBox::rb_cut));
3396 copy_action = myactions.register_action (processor_box_actions, X_("copy"), _("Copy"),
3397 sigc::ptr_fun (ProcessorBox::rb_copy));
3398 delete_action = myactions.register_action (processor_box_actions, X_("delete"), _("Delete"),
3399 sigc::ptr_fun (ProcessorBox::rb_delete));
3401 ActionManager::plugin_selection_sensitive_actions.push_back (cut_action);
3402 ActionManager::plugin_selection_sensitive_actions.push_back (copy_action);
3403 ActionManager::plugin_selection_sensitive_actions.push_back (delete_action);
3405 paste_action = myactions.register_action (processor_box_actions, X_("paste"), _("Paste"),
3406 sigc::ptr_fun (ProcessorBox::rb_paste));
3407 rename_action = myactions.register_action (processor_box_actions, X_("rename"), _("Rename"),
3408 sigc::ptr_fun (ProcessorBox::rb_rename));
3409 myactions.register_action (processor_box_actions, X_("selectall"), _("Select All"),
3410 sigc::ptr_fun (ProcessorBox::rb_select_all));
3411 myactions.register_action (processor_box_actions, X_("deselectall"), _("Deselect All"),
3412 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
3414 /* activation etc. */
3416 myactions.register_action (processor_box_actions, X_("activate_all"), _("Activate All"),
3417 sigc::ptr_fun (ProcessorBox::rb_activate_all));
3418 myactions.register_action (processor_box_actions, X_("deactivate_all"), _("Deactivate All"),
3419 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
3420 myactions.register_action (processor_box_actions, X_("ab_plugins"), _("A/B Plugins"),
3421 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
3423 manage_pins_action = myactions.register_action (
3424 processor_box_actions, X_("manage-pins"), _("Pin Management..."),
3425 sigc::ptr_fun (ProcessorBox::rb_manage_pins));
3428 edit_action = myactions.register_action (
3429 processor_box_actions, X_("edit"), _("Edit..."),
3430 sigc::ptr_fun (ProcessorBox::rb_edit));
3432 edit_generic_action = myactions.register_action (
3433 processor_box_actions, X_("edit-generic"), _("Edit with generic controls..."),
3434 sigc::ptr_fun (ProcessorBox::rb_edit_generic));
3440 ProcessorBox::rb_edit_generic ()
3442 if (_current_processor_box == 0) {
3446 _current_processor_box->for_selected_processors (&ProcessorBox::generic_edit_processor);
3450 ProcessorBox::rb_ab_plugins ()
3452 if (_current_processor_box == 0) {
3456 _current_processor_box->ab_plugins ();
3460 ProcessorBox::rb_manage_pins ()
3462 if (_current_processor_box == 0) {
3466 _current_processor_box->for_selected_processors (&ProcessorBox::manage_pins);
3469 ProcessorBox::rb_choose_plugin ()
3471 if (_current_processor_box == 0) {
3474 _current_processor_box->choose_plugin ();
3478 ProcessorBox::rb_choose_lua ()
3480 if (_current_processor_box == 0) {
3483 _current_processor_box->choose_lua ();
3487 ProcessorBox::rb_choose_insert ()
3489 if (_current_processor_box == 0) {
3492 _current_processor_box->choose_insert ();
3496 ProcessorBox::rb_choose_send ()
3498 if (_current_processor_box == 0) {
3501 _current_processor_box->choose_send ();
3505 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
3507 if (_current_processor_box == 0) {
3511 _current_processor_box->choose_aux (wr);
3515 ProcessorBox::rb_clear ()
3517 if (_current_processor_box == 0) {
3521 _current_processor_box->clear_processors ();
3526 ProcessorBox::rb_clear_pre ()
3528 if (_current_processor_box == 0) {
3532 _current_processor_box->clear_processors (PreFader);
3537 ProcessorBox::rb_clear_post ()
3539 if (_current_processor_box == 0) {
3543 _current_processor_box->clear_processors (PostFader);
3547 ProcessorBox::rb_cut ()
3549 if (_current_processor_box == 0) {
3553 _current_processor_box->processor_operation (ProcessorsCut);
3557 ProcessorBox::rb_delete ()
3559 if (_current_processor_box == 0) {
3563 _current_processor_box->processor_operation (ProcessorsDelete);
3567 ProcessorBox::rb_copy ()
3569 if (_current_processor_box == 0) {
3572 _current_processor_box->processor_operation (ProcessorsCopy);
3576 ProcessorBox::rb_paste ()
3578 if (_current_processor_box == 0) {
3582 _current_processor_box->processor_operation (ProcessorsPaste);
3586 ProcessorBox::rb_rename ()
3588 if (_current_processor_box == 0) {
3591 _current_processor_box->rename_processors ();
3595 ProcessorBox::rb_select_all ()
3597 if (_current_processor_box == 0) {
3601 _current_processor_box->processor_operation (ProcessorsSelectAll);
3605 ProcessorBox::rb_deselect_all ()
3607 if (_current_processor_box == 0) {
3611 _current_processor_box->deselect_all_processors ();
3615 ProcessorBox::rb_activate_all ()
3617 if (_current_processor_box == 0) {
3621 _current_processor_box->all_visible_processors_active (true);
3625 ProcessorBox::rb_deactivate_all ()
3627 if (_current_processor_box == 0) {
3630 _current_processor_box->all_visible_processors_active (false);
3634 ProcessorBox::rb_edit ()
3636 if (_current_processor_box == 0) {
3640 _current_processor_box->for_selected_processors (&ProcessorBox::edit_processor);
3644 ProcessorBox::edit_aux_send (boost::shared_ptr<Processor> processor)
3646 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
3650 if (_parent_strip) {
3651 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
3652 if (_parent_strip->current_delivery() == send) {
3653 _parent_strip->revert_to_default_display ();
3655 _parent_strip->show_send(send);
3662 ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
3667 if (edit_aux_send (processor)) {
3671 ProcessorWindowProxy* proxy = find_window_proxy (processor);
3674 proxy->set_custom_ui_mode (true);
3675 proxy->show_the_right_window ();
3680 ProcessorBox::generic_edit_processor (boost::shared_ptr<Processor> processor)
3685 if (edit_aux_send (processor)) {
3689 ProcessorWindowProxy* proxy = find_window_proxy (processor);
3692 proxy->set_custom_ui_mode (false);
3693 proxy->show_the_right_window ();
3698 ProcessorBox::manage_pins (boost::shared_ptr<Processor> processor)
3703 PluginPinWindowProxy* proxy = processor->pinmgr_proxy ();
3712 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
3714 if (!what_changed.contains (ARDOUR::Properties::name)) {
3718 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
3720 boost::shared_ptr<Processor> processor;
3721 boost::shared_ptr<PluginInsert> plugin_insert;
3722 boost::shared_ptr<Send> send;
3724 list<ProcessorEntry*> children = processor_display.children();
3726 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
3728 processor = (*iter)->processor ();
3734 Window* w = get_processor_ui (processor);
3740 /* rename editor windows for sends and plugins */
3742 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
3743 w->set_title (send->name ());
3744 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
3745 w->set_title (generate_processor_title (plugin_insert));
3751 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
3753 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
3754 string::size_type email_pos;
3756 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
3757 maker = maker.substr (0, email_pos - 1);
3760 if (maker.length() > 32) {
3761 maker = maker.substr (0, 32);
3765 SessionObject* owner = pi->owner();
3768 return string_compose(_("%1: %2 (by %3)"), owner->name(), pi->name(), maker);
3770 return string_compose(_("%1 (by %2)"), pi->name(), maker);
3774 /** @param p Processor.
3775 * @return the UI window for \a p.
3778 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
3780 ProcessorWindowProxy* wp = p->window_proxy();
3787 /** Make a note of the UI window that a processor is using.
3788 * @param p Processor.
3789 * @param w UI window.
3792 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
3794 assert (p->window_proxy());
3796 p->window_proxy()->use_window (*w);
3800 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
3802 boost::shared_ptr<Delivery> d = w.lock ();
3807 list<ProcessorEntry*> children = processor_display.children ();
3808 list<ProcessorEntry*>::const_iterator i = children.begin();
3809 while (i != children.end() && (*i)->processor() != d) {
3813 if (i == children.end()) {
3814 processor_display.set_active (0);
3816 processor_display.set_active (*i);
3820 /** Called to repair the damage of Editor::show_window doing a show_all() */
3822 ProcessorBox::hide_things ()
3824 list<ProcessorEntry*> c = processor_display.children ();
3825 for (list<ProcessorEntry*>::iterator i = c.begin(); i != c.end(); ++i) {
3826 (*i)->hide_things ();
3831 ProcessorBox::processor_menu_unmapped ()
3833 processor_display.remove_placeholder ();
3834 /* make all possibly-desensitized actions sensitive again so that
3835 they be activated by other means (e.g. bindings)
3837 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, true);
3841 ProcessorBox::entry_gui_object_state (ProcessorEntry* entry)
3843 if (!_parent_strip) {
3847 GUIObjectState& st = _parent_strip->gui_object_state ();
3849 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
3851 return st.get_or_add_node (strip, entry->state_id());
3855 ProcessorBox::update_gui_object_state (ProcessorEntry* entry)
3857 XMLNode* proc = entry_gui_object_state (entry);
3862 /* XXX: this is a bit inefficient; we just remove all child nodes and re-add them */
3863 proc->remove_nodes_and_delete (X_("Object"));
3864 entry->add_control_state (proc);
3868 ProcessorBox::is_editor_mixer_strip() const
3870 return _parent_strip && !_parent_strip->mixer_owned();
3873 ProcessorWindowProxy::ProcessorWindowProxy (string const & name, ProcessorBox* box, boost::weak_ptr<Processor> processor)
3874 : WM::ProxyBase (name, string())
3875 , _processor_box (box)
3876 , _processor (processor)
3878 , want_custom (false)
3880 boost::shared_ptr<Processor> p = _processor.lock ();
3884 p->DropReferences.connect (going_away_connection, MISSING_INVALIDATOR, boost::bind (&ProcessorWindowProxy::processor_going_away, this), gui_context());
3887 ProcessorWindowProxy::~ProcessorWindowProxy()
3889 /* processor window proxies do not own the windows they create with
3890 * ::get(), so set _window to null before the normal WindowProxy method
3897 ProcessorWindowProxy::processor_going_away ()
3901 WM::Manager::instance().remove (this);
3902 /* should be no real reason to do this, since the object that would
3903 send DropReferences is about to be deleted, but lets do it anyway.
3905 going_away_connection.disconnect();
3908 ARDOUR::SessionHandlePtr*
3909 ProcessorWindowProxy::session_handle()
3916 ProcessorWindowProxy::get_state ()
3919 node = &ProxyBase::get_state();
3920 node->add_property (X_("custom-ui"), is_custom? X_("yes") : X_("no"));
3925 ProcessorWindowProxy::set_state (const XMLNode& node, int /*version*/)
3927 XMLNodeList children = node.children ();
3928 XMLNodeList::const_iterator i = children.begin ();
3929 while (i != children.end()) {
3930 XMLProperty* prop = (*i)->property (X_("name"));
3931 if ((*i)->name() == X_("Window") && prop && prop->value() == _name) {
3937 if (i != children.end()) {
3939 if ((prop = (*i)->property (X_("custom-ui"))) != 0) {
3940 want_custom = PBD::string_is_affirmative (prop->value ());
3944 return ProxyBase::set_state (node, 0);
3948 ProcessorWindowProxy::get (bool create)
3950 boost::shared_ptr<Processor> p = _processor.lock ();
3955 if (_window && (is_custom != want_custom)) {
3956 /* drop existing window - wrong type */
3965 is_custom = want_custom;
3966 _window = _processor_box->get_editor_window (p, is_custom);
3972 _window->show_all ();
3977 ProcessorWindowProxy::show_the_right_window ()
3979 if (_window && (is_custom != want_custom)) {
3980 /* drop existing window - wrong type */
3985 is_custom = want_custom;
3992 PluginPinWindowProxy::PluginPinWindowProxy(std::string const &name, boost::weak_ptr<ARDOUR::Processor> processor)
3993 : WM::ProxyBase (name, string())
3994 , _processor (processor)
3996 boost::shared_ptr<Processor> p = _processor.lock ();
4000 p->DropReferences.connect (going_away_connection, MISSING_INVALIDATOR, boost::bind (&PluginPinWindowProxy::processor_going_away, this), gui_context());
4003 PluginPinWindowProxy::~PluginPinWindowProxy()
4008 ARDOUR::SessionHandlePtr*
4009 PluginPinWindowProxy::session_handle ()
4011 ArdourWindow* aw = dynamic_cast<ArdourWindow*> (_window);
4012 if (aw) { return aw; }
4017 PluginPinWindowProxy::get (bool create)
4019 boost::shared_ptr<Processor> p = _processor.lock ();
4020 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (p);
4029 _window = new PluginPinDialog (pi);
4030 ArdourWindow* aw = dynamic_cast<ArdourWindow*> (_window);
4032 aw->set_session (_session);
4036 _window->show_all ();
4041 PluginPinWindowProxy::processor_going_away ()
4045 WM::Manager::instance().remove (this);
4046 going_away_connection.disconnect();
4050 ProcessorBox::load_bindings ()
4052 bindings = Bindings::get_bindings (X_("Processor Box"), myactions);