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)
154 _button.set_distinct_led_click (true);
155 _button.set_fallthrough_to_parent(true);
156 _button.set_led_left (true);
157 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &ProcessorEntry::led_clicked));
158 _button.set_text (name (_width));
160 if (boost::dynamic_pointer_cast<PeakMeter> (_processor)) {
161 _button.set_elements(ArdourButton::Element(_button.elements() & ~ArdourButton::Indicator));
163 if (boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
164 _button.set_elements(ArdourButton::Element(_button.elements() & ~ArdourButton::Indicator));
165 _unknown_processor = true;
168 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
169 if (pi && pi->plugin() && pi->plugin()->get_info()->type != ARDOUR::Lua) {
170 _plugin_preset_pointer = PluginPresetPtr (new PluginPreset (pi->plugin()->get_info()));
175 _vbox.pack_start (routing_icon);
176 _vbox.pack_start (input_icon);
177 _vbox.pack_start (_button, true, true);
179 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
180 if (pi && pi->plugin() && pi->plugin()->has_inline_display()) {
181 if (pi->plugin()->get_info()->type != ARDOUR::Lua) {
182 _plugin_display = new PluginDisplay (pi->plugin(),
183 std::max (60.f, rintf(112.f * UIConfiguration::instance().get_ui_scale())));
185 assert (boost::dynamic_pointer_cast<LuaProc>(pi->plugin()));
186 _plugin_display = new LuaPluginDisplay (boost::dynamic_pointer_cast<LuaProc>(pi->plugin()),
187 std::max (60.f, rintf(112.f * UIConfiguration::instance().get_ui_scale())));
189 _vbox.pack_start (*_plugin_display);
190 _plugin_display->set_no_show_all (true);
191 if (UIConfiguration::instance().get_show_inline_display_by_default ()) {
192 _plugin_display->show ();
195 _vbox.pack_end (output_icon);
197 _button.set_active (_processor->active());
199 routing_icon.set_no_show_all(true);
200 input_icon.set_no_show_all(true);
207 _processor->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_active_changed, this), gui_context());
208 _processor->PropertyChanged.connect (name_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_property_changed, this, _1), gui_context());
209 _processor->ConfigurationChanged.connect (config_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_configuration_changed, this, _1, _2), gui_context());
211 set<Evoral::Parameter> p = _processor->what_can_be_automated ();
212 for (set<Evoral::Parameter>::iterator i = p.begin(); i != p.end(); ++i) {
214 std::string label = _processor->describe_parameter (*i);
216 if (boost::dynamic_pointer_cast<Send> (_processor)) {
218 } else if (boost::dynamic_pointer_cast<Return> (_processor)) {
222 Control* c = new Control (_processor->automation_control (*i), label);
224 _controls.push_back (c);
226 if (boost::dynamic_pointer_cast<Amp> (_processor) == 0) {
227 /* Add non-Amp (Fader & Trim) controls to the processor box */
228 _vbox.pack_start (c->box);
235 _vbox.set_size_request (-1, _button.size_request().height);
239 ProcessorEntry::~ProcessorEntry ()
241 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
244 delete _plugin_display;
248 ProcessorEntry::action_widget ()
254 ProcessorEntry::widget ()
260 ProcessorEntry::drag_text () const
266 ProcessorEntry::can_copy_state (Gtkmm2ext::DnDVBoxChild* o) const
268 ProcessorEntry *other = dynamic_cast<ProcessorEntry*> (o);
272 boost::shared_ptr<ARDOUR::Processor> otherproc = other->processor();
273 boost::shared_ptr<PluginInsert> my_pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
274 boost::shared_ptr<PluginInsert> ot_pi = boost::dynamic_pointer_cast<PluginInsert> (otherproc);
275 if (boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
278 if (boost::dynamic_pointer_cast<UnknownProcessor> (otherproc)) {
281 if (!my_pi || !ot_pi) {
284 if (my_pi->type() != ot_pi->type()) {
287 boost::shared_ptr<Plugin> my_p = my_pi->plugin();
288 boost::shared_ptr<Plugin> ot_p = ot_pi->plugin();
289 if (!my_p || !ot_p) {
292 if (my_p->unique_id() != ot_p->unique_id()) {
299 ProcessorEntry::drag_data_get (Glib::RefPtr<Gdk::DragContext> const, Gtk::SelectionData &data)
301 if (data.get_target() == "PluginPresetPtr") {
302 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
304 if (!_plugin_preset_pointer || !pi) {
305 data.set (data.get_target(), 8, NULL, 0);
309 boost::shared_ptr<ARDOUR::Plugin> plugin = pi->plugin();
312 PluginManager& manager (PluginManager::instance());
313 bool fav = manager.get_status (_plugin_preset_pointer->_pip) == PluginManager::Favorite;
315 NewPluginPresetDialog d (plugin,
316 string_compose(_("New Favorite Preset for \"%1\""),_plugin_preset_pointer->_pip->name), !fav);
318 _plugin_preset_pointer->_preset.valid = false;
321 case Gtk::RESPONSE_CANCEL:
322 data.set (data.get_target(), 8, NULL, 0);
326 case Gtk::RESPONSE_NO:
329 case Gtk::RESPONSE_ACCEPT:
330 if (d.name().empty()) {
335 plugin->remove_preset (d.name ());
338 Plugin::PresetRecord const r = plugin->save_preset (d.name());
340 if (!r.uri.empty ()) {
341 _plugin_preset_pointer->_preset.uri = r.uri;
342 _plugin_preset_pointer->_preset.label = r.label;
343 _plugin_preset_pointer->_preset.user = r.user;
344 _plugin_preset_pointer->_preset.valid = r.valid;
347 data.set (data.get_target(), 8, (const guchar *) &_plugin_preset_pointer, sizeof (PluginPresetPtr));
354 ProcessorEntry::set_position (Position p, uint32_t num)
362 ProcessorEntry::set_visual_state (Gtkmm2ext::VisualState s, bool yn)
365 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() | s));
367 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() & ~s));
372 ProcessorEntry::setup_visuals ()
374 if (_unknown_processor) {
375 _button.set_name ("processor stub");
381 if (_plugin_display) { _plugin_display->set_name ("processor prefader"); }
382 _button.set_name ("processor prefader");
386 _button.set_name ("processor fader");
390 if (_plugin_display) { _plugin_display->set_name ("processor postfader"); }
391 _button.set_name ("processor postfader");
397 boost::shared_ptr<Processor>
398 ProcessorEntry::processor () const
401 return boost::shared_ptr<Processor>();
407 ProcessorEntry::set_enum_width (Width w)
410 _button.set_text (name (_width));
414 ProcessorEntry::led_clicked(GdkEventButton *ev)
416 bool ctrl_shift_pressed = false;
417 Keyboard::ModifierMask ctrl_shift_mask = Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier);
419 if (Keyboard::modifier_state_equals (ev->state, ctrl_shift_mask)) {
420 ctrl_shift_pressed = true;
424 if (_button.get_active ()) {
425 if (ctrl_shift_pressed) {
426 _parent->all_visible_processors_active(false);
428 if (_position == Fader) {
429 _processor->deactivate ();
433 _processor->deactivate ();
437 if (ctrl_shift_pressed) {
438 _parent->all_visible_processors_active(true);
440 if (_position == Fader) {
441 _processor->activate ();
445 _processor->activate ();
452 ProcessorEntry::processor_active_changed ()
455 _button.set_active (_processor->active());
460 ProcessorEntry::processor_property_changed (const PropertyChange& what_changed)
462 if (what_changed.contains (ARDOUR::Properties::name)) {
463 _button.set_text (name (_width));
469 ProcessorEntry::processor_configuration_changed (const ChanCount in, const ChanCount out)
471 _parent->setup_routing_feeds ();
472 input_icon.queue_draw();
473 output_icon.queue_draw();
474 routing_icon.queue_draw();
478 ProcessorEntry::setup_tooltip ()
481 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
483 std::string postfix = "";
485 if ((replicated = pi->get_count()) > 1) {
486 postfix = string_compose(_("\nThis mono plugin has been replicated %1 times."), replicated);
488 if (pi->plugin()->has_editor()) {
489 ARDOUR_UI_UTILS::set_tooltip (_button,
490 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));
492 ARDOUR_UI_UTILS::set_tooltip (_button,
493 string_compose (_("<b>%1</b>\nDouble-click to show generic GUI.%2"), name (Wide), postfix));
497 if(boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
498 ARDOUR_UI::instance()->set_tip (_button,
499 string_compose (_("<b>%1</b>\nThe Plugin is not available on this system\nand has been replaced by a stub."), name (Wide)));
503 ARDOUR_UI_UTILS::set_tooltip (_button, string_compose ("<b>%1</b>", name (Wide)));
507 ProcessorEntry::name (Width w) const
509 boost::shared_ptr<Send> send;
516 if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
517 !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
521 /* grab the send name out of its overall name */
523 string::size_type lbracket, rbracket;
524 lbracket = send->name().find ('[');
525 rbracket = send->name().find (']');
529 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
532 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
537 boost::shared_ptr<ARDOUR::PluginInsert> pi;
539 if ((pi = boost::dynamic_pointer_cast<ARDOUR::PluginInsert> (_processor)) != 0
540 && (replicated = pi->get_count()) > 1)
542 name_display += string_compose(_("(%1x1) "), replicated);
547 name_display += _processor->display_name();
550 name_display += PBD::short_version (_processor->display_name(), 5);
560 ProcessorEntry::show_all_controls ()
562 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
563 (*i)->set_visible (true);
566 _parent->update_gui_object_state (this);
570 ProcessorEntry::hide_all_controls ()
572 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
573 (*i)->set_visible (false);
576 _parent->update_gui_object_state (this);
580 ProcessorEntry::add_control_state (XMLNode* node) const
582 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
583 (*i)->add_state (node);
586 if (_plugin_display) {
587 XMLNode* c = new XMLNode (X_("Object"));
588 c->add_property (X_("id"), X_("InlineDisplay"));
589 c->add_property (X_("visible"), _plugin_display->is_visible ());
590 node->add_child_nocopy (*c);
595 ProcessorEntry::set_control_state (XMLNode const * node)
597 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
598 (*i)->set_state (node);
601 if (_plugin_display) {
602 XMLNode* n = GUIObjectState::get_node (node, X_("InlineDisplay"));
603 XMLProperty* p = n ? n->property (X_("visible")) : NULL;
605 if (string_is_affirmative (p->value ())) {
606 _plugin_display->show();
608 _plugin_display->hide();
615 ProcessorEntry::state_id () const
617 return string_compose ("processor %1", _processor->id().to_s());
621 ProcessorEntry::hide_things ()
623 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
624 (*i)->hide_things ();
630 ProcessorEntry::build_controls_menu ()
632 using namespace Menu_Helpers;
633 Menu* menu = manage (new Menu);
634 MenuList& items = menu->items ();
636 if (_plugin_display) {
637 items.push_back (CheckMenuElem (_("Inline Display")));
638 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
639 c->set_active (_plugin_display->is_visible ());
640 c->signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::toggle_inline_display_visibility));
641 items.push_back (SeparatorElem ());
645 MenuElem (_("Show All Controls"), sigc::mem_fun (*this, &ProcessorEntry::show_all_controls))
649 MenuElem (_("Hide All Controls"), sigc::mem_fun (*this, &ProcessorEntry::hide_all_controls))
652 if (!_controls.empty ()) {
653 items.push_back (SeparatorElem ());
656 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
657 items.push_back (CheckMenuElem ((*i)->name ()));
658 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
659 c->set_active ((*i)->visible ());
660 c->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &ProcessorEntry::toggle_control_visibility), *i));
667 ProcessorEntry::toggle_inline_display_visibility ()
669 if (_plugin_display->is_visible ()) {
670 _plugin_display->hide();
672 _plugin_display->show();
674 _parent->update_gui_object_state (this);
678 ProcessorEntry::toggle_control_visibility (Control* c)
680 c->set_visible (!c->visible ());
681 _parent->update_gui_object_state (this);
685 ProcessorEntry::build_send_options_menu ()
687 using namespace Menu_Helpers;
688 Menu* menu = manage (new Menu);
689 MenuList& items = menu->items ();
691 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (_processor);
694 items.push_back (CheckMenuElem (_("Link panner controls")));
695 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
696 c->set_active (send->panner_shell()->is_linked_to_route());
697 c->signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::toggle_panner_link));
704 ProcessorEntry::toggle_panner_link ()
706 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (_processor);
708 send->panner_shell()->set_linked_to_route(!send->panner_shell()->is_linked_to_route());
712 ProcessorEntry::Control::Control (boost::shared_ptr<AutomationControl> c, string const & n)
714 , _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1)
715 , _slider (&_adjustment, boost::shared_ptr<PBD::Controllable>(), 0, max(13.f, rintf(13.f * UIConfiguration::instance().get_ui_scale())))
716 , _slider_persistant_tooltip (&_slider)
717 , _button (ArdourButton::led_default_elements)
718 , _ignore_ui_adjustment (false)
722 _slider.set_controllable (c);
723 box.set_padding(0, 0, 4, 4);
726 _button.set_text (_name);
727 _button.set_led_left (true);
728 _button.set_name ("processor control button");
732 _button.signal_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked));
733 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked_event));
734 // dup. currently timers are used :(
735 //c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
739 _slider.set_name ("ProcessorControlSlider");
740 _slider.set_text (_name);
745 const ARDOUR::ParameterDescriptor& desc = c->desc();
746 double const lo = c->internal_to_interface(desc.lower);
747 double const up = c->internal_to_interface(desc.upper);
748 double const normal = c->internal_to_interface(desc.normal);
749 double smallstep = desc.smallstep;
750 double largestep = desc.largestep;
752 if (smallstep == 0.0) {
753 smallstep = up / 1000.;
755 smallstep = c->internal_to_interface(desc.lower + smallstep);
758 if (largestep == 0.0) {
759 largestep = up / 40.;
761 largestep = c->internal_to_interface(desc.lower + largestep);
764 _adjustment.set_lower (lo);
765 _adjustment.set_upper (up);
766 _adjustment.set_step_increment (smallstep);
767 _adjustment.set_page_increment (largestep);
768 _slider.set_default_value (normal);
770 _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &Control::slider_adjusted));
771 // dup. currently timers are used :(
772 //c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
775 // yuck, do we really need to do this?
776 // according to c404374 this is only needed for send automation
777 timer_connection = Timers::rapid_connect (sigc::mem_fun (*this, &Control::control_changed));
782 /* We're providing our own PersistentTooltip */
783 set_no_tooltip_whatsoever (_slider);
786 ProcessorEntry::Control::~Control ()
788 timer_connection.disconnect ();
792 ProcessorEntry::Control::set_tooltip ()
794 boost::shared_ptr<AutomationControl> c = _control.lock ();
801 snprintf (tmp, sizeof(tmp), "%s: %s", _name.c_str(), c->get_value() > 0.5 ? _("on") : _("off"));
803 snprintf (tmp, sizeof(tmp), "%s: %.2f", _name.c_str(), c->internal_to_user (c->get_value ()));
806 string sm = Gtkmm2ext::markup_escape_text (tmp);
807 _slider_persistant_tooltip.set_tip (sm);
808 ARDOUR_UI_UTILS::set_tooltip (_button, sm);
812 ProcessorEntry::Control::slider_adjusted ()
814 if (_ignore_ui_adjustment) {
818 boost::shared_ptr<AutomationControl> c = _control.lock ();
824 c->set_value ( c->interface_to_internal(_adjustment.get_value ()) , Controllable::NoGroup);
829 ProcessorEntry::Control::button_clicked ()
831 boost::shared_ptr<AutomationControl> c = _control.lock ();
837 bool const n = _button.get_active ();
839 c->set_value (n ? 0 : 1, Controllable::NoGroup);
840 _button.set_active (!n);
845 ProcessorEntry::Control::button_clicked_event (GdkEventButton *ev)
853 ProcessorEntry::Control::control_changed ()
855 boost::shared_ptr<AutomationControl> c = _control.lock ();
860 _ignore_ui_adjustment = true;
864 _button.set_active (c->get_value() > 0.5);
867 // as long as rapid timers are used, only update the tooltip
868 // if the value has changed.
869 const double nval = c->internal_to_interface (c->get_value ());
870 if (_adjustment.get_value() != nval) {
871 _adjustment.set_value (nval);
876 _ignore_ui_adjustment = false;
880 ProcessorEntry::Control::add_state (XMLNode* node) const
882 XMLNode* c = new XMLNode (X_("Object"));
883 c->add_property (X_("id"), state_id ());
884 c->add_property (X_("visible"), _visible);
885 node->add_child_nocopy (*c);
889 ProcessorEntry::Control::set_state (XMLNode const * node)
891 XMLNode* n = GUIObjectState::get_node (node, state_id ());
893 XMLProperty* p = n->property (X_("visible"));
894 set_visible (p && string_is_affirmative (p->value ()));
901 ProcessorEntry::Control::set_visible (bool v)
912 /** Called when the Editor might have re-shown things that
916 ProcessorEntry::Control::hide_things ()
924 ProcessorEntry::Control::state_id () const
926 boost::shared_ptr<AutomationControl> c = _control.lock ();
929 return string_compose (X_("control %1"), c->id().to_s ());
932 PluginInsertProcessorEntry::PluginInsertProcessorEntry (ProcessorBox* b, boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
933 : ProcessorEntry (b, p, w)
936 p->PluginIoReConfigure.connect (
937 _iomap_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::iomap_changed, this), gui_context()
939 p->PluginMapChanged.connect (
940 _iomap_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::iomap_changed, this), gui_context()
942 p->PluginConfigChanged.connect (
943 _iomap_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::iomap_changed, this), gui_context()
948 PluginInsertProcessorEntry::iomap_changed ()
950 _parent->setup_routing_feeds ();
951 routing_icon.queue_draw();
955 PluginInsertProcessorEntry::hide_things ()
957 ProcessorEntry::hide_things ();
960 ProcessorEntry::PortIcon::PortIcon(bool input) {
962 _ports = ARDOUR::ChanCount(ARDOUR::DataType::AUDIO, 1);
963 set_size_request (-1, std::max (2.f, rintf(2.f * UIConfiguration::instance().get_ui_scale())));
967 ProcessorEntry::PortIcon::on_expose_event (GdkEventExpose* ev)
969 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
971 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
974 Gtk::Allocation a = get_allocation();
975 double const width = a.get_width();
976 double const height = a.get_height();
978 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
979 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
981 cairo_rectangle (cr, 0, 0, width, height);
984 const double dx = rint(max(2., 2. * UIConfiguration::instance().get_ui_scale()));
985 if (_ports.n_total() > 1) {
986 for (uint32_t i = 0; i < _ports.n_total(); ++i) {
987 set_routing_color (cr, i < _ports.n_midi());
988 const float x = rintf(width * (.2f + .6f * i / (_ports.n_total() - 1.f)));
989 cairo_rectangle (cr, x-dx * .5, 0, 1+dx, height);
992 } else if (_ports.n_total() == 1) {
993 set_routing_color (cr, _ports.n_midi() == 1);
994 const float x = rintf(width * .5);
995 cairo_rectangle (cr, x-dx * .5, 0, 1+dx, height);
1004 ProcessorEntry::RoutingIcon::RoutingIcon ()
1007 set_size_request (-1, std::max (7.f, rintf(8.f * UIConfiguration::instance().get_ui_scale())));
1011 ProcessorEntry::RoutingIcon::set (
1012 const ARDOUR::ChanCount& in,
1013 const ARDOUR::ChanCount& out,
1014 const ARDOUR::ChanCount& sinks,
1015 const ARDOUR::ChanCount& sources,
1016 const ARDOUR::ChanMapping& in_map,
1017 const ARDOUR::ChanMapping& out_map)
1019 _in = in; _out = out;
1020 _sources = sources; _sinks = sinks;
1021 _in_map = in_map; _out_map = out_map;
1026 ProcessorEntry::RoutingIcon::identity () const {
1027 if (!_in_map.is_monotonic () || !_in_map.is_monotonic ()) {
1030 if (_in_map.count () != _sinks.n_total ()) {
1034 if (!_f_out_map.is_monotonic () || _sinks != _f_sources) {
1037 if (!_f_out_map.is_identity ()) {
1040 if (_f_out_map.count () != _f_sources.n_total ()) {
1048 ProcessorEntry::RoutingIcon::set_feed (
1049 const ARDOUR::ChanCount& out,
1050 const ARDOUR::ChanCount& sources,
1051 const ARDOUR::ChanMapping& out_map)
1054 _f_sources = sources;
1055 _f_out_map = out_map;
1060 ProcessorEntry::RoutingIcon::pin_x_pos (uint32_t i, double width, uint32_t n_total, uint32_t n_midi, bool midi)
1062 if (!midi) { i += n_midi; }
1065 return rint (width * .5) +.5;
1067 return rint (width * (.2 + .6 * i / (n_total - 1))) + .5;
1071 ProcessorEntry::RoutingIcon::draw_gnd (cairo_t* cr, double x0, double height, bool midi)
1073 const double dx = 1 + rint (max(2., 2. * UIConfiguration::instance().get_ui_scale()));
1074 const double y0 = rint (height * .66) - .5;
1076 cairo_move_to (cr, x0, height);
1077 cairo_line_to (cr, x0, y0);
1078 cairo_move_to (cr, x0 - dx, y0);
1079 cairo_line_to (cr, x0 + dx, y0);
1081 set_routing_color (cr, midi);
1082 cairo_set_line_width (cr, 1.0);
1087 ProcessorEntry::RoutingIcon::draw_connection (cairo_t* cr, double x0, double x1, double y0, double y1, bool midi, bool dashed)
1089 double bz = abs (y1 - y0);
1091 cairo_move_to (cr, x0, y0);
1092 cairo_curve_to (cr, x0, y0 + bz, x1, y1 - bz, x1, y1);
1093 cairo_set_line_width (cr, 1.0);
1094 cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
1095 cairo_set_source_rgb (cr, 1, 0, 0);
1097 const double dashes[] = { 2, 3 };
1098 cairo_set_dash (cr, dashes, 2, 0);
1100 set_routing_color (cr, midi);
1103 cairo_set_dash (cr, 0, 0, 0);
1108 ProcessorEntry::RoutingIcon::on_expose_event (GdkEventExpose* ev)
1110 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
1112 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
1115 cairo_set_line_width (cr, max (1.f, UIConfiguration::instance().get_ui_scale()));
1116 cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
1118 Gtk::Allocation a = get_allocation();
1119 double const width = a.get_width();
1120 double const height = a.get_height();
1122 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
1123 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
1125 cairo_rectangle (cr, 0, 0, width, height);
1128 expose_map (cr, width, height);
1135 ProcessorEntry::RoutingIcon::expose_map (cairo_t* cr, const double width, const double height)
1137 const uint32_t pc_in = _sinks.n_total();
1138 const uint32_t pc_in_midi = _sinks.n_midi();
1140 // TODO indicate midi-bypass ??
1143 for (uint32_t i = 0; i < pc_in; ++i) {
1144 const bool is_midi = i < pc_in_midi;
1146 uint32_t pn = is_midi ? i : i - pc_in_midi;
1147 uint32_t idx = _in_map.get (is_midi ? DataType::MIDI : DataType::AUDIO, pn, &valid_in);
1149 double x = pin_x_pos (i, width, pc_in, pc_in_midi, is_midi);
1150 draw_gnd (cr, x, height, is_midi);
1154 double c_x1 = pin_x_pos (i, width, pc_in, 0, false);
1158 uint32_t src = _f_out_map.get_src (is_midi ? DataType::MIDI : DataType::AUDIO, idx, &valid_src);
1160 double x = pin_x_pos (i, width, pc_in, pc_in_midi, is_midi);
1161 draw_gnd (cr, x, height, is_midi);
1164 c_x0 = pin_x_pos (src, width, _f_out.n_total(), _f_out.n_midi(), is_midi);
1166 c_x0 = pin_x_pos (idx, width, _in.n_total(), _in.n_midi(), is_midi);
1168 draw_connection (cr, c_x0, c_x1, 0, height, is_midi);
1173 ProcessorEntry::PluginDisplay::PluginDisplay (boost::shared_ptr<ARDOUR::Plugin> p, uint32_t max_height)
1176 , _max_height (max_height)
1180 set_name ("processor prefader");
1181 _plug->QueueDraw.connect (_qdraw_connection, invalidator (*this),
1182 boost::bind (&Gtk::Widget::queue_draw, this), gui_context ());
1185 ProcessorEntry::PluginDisplay::~PluginDisplay ()
1188 cairo_surface_destroy (_surf);
1193 ProcessorEntry::PluginDisplay::on_size_request (Gtk::Requisition* req)
1196 req->height = _cur_height;
1201 ProcessorEntry::PluginDisplay::update_height_alloc (uint32_t inline_height)
1203 /* work-around scroll-bar + aspect ratio
1204 * show inline-view -> height changes -> scrollbar gets added
1205 * -> width changes -> inline-view, fixed aspect ratio -> height changes
1206 * -> scroll bar is removed [-> width changes ; repeat ]
1208 uint32_t shm = std::min (_max_height, inline_height);
1210 Gtk::Container* pr = get_parent();
1211 for (uint32_t i = 0; i < 4 && pr; ++i) {
1212 // VBox, EventBox, ViewPort, ScrolledWindow
1213 pr = pr->get_parent();
1215 Gtk::ScrolledWindow* sw = dynamic_cast<Gtk::ScrolledWindow*> (pr);
1217 const Gtk::VScrollbar* vsb = sw->get_vscrollbar();
1218 sc = vsb && vsb->is_visible();
1221 if (shm != _cur_height) {
1222 if (_scroll == sc || _cur_height < shm) {
1231 ProcessorEntry::PluginDisplay::render_inline (cairo_t* cr, uint32_t width)
1233 Plugin::Display_Image_Surface* dis = _plug->render_inline_display (width, _max_height);
1238 /* allocate a local image-surface,
1239 * We cannot re-use the data via cairo_image_surface_create_for_data(),
1240 * since pixman keeps a reference to it.
1241 * we'd need to hand over the data and ha cairo_surface_destroy to free it.
1242 * it might be possible to work around via cairo_surface_set_user_data().
1245 || dis->width != cairo_image_surface_get_width (_surf)
1246 || dis->height != cairo_image_surface_get_height (_surf)
1249 cairo_surface_destroy (_surf);
1251 _surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, dis->width, dis->height);
1254 if (cairo_image_surface_get_stride (_surf) == dis->stride) {
1255 memcpy (cairo_image_surface_get_data (_surf), dis->data, dis->stride * dis->height);
1257 unsigned char *src = dis->data;
1258 unsigned char *dst = cairo_image_surface_get_data (_surf);
1259 const int dst_stride = cairo_image_surface_get_stride (_surf);
1260 for (int y = 0; y < dis->height; ++y) {
1261 memcpy (dst, src, dis->width * 4 /*ARGB32*/);
1267 cairo_surface_mark_dirty(_surf);
1268 const double xc = floor ((width - dis->width) * .5);
1269 cairo_set_source_surface(cr, _surf, xc, 0);
1276 ProcessorEntry::PluginDisplay::on_expose_event (GdkEventExpose* ev)
1278 Gtk::Allocation a = get_allocation();
1279 double const width = a.get_width();
1280 double const height = a.get_height();
1282 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
1283 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
1286 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
1287 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
1288 cairo_rectangle (cr, 0, 0, width, height);
1292 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
1293 Gtkmm2ext::rounded_rectangle (cr, .5, -1.5, width - 1, height + 1, 7);
1295 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1297 uint32_t ht = render_inline (cr, width);
1302 if (_cur_height != 1) {
1309 update_height_alloc (ht);
1312 bool failed = false;
1313 std::string name = get_name();
1314 ArdourCanvas::Color fill_color = UIConfiguration::instance().color (string_compose ("%1: fill active", name), &failed);
1316 Gtkmm2ext::rounded_rectangle (cr, .5, -1.5, width - 1, height + 1, 7);
1317 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1318 cairo_set_line_width(cr, 1.0);
1319 ArdourCanvas::set_source_rgb_a (cr, fill_color, 1.0);
1326 ProcessorEntry::LuaPluginDisplay::LuaPluginDisplay (boost::shared_ptr<ARDOUR::LuaProc> p, uint32_t max_height)
1327 : PluginDisplay (p, max_height)
1329 , _lua_render_inline (0)
1331 p->setup_lua_inline_gui (&lua_gui);
1333 lua_State* LG = lua_gui.getState ();
1334 LuaInstance::bind_cairo (LG);
1335 luabridge::LuaRef lua_render = luabridge::getGlobal (LG, "render_inline");
1336 assert (lua_render.isFunction ());
1337 _lua_render_inline = new luabridge::LuaRef (lua_render);
1340 ProcessorEntry::LuaPluginDisplay::~LuaPluginDisplay ()
1342 delete (_lua_render_inline);
1346 ProcessorEntry::LuaPluginDisplay::render_inline (cairo_t *cr, uint32_t width)
1348 Cairo::Context ctx (cr);
1350 luabridge::LuaRef rv = (*_lua_render_inline)((Cairo::Context *)&ctx, width, _max_height);
1351 if (rv.isTable ()) {
1355 } catch (luabridge::LuaException const& e) {
1362 static std::list<Gtk::TargetEntry> drop_targets()
1364 std::list<Gtk::TargetEntry> tmp;
1365 tmp.push_back (Gtk::TargetEntry ("processor")); // from processor-box to processor-box
1366 tmp.push_back (Gtk::TargetEntry ("PluginInfoPtr")); // from plugin-manager
1367 tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr")); // from sidebar
1371 static std::list<Gtk::TargetEntry> drag_targets()
1373 std::list<Gtk::TargetEntry> tmp;
1374 tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr")); // to sidebar (optional preset)
1375 tmp.push_back (Gtk::TargetEntry ("processor")); // to processor-box (copy)
1379 static std::list<Gtk::TargetEntry> drag_targets_noplugin()
1381 std::list<Gtk::TargetEntry> tmp;
1382 tmp.push_back (Gtk::TargetEntry ("processor")); // to processor box (sends, faders re-order)
1386 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
1387 RouteProcessorSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
1388 : _parent_strip (parent)
1389 , _owner_is_mixer (owner_is_mixer)
1390 , ab_direction (true)
1391 , _get_plugin_selector (get_plugin_selector)
1393 , _visible_prefader_processors (0)
1394 , _rr_selection(rsel)
1395 , processor_display (drop_targets())
1396 , _redisplay_pending (false)
1400 /* ProcessorBox actions and bindings created statically by call to
1401 * ProcessorBox::register_actions(), made by ARDOUR_UI so that actions
1402 * are available for context menus.
1405 processor_display.set_data ("ardour-bindings", bindings);
1409 no_processor_redisplay = false;
1411 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
1412 processor_scroller.add (processor_display);
1413 pack_start (processor_scroller, true, true);
1415 processor_display.set_flags (CAN_FOCUS);
1416 processor_display.set_name ("ProcessorList");
1417 processor_display.set_data ("processorbox", this);
1418 processor_display.set_size_request (48, -1);
1419 processor_display.set_spacing (0);
1421 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
1422 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
1424 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
1425 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
1427 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
1428 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
1429 processor_display.DropFromExternal.connect (sigc::mem_fun (*this, &ProcessorBox::plugin_drop));
1431 processor_scroller.show ();
1432 processor_display.show ();
1435 parent->DeliveryChanged.connect (
1436 _mixer_strip_connections, invalidator (*this), boost::bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
1440 ARDOUR_UI_UTILS::set_tooltip (processor_display, _("Right-click to add/remove/edit\nplugins,inserts,sends and more"));
1443 ProcessorBox::~ProcessorBox ()
1445 /* it may appear as if we should delete processor_menu but that is a
1446 * pointer to a widget owned by the UI Manager, and has potentially
1447 * be returned to many other ProcessorBoxes. GTK doesn't really make
1448 * clear the ownership of this widget, which is a menu and thus is
1449 * never packed into any container other than an implict GtkWindow.
1451 * For now, until or if we ever get clarification over the ownership
1452 * story just let it continue to exist. At worst, its a small memory leak.
1457 ProcessorBox::set_route (boost::shared_ptr<Route> r)
1463 _route_connections.drop_connections();
1465 /* new route: any existing block on processor redisplay must be meaningless */
1466 no_processor_redisplay = false;
1469 _route->processors_changed.connect (
1470 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
1473 _route->DropReferences.connect (
1474 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
1477 _route->PropertyChanged.connect (
1478 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
1481 redisplay_processors ();
1485 ProcessorBox::route_going_away ()
1487 /* don't keep updating display as processors are deleted */
1488 no_processor_redisplay = true;
1492 boost::shared_ptr<Processor>
1493 ProcessorBox::find_drop_position (ProcessorEntry* position)
1495 boost::shared_ptr<Processor> p;
1497 p = position->processor ();
1499 /* dropped on the blank entry (which will be before the
1500 fader), so use the first non-blank child as our
1501 `dropped on' processor */
1502 list<ProcessorEntry*> c = processor_display.children ();
1503 list<ProcessorEntry*>::iterator i = c.begin ();
1505 assert (i != c.end ());
1506 p = (*i)->processor ();
1514 ProcessorBox::_drop_plugin_preset (Gtk::SelectionData const &data, Route::ProcessorList &pl)
1516 const void * d = data.get_data();
1517 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
1519 PluginPresetList nfos;
1521 tv->get_object_drag_data (nfos, &source);
1523 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1524 PluginPresetPtr ppp = (*i);
1525 PluginInfoPtr pip = ppp->_pip;
1526 PluginPtr p = pip->load (*_session);
1531 if (ppp->_preset.valid) {
1532 p->load_preset (ppp->_preset);
1535 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
1536 if (Config->get_new_plugins_active ()) {
1537 processor->activate ();
1539 pl.push_back (processor);
1544 ProcessorBox::_drop_plugin (Gtk::SelectionData const &data, Route::ProcessorList &pl)
1546 const void * d = data.get_data();
1547 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>*>(d);
1548 PluginInfoList nfos;
1551 tv->get_object_drag_data (nfos, &source);
1553 for (list<PluginInfoPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1554 PluginPtr p = (*i)->load (*_session);
1558 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
1559 if (Config->get_new_plugins_active ()) {
1560 processor->activate ();
1562 pl.push_back (processor);
1567 ProcessorBox::plugin_drop (Gtk::SelectionData const &data, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
1573 boost::shared_ptr<Processor> p = find_drop_position (position);
1574 Route::ProcessorList pl;
1576 if (data.get_target() == "PluginInfoPtr") {
1577 _drop_plugin (data, pl);
1579 else if (data.get_target() == "PluginPresetPtr") {
1580 _drop_plugin_preset (data, pl);
1586 Route::ProcessorStreams err;
1587 if (_route->add_processors (pl, p, &err)) {
1589 "Processor Drag/Drop failed. Probably because\n\
1590 the I/O configuration of the plugins could\n\
1591 not match the configuration of this track.");
1592 MessageDialog am (msg);
1598 ProcessorBox::object_drop (DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
1600 if (Gdk::ACTION_LINK == context->get_selected_action()) {
1601 list<ProcessorEntry*> children = source->selection ();
1602 assert (children.size() == 1);
1603 ProcessorEntry* other = *children.begin();
1604 assert (other->can_copy_state (position));
1605 boost::shared_ptr<ARDOUR::Processor> otherproc = other->processor();
1606 boost::shared_ptr<ARDOUR::Processor> proc = position->processor();
1607 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (proc);
1608 assert (otherproc && proc && pi);
1610 PBD::ID id = pi->id();
1611 XMLNode& state = otherproc->get_state ();
1612 proc->set_state (state, Stateful::loading_state_version);
1613 boost::dynamic_pointer_cast<PluginInsert>(proc)->update_id (id);
1617 boost::shared_ptr<Processor> p = find_drop_position (position);
1619 list<ProcessorEntry*> children = source->selection ();
1620 list<boost::shared_ptr<Processor> > procs;
1621 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
1622 if ((*i)->processor ()) {
1623 if (boost::dynamic_pointer_cast<UnknownProcessor> ((*i)->processor())) {
1626 procs.push_back ((*i)->processor ());
1630 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
1631 XMLNode& state = (*i)->get_state ();
1633 nlist.push_back (&state);
1634 paste_processor_state (nlist, p);
1638 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
1642 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
1643 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
1645 other->delete_dragged_processors (procs);
1651 ProcessorBox::set_width (Width w)
1659 list<ProcessorEntry*> children = processor_display.children ();
1660 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1661 (*i)->set_enum_width (w);
1668 ProcessorBox::build_possible_aux_menu ()
1670 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
1673 /* No aux sends if there are no busses */
1677 if (_route->is_monitor ()) {
1681 using namespace Menu_Helpers;
1682 Menu* menu = manage (new Menu);
1683 MenuList& items = menu->items();
1685 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
1686 if (!_route->internal_send_for (*r) && *r != _route) {
1687 items.push_back (MenuElem ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
1695 ProcessorBox::show_processor_menu (int arg)
1697 if (processor_menu == 0) {
1698 processor_menu = build_processor_menu ();
1699 processor_menu->signal_unmap().connect (sigc::mem_fun (*this, &ProcessorBox::processor_menu_unmapped));
1702 /* Sort out the plugin submenu */
1704 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newplugin"));
1706 if (plugin_menu_item) {
1707 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
1710 /* And the aux submenu */
1712 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newaux"));
1714 if (aux_menu_item) {
1715 Menu* m = build_possible_aux_menu();
1716 if (m && !m->items().empty()) {
1717 aux_menu_item->set_submenu (*m);
1718 aux_menu_item->set_sensitive (true);
1720 /* stupid gtkmm: we need to pass a null reference here */
1721 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
1722 aux_menu_item->set_sensitive (false);
1726 ActionManager::get_action (X_("ProcessorMenu"), "newinsert")->set_sensitive (!_route->is_monitor ());
1727 ActionManager::get_action (X_("ProcessorMenu"), "newsend")->set_sensitive (!_route->is_monitor ());
1729 ProcessorEntry* single_selection = 0;
1730 if (processor_display.selection().size() == 1) {
1731 single_selection = processor_display.selection().front();
1734 /* And the controls submenu */
1736 Gtk::MenuItem* controls_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/controls"));
1738 if (controls_menu_item) {
1739 if (single_selection) {
1740 Menu* m = single_selection->build_controls_menu ();
1741 if (m && !m->items().empty()) {
1742 controls_menu_item->set_submenu (*m);
1743 controls_menu_item->set_sensitive (true);
1745 gtk_menu_item_set_submenu (controls_menu_item->gobj(), 0);
1746 controls_menu_item->set_sensitive (false);
1749 controls_menu_item->set_sensitive (false);
1753 Gtk::MenuItem* send_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/send_options"));
1754 if (send_menu_item) {
1755 if (single_selection && !_route->is_monitor()) {
1756 Menu* m = single_selection->build_send_options_menu ();
1757 if (m && !m->items().empty()) {
1758 send_menu_item->set_submenu (*m);
1759 send_menu_item->set_sensitive (true);
1761 gtk_menu_item_set_submenu (send_menu_item->gobj(), 0);
1762 send_menu_item->set_sensitive (false);
1765 send_menu_item->set_sensitive (false);
1769 /* Sensitise actions as approprioate */
1772 const bool sensitive = !processor_display.selection().empty() && ! stub_processor_selected ();
1774 paste_action->set_sensitive (!_rr_selection.processors.empty());
1775 cut_action->set_sensitive (sensitive && can_cut ());
1776 copy_action->set_sensitive (sensitive);
1777 delete_action->set_sensitive (sensitive || stub_processor_selected ());
1779 edit_action->set_sensitive (one_processor_can_be_edited ());
1780 edit_generic_action->set_sensitive (one_processor_can_be_edited ());
1782 boost::shared_ptr<PluginInsert> pi;
1783 if (single_selection) {
1784 pi = boost::dynamic_pointer_cast<PluginInsert> (single_selection->processor ());
1787 manage_pins_action->set_sensitive (pi != 0);
1789 /* allow editing with an Ardour-generated UI for plugin inserts with editors */
1790 edit_action->set_sensitive (pi && pi->plugin()->has_editor ());
1792 /* disallow rename for multiple selections, for plugin inserts and for the fader */
1793 rename_action->set_sensitive (single_selection
1795 && !boost::dynamic_pointer_cast<Amp> (single_selection->processor ())
1796 && !boost::dynamic_pointer_cast<UnknownProcessor> (single_selection->processor ()));
1798 processor_menu->popup (1, arg);
1800 /* Add a placeholder gap to the processor list to indicate where a processor would be
1801 inserted were one chosen from the menu.
1804 processor_display.get_pointer (x, y);
1805 _placement = processor_display.add_placeholder (y);
1807 if (_visible_prefader_processors == 0 && _placement > 0) {
1813 ProcessorBox::enter_notify (GdkEventCrossing*)
1815 processor_display.grab_focus ();
1816 _current_processor_box = this;
1821 ProcessorBox::leave_notify (GdkEventCrossing* ev)
1823 if (ev->detail == GDK_NOTIFY_INFERIOR) {
1827 Widget* top = get_toplevel();
1829 if (top->is_toplevel()) {
1830 Window* win = dynamic_cast<Window*> (top);
1831 gtk_window_set_focus (win->gobj(), 0);
1838 ProcessorBox::processor_operation (ProcessorOperation op)
1840 ProcSelection targets;
1842 get_selected_processors (targets);
1844 /* if (targets.empty()) {
1847 processor_display.get_pointer (x, y);
1849 pair<ProcessorEntry *, double> const pointer = processor_display.get_child_at_position (y);
1851 if (pointer.first && pointer.first->processor()) {
1852 targets.push_back (pointer.first->processor ());
1857 if ((op == ProcessorsDelete) && targets.empty()) {
1858 return false; //nothing to delete. return false so the editor-mixer, because the user was probably intending to delete something in the editor
1862 case ProcessorsSelectAll:
1863 processor_display.select_all ();
1866 case ProcessorsSelectNone:
1867 processor_display.select_none ();
1870 case ProcessorsCopy:
1871 copy_processors (targets);
1875 cut_processors (targets);
1878 case ProcessorsPaste:
1879 // some processors are not selectable (e.g fader, meter), target is empty.
1880 if (targets.empty() && _placement >= 0) {
1882 boost::shared_ptr<Processor> proc = _route->before_processor_for_index (_placement);
1884 targets.push_back (proc);
1887 if (targets.empty()) {
1888 paste_processors ();
1890 paste_processors (targets.front());
1894 case ProcessorsDelete:
1895 delete_processors (targets);
1898 case ProcessorsToggleActive:
1899 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
1900 if ((*i)->active()) {
1901 (*i)->deactivate ();
1919 ProcessorWindowProxy*
1920 ProcessorBox::find_window_proxy (boost::shared_ptr<Processor> processor) const
1922 return processor->window_proxy();
1927 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
1929 boost::shared_ptr<Processor> processor;
1931 processor = child->processor ();
1935 bool selected = processor_display.selected (child);
1937 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
1939 if (_session->engine().connected()) {
1940 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
1942 if (!one_processor_can_be_edited ()) {
1946 if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
1947 generic_edit_processor (processor);
1949 edit_processor (processor);
1955 } else if (Keyboard::is_context_menu_event (ev)) {
1957 show_processor_menu (ev->time);
1961 } else if (processor && ev->button == 1 && selected) {
1963 // this is purely informational but necessary for route params UI
1964 ProcessorSelected (processor); // emit
1966 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
1969 _get_plugin_selector()->show_manager ();
1976 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
1978 boost::shared_ptr<Processor> processor;
1980 processor = child->processor ();
1983 if (processor && Keyboard::is_delete_event (ev)) {
1985 Glib::signal_idle().connect (sigc::bind (
1986 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
1987 boost::weak_ptr<Processor>(processor)));
1989 } else if (processor && Keyboard::is_button2_event (ev)
1991 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
1995 /* button2-click with no/appropriate modifiers */
1997 if (processor->active()) {
1998 processor->deactivate ();
2000 processor->activate ();
2008 ProcessorBox::build_processor_menu ()
2010 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/ProcessorMenu") );
2011 processor_menu->set_name ("ArdourContextMenu");
2012 return processor_menu;
2016 ProcessorBox::select_all_processors ()
2018 processor_display.select_all ();
2022 ProcessorBox::deselect_all_processors ()
2024 processor_display.select_none ();
2028 ProcessorBox::choose_plugin ()
2030 _get_plugin_selector()->set_interested_object (*this);
2033 /** @return true if an error occurred, otherwise false */
2035 ProcessorBox::choose_lua ()
2037 LuaScriptInfoPtr spi;
2039 ScriptSelector ss (_("Add Lua DSP Processor"), LuaScriptInfo::DSP);
2040 switch (ss.run ()) {
2041 case Gtk::RESPONSE_ACCEPT:
2051 LuaPluginInfoPtr lpi (new LuaPluginInfo(spi));
2052 p = (lpi->load (*_session));
2055 "Failed to instantiate Lua DSP Processor,\n"
2056 "probably because the script is invalid (no dsp function).");
2057 MessageDialog am (msg);
2062 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
2064 Route::ProcessorStreams err_streams;
2065 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
2067 "Failed to add Lua DSP Processor at the given position,\n"
2068 "probably because the I/O configuration of the plugins\n"
2069 "could not match the configuration of this track.");
2070 MessageDialog am (msg);
2076 /** @return true if an error occurred, otherwise false */
2078 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
2080 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
2082 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
2084 Route::ProcessorStreams err_streams;
2086 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
2087 weird_plugin_dialog (**p, err_streams);
2089 // XXX SHAREDPTR delete plugin here .. do we even need to care?
2090 } else if (plugins.size() == 1 && UIConfiguration::instance().get_open_gui_after_adding_plugin()) {
2091 if (boost::dynamic_pointer_cast<PluginInsert>(processor)->plugin()->has_inline_display() && UIConfiguration::instance().get_prefer_inline_over_gui()) {
2093 } else if (_session->engine().connected () && processor_can_be_edited (processor)) {
2094 if ((*p)->has_editor ()) {
2095 edit_processor (processor);
2097 generic_edit_processor (processor);
2107 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
2109 ArdourDialog dialog (_("Plugin Incompatibility"));
2112 string text = string_compose(_("You attempted to add the plugin \"%1\" in slot %2.\n"),
2113 p.name(), streams.index);
2115 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
2116 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
2118 text += _("\nThis plugin has:\n");
2120 uint32_t const n = p.get_info()->n_inputs.n_midi ();
2121 text += string_compose (ngettext ("\t%1 MIDI input\n", "\t%1 MIDI inputs\n", n), n);
2124 uint32_t const n = p.get_info()->n_inputs.n_audio ();
2125 text += string_compose (ngettext ("\t%1 audio input\n", "\t%1 audio inputs\n", n), n);
2128 text += _("\nbut at the insertion point, there are:\n");
2130 uint32_t const n = streams.count.n_midi ();
2131 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
2134 uint32_t const n = streams.count.n_audio ();
2135 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
2138 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
2139 label.set_text(text);
2141 dialog.get_vbox()->pack_start (label);
2142 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
2144 dialog.set_name (X_("PluginIODialog"));
2145 dialog.set_modal (true);
2152 ProcessorBox::choose_insert ()
2154 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->pannable(), _route->mute_master()));
2155 _route->add_processor_by_index (processor, _placement);
2158 /* Caller must not hold process lock */
2160 ProcessorBox::choose_send ()
2162 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
2163 boost::shared_ptr<Send> send (new Send (*_session, sendpan, _route->mute_master()));
2165 /* make an educated guess at the initial number of outputs for the send */
2166 ChanCount outs = (_session->master_out())
2167 ? _session->master_out()->n_outputs()
2168 : _route->n_outputs();
2170 /* XXX need processor lock on route */
2172 Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock());
2173 send->output()->ensure_io (outs, false, this);
2174 } catch (AudioEngine::PortRegistrationFailure& err) {
2175 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
2179 /* let the user adjust the IO setup before creation.
2181 Note: this dialog is NOT modal - we just leave it to run and it will
2182 return when its Finished signal is emitted - typically when the window
2186 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
2189 /* keep a reference to the send so it doesn't get deleted while
2190 the IOSelectorWindow is doing its stuff
2192 _processor_being_created = send;
2194 ios->selector().Finished.connect (sigc::bind (
2195 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
2196 boost::weak_ptr<Processor>(send), ios));
2201 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
2203 boost::shared_ptr<Processor> processor (weak_processor.lock());
2205 /* drop our temporary reference to the new send */
2206 _processor_being_created.reset ();
2213 case IOSelector::Cancelled:
2214 // processor will go away when all shared_ptrs to it vanish
2217 case IOSelector::Accepted:
2218 _route->add_processor_by_index (processor, _placement);
2222 delete_when_idle (ios);
2226 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
2228 boost::shared_ptr<Processor> processor (weak_processor.lock());
2230 /* drop our temporary reference to the new return */
2231 _processor_being_created.reset ();
2238 case IOSelector::Cancelled:
2239 // processor will go away when all shared_ptrs to it vanish
2242 case IOSelector::Accepted:
2243 _route->add_processor_by_index (processor, _placement);
2247 delete_when_idle (ios);
2251 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
2257 boost::shared_ptr<Route> target = wr.lock();
2263 _session->add_internal_send (target, _placement, _route);
2267 ProcessorBox::route_processors_changed (RouteProcessorChange c)
2269 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
2270 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
2274 redisplay_processors ();
2278 ProcessorBox::redisplay_processors ()
2280 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors);
2283 if (no_processor_redisplay) {
2287 processor_display.clear ();
2289 _visible_prefader_processors = 0;
2292 _route->foreach_processor (sigc::bind (sigc::mem_fun (*this, &ProcessorBox::help_count_visible_prefader_processors),
2293 &_visible_prefader_processors, &fader_seen));
2295 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
2296 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
2297 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_pin_mgr));
2299 setup_entry_positions ();
2302 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
2303 * not already have one.
2306 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
2308 boost::shared_ptr<Processor> p = w.lock ();
2312 if (p->window_proxy()) {
2316 /* not on the list; add it */
2319 #if 0 // is this still needed? Why?
2320 if (_parent_strip) {
2321 if (_parent_strip->mixer_owned()) {
2333 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
2334 string_compose ("%1-%2-%3", loc, _route->id(), p->id()),
2338 const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
2341 wp->set_state (*ui_xml, 0);
2344 void* existing_ui = p->get_ui ();
2347 wp->use_window (*(reinterpret_cast<Gtk::Window*>(existing_ui)));
2350 p->set_window_proxy (wp);
2351 WM::Manager::instance().register_window (wp);
2355 ProcessorBox::maybe_add_processor_pin_mgr (boost::weak_ptr<Processor> w)
2357 boost::shared_ptr<Processor> p = w.lock ();
2358 if (!p || p->pinmgr_proxy ()) {
2362 PluginPinWindowProxy* wp = new PluginPinWindowProxy (
2363 string_compose ("PM-%2-%3", _route->id(), p->id()), w);
2365 const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
2367 wp->set_state (*ui_xml, 0);
2370 void* existing_ui = p->get_ui ();
2373 wp->use_window (*(reinterpret_cast<Gtk::Window*>(existing_ui)));
2376 p->set_pingmgr_proxy (wp);
2377 WM::Manager::instance().register_window (wp);
2380 ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor> p, uint32_t* cnt, bool* amp_seen)
2382 boost::shared_ptr<Processor> processor (p.lock ());
2384 if (processor && ( processor->display_to_user()
2386 || show_all_processors
2391 if (boost::dynamic_pointer_cast<Amp>(processor) &&
2392 boost::dynamic_pointer_cast<Amp>(processor)->gain_control()->parameter().type() == GainAutomation) {
2403 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
2405 boost::shared_ptr<Processor> processor (p.lock ());
2407 if (!processor || ( !processor->display_to_user()
2409 && !show_all_processors
2416 boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
2418 ProcessorEntry* e = 0;
2419 if (plugin_insert) {
2420 e = new PluginInsertProcessorEntry (this, plugin_insert, _width);
2422 e = new ProcessorEntry (this, processor, _width);
2425 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
2426 boost::shared_ptr<PortInsert> ext = boost::dynamic_pointer_cast<PortInsert> (processor);
2427 boost::shared_ptr<UnknownProcessor> stub = boost::dynamic_pointer_cast<UnknownProcessor> (processor);
2429 //faders and meters are not deletable, copy/paste-able, so they shouldn't be selectable
2430 if (!send && !plugin_insert && !ext && !stub)
2431 e->set_selectable(false);
2433 bool mark_send_visible = false;
2434 if (send && _parent_strip) {
2435 /* show controls of new sends by default */
2436 GUIObjectState& st = _parent_strip->gui_object_state ();
2437 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
2439 /* check if state exists, if not it must be a new send */
2440 if (!st.get_node(strip, e->state_id())) {
2441 mark_send_visible = true;
2445 /* Set up this entry's state from the GUIObjectState */
2446 XMLNode* proc = entry_gui_object_state (e);
2448 e->set_control_state (proc);
2451 if (mark_send_visible) {
2452 e->show_all_controls ();
2457 && !plugin_insert->plugin(0)->is_channelstrip()
2461 processor_display.add_child (e, drag_targets());
2463 processor_display.add_child (e, drag_targets_noplugin());
2468 ProcessorBox::reordered ()
2470 compute_processor_sort_keys ();
2471 setup_entry_positions ();
2475 ProcessorBox::setup_routing_feeds ()
2477 list<ProcessorEntry*> children = processor_display.children ();
2478 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2479 boost::shared_ptr<ARDOUR::Processor> p = (*i)->processor();
2480 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (p);
2482 list<ProcessorEntry*>::iterator next = i;
2486 ChanCount sinks = pi->natural_input_streams ();
2487 ChanCount sources = pi->natural_output_streams ();
2488 uint32_t count = pi->get_count ();
2490 pi->configured_io (in, out);
2492 ChanCount midi_bypass;
2493 if (pi->has_midi_bypass ()) {
2494 midi_bypass.set(DataType::MIDI, 1);
2497 (*i)->input_icon.set_ports (sinks * count);
2498 (*i)->output_icon.set_ports (sources * count + midi_bypass);
2500 (*i)->routing_icon.set (
2503 sources * count + midi_bypass,
2507 if (next != children.end()) {
2508 (*next)->routing_icon.set_feed (out, sources * count + midi_bypass, pi->output_map ());
2512 (*i)->input_icon.set_ports (p->input_streams());
2513 (*i)->output_icon.set_ports (p->output_streams());
2514 ChanMapping inmap (p->input_streams ());
2515 ChanMapping outmap (p->input_streams ());
2516 (*i)->routing_icon.set (
2518 p->output_streams(),
2520 p->output_streams(),
2523 if (next != children.end()) {
2524 (*next)->routing_icon.set_feed (p->output_streams(), p->output_streams(), outmap);
2528 if (i == children.begin()) {
2529 (*i)->routing_icon.unset_feed ();
2533 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2534 if ((*i)->routing_icon.identity ()) {
2535 (*i)->routing_icon.hide();
2536 if (i == children.begin()) {
2537 (*i)->input_icon.show();
2539 (*i)->input_icon.hide();
2542 (*i)->routing_icon.show();
2543 (*i)->routing_icon.queue_draw();
2544 (*i)->input_icon.show();
2547 // TODO show additional wires if outputs of last processor are not an identity map.
2551 ProcessorBox::setup_entry_positions ()
2553 list<ProcessorEntry*> children = processor_display.children ();
2554 bool pre_fader = true;
2557 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2558 if (boost::dynamic_pointer_cast<Amp>((*i)->processor()) &&
2559 boost::dynamic_pointer_cast<Amp>((*i)->processor())->gain_control()->parameter().type() == GainAutomation) {
2561 (*i)->set_position (ProcessorEntry::Fader, num++);
2564 (*i)->set_position (ProcessorEntry::PreFader, num++);
2566 (*i)->set_position (ProcessorEntry::PostFader, num++);
2570 setup_routing_feeds ();
2574 ProcessorBox::compute_processor_sort_keys ()
2576 list<ProcessorEntry*> children = processor_display.children ();
2577 Route::ProcessorList our_processors;
2579 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2580 if ((*i)->processor()) {
2581 our_processors.push_back ((*i)->processor ());
2585 if (_route->reorder_processors (our_processors)) {
2586 /* Reorder failed, so report this to the user. As far as I can see this must be done
2587 in an idle handler: it seems that the redisplay_processors() that happens below destroys
2588 widgets that were involved in the drag-and-drop on the processor list, which causes problems
2589 when the drag is torn down after this handler function is finished.
2591 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
2596 ProcessorBox::report_failed_reorder ()
2598 /* reorder failed, so redisplay */
2600 redisplay_processors ();
2602 /* now tell them about the problem */
2604 ArdourDialog dialog (_("Plugin Incompatibility"));
2607 label.set_text (_("\
2608 You cannot reorder these plugins/sends/inserts\n\
2609 in that way because the inputs and\n\
2610 outputs will not work correctly."));
2612 dialog.get_vbox()->set_border_width (12);
2613 dialog.get_vbox()->pack_start (label);
2614 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
2616 dialog.set_name (X_("PluginIODialog"));
2617 dialog.set_modal (true);
2624 ProcessorBox::rename_processors ()
2626 ProcSelection to_be_renamed;
2628 get_selected_processors (to_be_renamed);
2630 if (to_be_renamed.empty()) {
2634 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
2635 rename_processor (*i);
2640 ProcessorBox::can_cut () const
2642 vector<boost::shared_ptr<Processor> > sel;
2644 get_selected_processors (sel);
2646 /* cut_processors () does not cut inserts */
2648 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
2650 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
2651 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
2652 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
2661 ProcessorBox::stub_processor_selected () const
2663 vector<boost::shared_ptr<Processor> > sel;
2665 get_selected_processors (sel);
2667 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
2668 if (boost::dynamic_pointer_cast<UnknownProcessor>((*i)) != 0) {
2677 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
2679 if (to_be_removed.empty()) {
2683 XMLNode* node = new XMLNode (X_("cut"));
2684 Route::ProcessorList to_cut;
2686 no_processor_redisplay = true;
2687 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
2688 // Cut only plugins, sends and returns
2689 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
2690 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
2691 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
2693 Window* w = get_processor_ui (*i);
2699 XMLNode& child ((*i)->get_state());
2700 node->add_child_nocopy (child);
2701 to_cut.push_back (*i);
2705 if (_route->remove_processors (to_cut) != 0) {
2707 no_processor_redisplay = false;
2711 _rr_selection.set (node);
2713 no_processor_redisplay = false;
2714 redisplay_processors ();
2718 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
2720 if (to_be_copied.empty()) {
2724 XMLNode* node = new XMLNode (X_("copy"));
2726 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
2727 // Copy only plugins, sends, returns
2728 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
2729 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
2730 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
2731 node->add_child_nocopy ((*i)->get_state());
2735 _rr_selection.set (node);
2739 ProcessorBox::delete_processors (const ProcSelection& targets)
2741 if (targets.empty()) {
2745 no_processor_redisplay = true;
2747 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
2749 Window* w = get_processor_ui (*i);
2755 _route->remove_processor(*i);
2758 no_processor_redisplay = false;
2759 redisplay_processors ();
2763 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
2765 list<boost::shared_ptr<Processor> >::const_iterator x;
2767 no_processor_redisplay = true;
2768 for (x = procs.begin(); x != procs.end(); ++x) {
2770 Window* w = get_processor_ui (*x);
2776 _route->remove_processor(*x);
2779 no_processor_redisplay = false;
2780 redisplay_processors ();
2784 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
2786 boost::shared_ptr<Processor> processor (weak_processor.lock());
2792 /* NOT copied to _mixer.selection() */
2794 no_processor_redisplay = true;
2795 _route->remove_processor (processor);
2796 no_processor_redisplay = false;
2797 redisplay_processors ();
2803 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
2805 ArdourPrompter name_prompter (true);
2807 name_prompter.set_title (_("Rename Processor"));
2808 name_prompter.set_prompt (_("New name:"));
2809 name_prompter.set_initial_text (processor->name());
2810 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
2811 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
2812 name_prompter.show_all ();
2814 switch (name_prompter.run ()) {
2816 case Gtk::RESPONSE_ACCEPT:
2817 name_prompter.get_result (result);
2818 if (result.length()) {
2821 string test = result;
2823 while (tries < 100) {
2824 if (_session->io_name_is_legal (test)) {
2830 test = string_compose ("%1-%2", result, tries);
2834 processor->set_name (result);
2837 ARDOUR_UI::instance()->popup_error
2838 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
2848 ProcessorBox::paste_processors ()
2850 if (_rr_selection.processors.empty()) {
2854 paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
2858 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
2861 if (_rr_selection.processors.empty()) {
2865 paste_processor_state (_rr_selection.processors.get_node().children(), before);
2869 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
2871 XMLNodeConstIterator niter;
2872 list<boost::shared_ptr<Processor> > copies;
2874 if (nlist.empty()) {
2878 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2880 XMLProperty const * type = (*niter)->property ("type");
2881 XMLProperty const * role = (*niter)->property ("role");
2884 boost::shared_ptr<Processor> p;
2886 if (type->value() == "meter" ||
2887 type->value() == "main-outs" ||
2888 type->value() == "amp" ||
2889 type->value() == "intreturn") {
2890 /* do not paste meter, main outs, amp or internal returns */
2893 } else if (type->value() == "intsend") {
2895 /* aux sends are OK, but those used for
2896 * other purposes, are not.
2901 if (role->value() != "Aux") {
2905 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
2906 XMLNode n (**niter);
2907 InternalSend* s = new InternalSend (*_session, sendpan, _route->mute_master(),
2908 _route, boost::shared_ptr<Route>(), Delivery::Aux);
2910 IOProcessor::prepare_for_reset (n, s->name());
2912 if (s->set_state (n, Stateful::loading_state_version)) {
2919 } else if (type->value() == "send") {
2921 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
2922 XMLNode n (**niter);
2924 Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
2926 IOProcessor::prepare_for_reset (n, s->name());
2928 if (s->set_state (n, Stateful::loading_state_version)) {
2935 } else if (type->value() == "return") {
2937 XMLNode n (**niter);
2938 Return* r = new Return (*_session);
2940 IOProcessor::prepare_for_reset (n, r->name());
2942 if (r->set_state (n, Stateful::loading_state_version)) {
2949 } else if (type->value() == "port") {
2951 XMLNode n (**niter);
2952 PortInsert* pi = new PortInsert (*_session, _route->pannable (), _route->mute_master ());
2954 IOProcessor::prepare_for_reset (n, pi->name());
2956 if (pi->set_state (n, Stateful::loading_state_version)) {
2962 /* XXX its a bit limiting to assume that everything else
2965 p.reset (new PluginInsert (*_session));
2966 PBD::ID id = p->id();
2967 p->set_state (**niter, Stateful::current_state_version);
2968 boost::dynamic_pointer_cast<PluginInsert>(p)->update_id (id);
2971 copies.push_back (p);
2975 error << _("plugin insert constructor failed") << endmsg;
2979 if (copies.empty()) {
2983 if (_route->add_processors (copies, p)) {
2986 "Copying the set of processors on the clipboard failed,\n\
2987 probably because the I/O configuration of the plugins\n\
2988 could not match the configuration of this track.");
2989 MessageDialog am (msg);
2995 ProcessorBox::get_selected_processors (ProcSelection& processors) const
2997 const list<ProcessorEntry*> selection = processor_display.selection ();
2998 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
2999 processors.push_back ((*i)->processor ());
3004 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
3006 list<ProcessorEntry*> selection = processor_display.selection ();
3007 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
3008 (this->*method) ((*i)->processor ());
3013 ProcessorBox::all_visible_processors_active (bool state)
3015 _route->all_visible_processors_active (state);
3019 ProcessorBox::ab_plugins ()
3021 _route->ab_plugins (ab_direction);
3022 ab_direction = !ab_direction;
3027 ProcessorBox::clear_processors ()
3030 vector<string> choices;
3032 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
3033 "(this cannot be undone)"), _route->name());
3035 choices.push_back (_("Cancel"));
3036 choices.push_back (_("Yes, remove them all"));
3038 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
3040 if (prompter.run () == 1) {
3041 _route->clear_processors (PreFader);
3042 _route->clear_processors (PostFader);
3047 ProcessorBox::clear_processors (Placement p)
3050 vector<string> choices;
3052 if (p == PreFader) {
3053 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
3054 "(this cannot be undone)"), _route->name());
3056 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
3057 "(this cannot be undone)"), _route->name());
3060 choices.push_back (_("Cancel"));
3061 choices.push_back (_("Yes, remove them all"));
3063 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
3065 if (prompter.run () == 1) {
3066 _route->clear_processors (p);
3071 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
3073 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
3074 if (at && at->freeze_state() == AudioTrack::Frozen) {
3079 boost::dynamic_pointer_cast<Send> (processor) ||
3080 boost::dynamic_pointer_cast<Return> (processor) ||
3081 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
3082 boost::dynamic_pointer_cast<PortInsert> (processor)
3091 ProcessorBox::one_processor_can_be_edited ()
3093 list<ProcessorEntry*> selection = processor_display.selection ();
3094 list<ProcessorEntry*>::iterator i = selection.begin();
3095 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
3099 return (i != selection.end());
3103 ProcessorBox::get_editor_window (boost::shared_ptr<Processor> processor, bool use_custom)
3105 boost::shared_ptr<Send> send;
3106 boost::shared_ptr<InternalSend> internal_send;
3107 boost::shared_ptr<Return> retrn;
3108 boost::shared_ptr<PluginInsert> plugin_insert;
3109 boost::shared_ptr<PortInsert> port_insert;
3112 /* This method may or may not return a Window, but if it does not it
3113 * will modify the parent mixer strip appearance layout to allow
3114 * "editing" the @param processor that was passed in.
3116 * So for example, if the processor is an Amp (gain), the parent strip
3117 * will be forced back into a model where the fader controls the main gain.
3118 * If the processor is a send, then we map the send controls onto the
3121 * Plugins and others will return a window for control.
3124 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
3126 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
3131 if (boost::dynamic_pointer_cast<Amp> (processor) && boost::dynamic_pointer_cast<Amp> (processor)->gain_control()->parameter().type() == GainAutomation) {
3133 if (_parent_strip) {
3134 _parent_strip->revert_to_default_display ();
3137 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
3139 if (!_session->engine().connected()) {
3143 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
3145 gidget = new SendUIWindow (send, _session);
3148 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
3150 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
3151 /* no GUI for these */
3155 if (!_session->engine().connected()) {
3159 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
3161 ReturnUIWindow *return_ui;
3162 Window* w = get_processor_ui (retrn);
3166 return_ui = new ReturnUIWindow (retrn, _session);
3167 return_ui->set_title (retrn->name ());
3168 set_processor_ui (send, return_ui);
3171 return_ui = dynamic_cast<ReturnUIWindow *> (w);
3176 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
3178 PluginUIWindow *plugin_ui;
3180 /* these are both allowed to be null */
3182 Window* w = get_processor_ui (plugin_insert);
3185 plugin_ui = new PluginUIWindow (plugin_insert, false, use_custom);
3186 plugin_ui->set_title (generate_processor_title (plugin_insert));
3187 set_processor_ui (plugin_insert, plugin_ui);
3190 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
3195 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
3197 if (!_session->engine().connected()) {
3198 MessageDialog msg ( _("Not connected to audio engine - no I/O changes are possible"));
3203 PortInsertWindow *io_selector;
3205 Window* w = get_processor_ui (port_insert);
3208 io_selector = new PortInsertWindow (_session, port_insert);
3209 set_processor_ui (port_insert, io_selector);
3212 io_selector = dynamic_cast<PortInsertWindow *> (w);
3215 gidget = io_selector;
3222 ProcessorBox::get_generic_editor_window (boost::shared_ptr<Processor> processor)
3224 boost::shared_ptr<PluginInsert> plugin_insert
3225 = boost::dynamic_pointer_cast<PluginInsert>(processor);
3227 if (!plugin_insert) {
3231 PluginUIWindow* win = new PluginUIWindow (plugin_insert, true, false);
3232 win->set_title (generate_processor_title (plugin_insert));
3238 ProcessorBox::register_actions ()
3240 processor_box_actions = myactions.create_action_group (X_("ProcessorMenu"));
3242 Glib::RefPtr<Action> act;
3245 myactions.register_action (processor_box_actions, X_("newplugin"), _("New Plugin"),
3246 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
3248 act = myactions.register_action (processor_box_actions, X_("newlua"), _("New Lua Proc"),
3249 sigc::ptr_fun (ProcessorBox::rb_choose_lua));
3250 act = myactions.register_action (processor_box_actions, X_("newinsert"), _("New Insert"),
3251 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
3252 ActionManager::engine_sensitive_actions.push_back (act);
3253 act = myactions.register_action (processor_box_actions, X_("newsend"), _("New External Send ..."),
3254 sigc::ptr_fun (ProcessorBox::rb_choose_send));
3255 ActionManager::engine_sensitive_actions.push_back (act);
3257 myactions.register_action (processor_box_actions, X_("newaux"), _("New Aux Send ..."));
3259 myactions.register_action (processor_box_actions, X_("controls"), _("Controls"));
3260 myactions.register_action (processor_box_actions, X_("send_options"), _("Send Options"));
3262 myactions.register_action (processor_box_actions, X_("clear"), _("Clear (all)"),
3263 sigc::ptr_fun (ProcessorBox::rb_clear));
3264 myactions.register_action (processor_box_actions, X_("clear_pre"), _("Clear (pre-fader)"),
3265 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
3266 myactions.register_action (processor_box_actions, X_("clear_post"), _("Clear (post-fader)"),
3267 sigc::ptr_fun (ProcessorBox::rb_clear_post));
3269 /* standard editing stuff */
3271 cut_action = myactions.register_action (processor_box_actions, X_("cut"), _("Cut"),
3272 sigc::ptr_fun (ProcessorBox::rb_cut));
3273 copy_action = myactions.register_action (processor_box_actions, X_("copy"), _("Copy"),
3274 sigc::ptr_fun (ProcessorBox::rb_copy));
3275 delete_action = myactions.register_action (processor_box_actions, X_("delete"), _("Delete"),
3276 sigc::ptr_fun (ProcessorBox::rb_delete));
3278 ActionManager::plugin_selection_sensitive_actions.push_back (cut_action);
3279 ActionManager::plugin_selection_sensitive_actions.push_back (copy_action);
3280 ActionManager::plugin_selection_sensitive_actions.push_back (delete_action);
3282 paste_action = myactions.register_action (processor_box_actions, X_("paste"), _("Paste"),
3283 sigc::ptr_fun (ProcessorBox::rb_paste));
3284 rename_action = myactions.register_action (processor_box_actions, X_("rename"), _("Rename"),
3285 sigc::ptr_fun (ProcessorBox::rb_rename));
3286 myactions.register_action (processor_box_actions, X_("selectall"), _("Select All"),
3287 sigc::ptr_fun (ProcessorBox::rb_select_all));
3288 myactions.register_action (processor_box_actions, X_("deselectall"), _("Deselect All"),
3289 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
3291 /* activation etc. */
3293 myactions.register_action (processor_box_actions, X_("activate_all"), _("Activate All"),
3294 sigc::ptr_fun (ProcessorBox::rb_activate_all));
3295 myactions.register_action (processor_box_actions, X_("deactivate_all"), _("Deactivate All"),
3296 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
3297 myactions.register_action (processor_box_actions, X_("ab_plugins"), _("A/B Plugins"),
3298 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
3300 manage_pins_action = myactions.register_action (
3301 processor_box_actions, X_("manage-pins"), _("Pin Management..."),
3302 sigc::ptr_fun (ProcessorBox::rb_manage_pins));
3305 edit_action = myactions.register_action (
3306 processor_box_actions, X_("edit"), _("Edit..."),
3307 sigc::ptr_fun (ProcessorBox::rb_edit));
3309 edit_generic_action = myactions.register_action (
3310 processor_box_actions, X_("edit-generic"), _("Edit with generic controls..."),
3311 sigc::ptr_fun (ProcessorBox::rb_edit_generic));
3317 ProcessorBox::rb_edit_generic ()
3319 if (_current_processor_box == 0) {
3323 _current_processor_box->for_selected_processors (&ProcessorBox::generic_edit_processor);
3327 ProcessorBox::rb_ab_plugins ()
3329 if (_current_processor_box == 0) {
3333 _current_processor_box->ab_plugins ();
3337 ProcessorBox::rb_manage_pins ()
3339 if (_current_processor_box == 0) {
3343 _current_processor_box->for_selected_processors (&ProcessorBox::manage_pins);
3346 ProcessorBox::rb_choose_plugin ()
3348 if (_current_processor_box == 0) {
3351 _current_processor_box->choose_plugin ();
3355 ProcessorBox::rb_choose_lua ()
3357 if (_current_processor_box == 0) {
3360 _current_processor_box->choose_lua ();
3364 ProcessorBox::rb_choose_insert ()
3366 if (_current_processor_box == 0) {
3369 _current_processor_box->choose_insert ();
3373 ProcessorBox::rb_choose_send ()
3375 if (_current_processor_box == 0) {
3378 _current_processor_box->choose_send ();
3382 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
3384 if (_current_processor_box == 0) {
3388 _current_processor_box->choose_aux (wr);
3392 ProcessorBox::rb_clear ()
3394 if (_current_processor_box == 0) {
3398 _current_processor_box->clear_processors ();
3403 ProcessorBox::rb_clear_pre ()
3405 if (_current_processor_box == 0) {
3409 _current_processor_box->clear_processors (PreFader);
3414 ProcessorBox::rb_clear_post ()
3416 if (_current_processor_box == 0) {
3420 _current_processor_box->clear_processors (PostFader);
3424 ProcessorBox::rb_cut ()
3426 if (_current_processor_box == 0) {
3430 _current_processor_box->processor_operation (ProcessorsCut);
3434 ProcessorBox::rb_delete ()
3436 if (_current_processor_box == 0) {
3440 _current_processor_box->processor_operation (ProcessorsDelete);
3444 ProcessorBox::rb_copy ()
3446 if (_current_processor_box == 0) {
3449 _current_processor_box->processor_operation (ProcessorsCopy);
3453 ProcessorBox::rb_paste ()
3455 if (_current_processor_box == 0) {
3459 _current_processor_box->processor_operation (ProcessorsPaste);
3463 ProcessorBox::rb_rename ()
3465 if (_current_processor_box == 0) {
3468 _current_processor_box->rename_processors ();
3472 ProcessorBox::rb_select_all ()
3474 if (_current_processor_box == 0) {
3478 _current_processor_box->processor_operation (ProcessorsSelectAll);
3482 ProcessorBox::rb_deselect_all ()
3484 if (_current_processor_box == 0) {
3488 _current_processor_box->deselect_all_processors ();
3492 ProcessorBox::rb_activate_all ()
3494 if (_current_processor_box == 0) {
3498 _current_processor_box->all_visible_processors_active (true);
3502 ProcessorBox::rb_deactivate_all ()
3504 if (_current_processor_box == 0) {
3507 _current_processor_box->all_visible_processors_active (false);
3511 ProcessorBox::rb_edit ()
3513 if (_current_processor_box == 0) {
3517 _current_processor_box->for_selected_processors (&ProcessorBox::edit_processor);
3521 ProcessorBox::edit_aux_send (boost::shared_ptr<Processor> processor)
3523 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
3527 if (_parent_strip) {
3528 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
3529 if (_parent_strip->current_delivery() == send) {
3530 _parent_strip->revert_to_default_display ();
3532 _parent_strip->show_send(send);
3539 ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
3544 if (edit_aux_send (processor)) {
3548 ProcessorWindowProxy* proxy = find_window_proxy (processor);
3551 proxy->set_custom_ui_mode (true);
3552 proxy->show_the_right_window ();
3557 ProcessorBox::generic_edit_processor (boost::shared_ptr<Processor> processor)
3562 if (edit_aux_send (processor)) {
3566 ProcessorWindowProxy* proxy = find_window_proxy (processor);
3569 proxy->set_custom_ui_mode (false);
3570 proxy->show_the_right_window ();
3575 ProcessorBox::manage_pins (boost::shared_ptr<Processor> processor)
3580 PluginPinWindowProxy* proxy = processor->pinmgr_proxy ();
3589 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
3591 if (!what_changed.contains (ARDOUR::Properties::name)) {
3595 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
3597 boost::shared_ptr<Processor> processor;
3598 boost::shared_ptr<PluginInsert> plugin_insert;
3599 boost::shared_ptr<Send> send;
3601 list<ProcessorEntry*> children = processor_display.children();
3603 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
3605 processor = (*iter)->processor ();
3611 Window* w = get_processor_ui (processor);
3617 /* rename editor windows for sends and plugins */
3619 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
3620 w->set_title (send->name ());
3621 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
3622 w->set_title (generate_processor_title (plugin_insert));
3628 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
3630 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
3631 string::size_type email_pos;
3633 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
3634 maker = maker.substr (0, email_pos - 1);
3637 if (maker.length() > 32) {
3638 maker = maker.substr (0, 32);
3642 SessionObject* owner = pi->owner();
3645 return string_compose(_("%1: %2 (by %3)"), owner->name(), pi->name(), maker);
3647 return string_compose(_("%1 (by %2)"), pi->name(), maker);
3651 /** @param p Processor.
3652 * @return the UI window for \a p.
3655 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
3657 ProcessorWindowProxy* wp = p->window_proxy();
3664 /** Make a note of the UI window that a processor is using.
3665 * @param p Processor.
3666 * @param w UI window.
3669 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
3671 assert (p->window_proxy());
3673 p->window_proxy()->use_window (*w);
3677 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
3679 boost::shared_ptr<Delivery> d = w.lock ();
3684 list<ProcessorEntry*> children = processor_display.children ();
3685 list<ProcessorEntry*>::const_iterator i = children.begin();
3686 while (i != children.end() && (*i)->processor() != d) {
3690 if (i == children.end()) {
3691 processor_display.set_active (0);
3693 processor_display.set_active (*i);
3697 /** Called to repair the damage of Editor::show_window doing a show_all() */
3699 ProcessorBox::hide_things ()
3701 list<ProcessorEntry*> c = processor_display.children ();
3702 for (list<ProcessorEntry*>::iterator i = c.begin(); i != c.end(); ++i) {
3703 (*i)->hide_things ();
3708 ProcessorBox::processor_menu_unmapped ()
3710 processor_display.remove_placeholder ();
3711 /* make all possibly-desensitized actions sensitive again so that
3712 they be activated by other means (e.g. bindings)
3714 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, true);
3718 ProcessorBox::entry_gui_object_state (ProcessorEntry* entry)
3720 if (!_parent_strip) {
3724 GUIObjectState& st = _parent_strip->gui_object_state ();
3726 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
3728 return st.get_or_add_node (strip, entry->state_id());
3732 ProcessorBox::update_gui_object_state (ProcessorEntry* entry)
3734 XMLNode* proc = entry_gui_object_state (entry);
3739 /* XXX: this is a bit inefficient; we just remove all child nodes and re-add them */
3740 proc->remove_nodes_and_delete (X_("Object"));
3741 entry->add_control_state (proc);
3745 ProcessorBox::is_editor_mixer_strip() const
3747 return _parent_strip && !_parent_strip->mixer_owned();
3750 ProcessorWindowProxy::ProcessorWindowProxy (string const & name, ProcessorBox* box, boost::weak_ptr<Processor> processor)
3751 : WM::ProxyBase (name, string())
3752 , _processor_box (box)
3753 , _processor (processor)
3755 , want_custom (false)
3757 boost::shared_ptr<Processor> p = _processor.lock ();
3761 p->DropReferences.connect (going_away_connection, MISSING_INVALIDATOR, boost::bind (&ProcessorWindowProxy::processor_going_away, this), gui_context());
3764 ProcessorWindowProxy::~ProcessorWindowProxy()
3766 /* processor window proxies do not own the windows they create with
3767 * ::get(), so set _window to null before the normal WindowProxy method
3774 ProcessorWindowProxy::processor_going_away ()
3778 WM::Manager::instance().remove (this);
3779 /* should be no real reason to do this, since the object that would
3780 send DropReferences is about to be deleted, but lets do it anyway.
3782 going_away_connection.disconnect();
3785 ARDOUR::SessionHandlePtr*
3786 ProcessorWindowProxy::session_handle()
3793 ProcessorWindowProxy::get_state ()
3796 node = &ProxyBase::get_state();
3797 node->add_property (X_("custom-ui"), is_custom? X_("yes") : X_("no"));
3802 ProcessorWindowProxy::set_state (const XMLNode& node, int /*version*/)
3804 XMLNodeList children = node.children ();
3805 XMLNodeList::const_iterator i = children.begin ();
3806 while (i != children.end()) {
3807 XMLProperty* prop = (*i)->property (X_("name"));
3808 if ((*i)->name() == X_("Window") && prop && prop->value() == _name) {
3814 if (i != children.end()) {
3816 if ((prop = (*i)->property (X_("custom-ui"))) != 0) {
3817 want_custom = PBD::string_is_affirmative (prop->value ());
3821 return ProxyBase::set_state (node, 0);
3825 ProcessorWindowProxy::get (bool create)
3827 boost::shared_ptr<Processor> p = _processor.lock ();
3832 if (_window && (is_custom != want_custom)) {
3833 /* drop existing window - wrong type */
3842 is_custom = want_custom;
3843 _window = _processor_box->get_editor_window (p, is_custom);
3849 _window->show_all ();
3854 ProcessorWindowProxy::show_the_right_window ()
3856 if (_window && (is_custom != want_custom)) {
3857 /* drop existing window - wrong type */
3862 is_custom = want_custom;
3869 PluginPinWindowProxy::PluginPinWindowProxy(std::string const &name, boost::weak_ptr<ARDOUR::Processor> processor)
3870 : WM::ProxyBase (name, string())
3871 , _processor (processor)
3873 boost::shared_ptr<Processor> p = _processor.lock ();
3877 p->DropReferences.connect (going_away_connection, MISSING_INVALIDATOR, boost::bind (&PluginPinWindowProxy::processor_going_away, this), gui_context());
3880 PluginPinWindowProxy::~PluginPinWindowProxy()
3887 PluginPinWindowProxy::get (bool create)
3889 boost::shared_ptr<Processor> p = _processor.lock ();
3890 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (p);
3899 _window = new PluginPinDialog (pi);
3902 _window->show_all ();
3907 PluginPinWindowProxy::processor_going_away ()
3911 WM::Manager::instance().remove (this);
3912 going_away_connection.disconnect();
3916 ProcessorBox::load_bindings ()
3918 bindings = Bindings::get_bindings (X_("Processor Box"), myactions);