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;
119 static const uint32_t audio_port_color = 0x4A8A0EFF; // Green
120 static const uint32_t midi_port_color = 0x960909FF; //Red
122 ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processor> p, Width w)
123 : _button (ArdourButton::led_default_elements)
124 , _position (PreFader)
127 , _unknown_processor(false)
132 , _output_icon(false)
137 _button.set_distinct_led_click (true);
138 _button.set_fallthrough_to_parent(true);
139 _button.set_led_left (true);
140 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &ProcessorEntry::led_clicked));
141 _button.set_text (name (_width));
143 if (boost::dynamic_pointer_cast<PeakMeter> (_processor)) {
144 _button.set_elements(ArdourButton::Element(_button.elements() & ~ArdourButton::Indicator));
146 if (boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
147 _button.set_elements(ArdourButton::Element(_button.elements() & ~ArdourButton::Indicator));
148 _unknown_processor = true;
151 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
152 if (pi && pi->plugin() && pi->plugin()->get_info()->type != ARDOUR::Lua) {
153 _plugin_preset_pointer = PluginPresetPtr (new PluginPreset (pi->plugin()->get_info()));
158 _vbox.pack_start (_routing_icon);
159 _vbox.pack_start (_input_icon);
160 _vbox.pack_start (_button, true, true);
162 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
163 if (pi && pi->plugin() && pi->plugin()->has_inline_display()) {
164 if (pi->plugin()->get_info()->type != ARDOUR::Lua) {
165 _plugin_display = new PluginDisplay (pi->plugin(),
166 std::max (60.f, rintf(112.f * UIConfiguration::instance().get_ui_scale())));
168 assert (boost::dynamic_pointer_cast<LuaProc>(pi->plugin()));
169 _plugin_display = new LuaPluginDisplay (boost::dynamic_pointer_cast<LuaProc>(pi->plugin()),
170 std::max (60.f, rintf(112.f * UIConfiguration::instance().get_ui_scale())));
172 _vbox.pack_start (*_plugin_display);
173 _plugin_display->set_no_show_all (true);
174 if (UIConfiguration::instance().get_show_inline_display_by_default ()) {
175 _plugin_display->show ();
178 _vbox.pack_end (_output_icon);
180 _button.set_active (_processor->active());
182 _routing_icon.set_no_show_all(true);
183 _input_icon.set_no_show_all(true);
186 _routing_icon.set_visible(false);
190 _processor->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_active_changed, this), gui_context());
191 _processor->PropertyChanged.connect (name_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_property_changed, this, _1), gui_context());
192 _processor->ConfigurationChanged.connect (config_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_configuration_changed, this, _1, _2), gui_context());
194 set<Evoral::Parameter> p = _processor->what_can_be_automated ();
195 for (set<Evoral::Parameter>::iterator i = p.begin(); i != p.end(); ++i) {
197 std::string label = _processor->describe_parameter (*i);
199 if (boost::dynamic_pointer_cast<Send> (_processor)) {
201 } else if (boost::dynamic_pointer_cast<Return> (_processor)) {
205 Control* c = new Control (_processor->automation_control (*i), label);
207 _controls.push_back (c);
209 if (boost::dynamic_pointer_cast<Amp> (_processor) == 0) {
210 /* Add non-Amp (Fader & Trim) controls to the processor box */
211 _vbox.pack_start (c->box);
215 _input_icon.set_ports(_processor->input_streams());
216 _output_icon.set_ports(_processor->output_streams());
218 _routing_icon.set_sources(_processor->input_streams());
219 _routing_icon.set_sinks(_processor->output_streams());
224 _vbox.set_size_request (-1, _button.size_request().height);
228 ProcessorEntry::~ProcessorEntry ()
230 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
233 delete _plugin_display;
237 ProcessorEntry::action_widget ()
243 ProcessorEntry::widget ()
249 ProcessorEntry::drag_text () const
255 ProcessorEntry::can_copy_state (Gtkmm2ext::DnDVBoxChild* o) const
257 ProcessorEntry *other = dynamic_cast<ProcessorEntry*> (o);
261 boost::shared_ptr<ARDOUR::Processor> otherproc = other->processor();
262 boost::shared_ptr<PluginInsert> my_pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
263 boost::shared_ptr<PluginInsert> ot_pi = boost::dynamic_pointer_cast<PluginInsert> (otherproc);
264 if (boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
267 if (boost::dynamic_pointer_cast<UnknownProcessor> (otherproc)) {
270 if (!my_pi || !ot_pi) {
273 if (my_pi->type() != ot_pi->type()) {
276 boost::shared_ptr<Plugin> my_p = my_pi->plugin();
277 boost::shared_ptr<Plugin> ot_p = ot_pi->plugin();
278 if (!my_p || !ot_p) {
281 if (my_p->unique_id() != ot_p->unique_id()) {
288 ProcessorEntry::drag_data_get (Glib::RefPtr<Gdk::DragContext> const, Gtk::SelectionData &data)
290 if (data.get_target() == "PluginPresetPtr") {
291 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
293 if (!_plugin_preset_pointer || !pi) {
294 data.set (data.get_target(), 8, NULL, 0);
298 boost::shared_ptr<ARDOUR::Plugin> plugin = pi->plugin();
301 PluginManager& manager (PluginManager::instance());
302 bool fav = manager.get_status (_plugin_preset_pointer->_pip) == PluginManager::Favorite;
304 NewPluginPresetDialog d (plugin,
305 string_compose(_("New Favorite Preset for \"%1\""),_plugin_preset_pointer->_pip->name), !fav);
307 _plugin_preset_pointer->_preset.valid = false;
310 case Gtk::RESPONSE_CANCEL:
311 data.set (data.get_target(), 8, NULL, 0);
315 case Gtk::RESPONSE_NO:
318 case Gtk::RESPONSE_ACCEPT:
319 if (d.name().empty()) {
324 plugin->remove_preset (d.name ());
327 Plugin::PresetRecord const r = plugin->save_preset (d.name());
329 if (!r.uri.empty ()) {
330 _plugin_preset_pointer->_preset.uri = r.uri;
331 _plugin_preset_pointer->_preset.label = r.label;
332 _plugin_preset_pointer->_preset.user = r.user;
333 _plugin_preset_pointer->_preset.valid = r.valid;
336 data.set (data.get_target(), 8, (const guchar *) &_plugin_preset_pointer, sizeof (PluginPresetPtr));
343 ProcessorEntry::set_position (Position p, uint32_t num)
348 if (_position_num == 0 || _routing_icon.get_visible()) {
358 ProcessorEntry::set_visual_state (Gtkmm2ext::VisualState s, bool yn)
361 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() | s));
363 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() & ~s));
368 ProcessorEntry::setup_visuals ()
370 if (_unknown_processor) {
371 _button.set_name ("processor stub");
377 if (_plugin_display) { _plugin_display->set_name ("processor prefader"); }
378 _button.set_name ("processor prefader");
382 _button.set_name ("processor fader");
386 if (_plugin_display) { _plugin_display->set_name ("processor postfader"); }
387 _button.set_name ("processor postfader");
393 boost::shared_ptr<Processor>
394 ProcessorEntry::processor () const
397 return boost::shared_ptr<Processor>();
403 ProcessorEntry::set_enum_width (Width w)
406 _button.set_text (name (_width));
410 ProcessorEntry::led_clicked(GdkEventButton *ev)
412 bool ctrl_shift_pressed = false;
413 Keyboard::ModifierMask ctrl_shift_mask = Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier);
415 if (Keyboard::modifier_state_equals (ev->state, ctrl_shift_mask)) {
416 ctrl_shift_pressed = true;
420 if (_button.get_active ()) {
421 if (ctrl_shift_pressed) {
422 _parent->all_visible_processors_active(false);
424 if (_position == Fader) {
425 _processor->deactivate ();
429 _processor->deactivate ();
433 if (ctrl_shift_pressed) {
434 _parent->all_visible_processors_active(true);
436 if (_position == Fader) {
437 _processor->activate ();
441 _processor->activate ();
448 ProcessorEntry::processor_active_changed ()
451 _button.set_active (_processor->active());
456 ProcessorEntry::processor_property_changed (const PropertyChange& what_changed)
458 if (what_changed.contains (ARDOUR::Properties::name)) {
459 _button.set_text (name (_width));
465 ProcessorEntry::processor_configuration_changed (const ChanCount in, const ChanCount out)
467 _input_icon.set_ports(in);
468 _output_icon.set_ports(out);
469 _routing_icon.set_sources(in);
470 _routing_icon.set_sinks(out);
471 _input_icon.queue_draw();
472 _output_icon.queue_draw();
473 _routing_icon.queue_draw();
477 ProcessorEntry::setup_tooltip ()
480 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
482 std::string postfix = "";
484 if ((replicated = pi->get_count()) > 1) {
485 postfix = string_compose(_("\nThis mono plugin has been replicated %1 times."), replicated);
487 if (pi->plugin()->has_editor()) {
488 ARDOUR_UI_UTILS::set_tooltip (_button,
489 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));
491 ARDOUR_UI_UTILS::set_tooltip (_button,
492 string_compose (_("<b>%1</b>\nDouble-click to show generic GUI.%2"), name (Wide), postfix));
496 if(boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
497 ARDOUR_UI::instance()->set_tip (_button,
498 string_compose (_("<b>%1</b>\nThe Plugin is not available on this system\nand has been replaced by a stub."), name (Wide)));
502 ARDOUR_UI_UTILS::set_tooltip (_button, string_compose ("<b>%1</b>", name (Wide)));
506 ProcessorEntry::name (Width w) const
508 boost::shared_ptr<Send> send;
515 if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
516 !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
520 /* grab the send name out of its overall name */
522 string::size_type lbracket, rbracket;
523 lbracket = send->name().find ('[');
524 rbracket = send->name().find (']');
528 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
531 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
536 boost::shared_ptr<ARDOUR::PluginInsert> pi;
538 if ((pi = boost::dynamic_pointer_cast<ARDOUR::PluginInsert> (_processor)) != 0
539 && (replicated = pi->get_count()) > 1)
541 name_display += string_compose(_("(%1x1) "), replicated);
546 name_display += _processor->display_name();
549 name_display += PBD::short_version (_processor->display_name(), 5);
559 ProcessorEntry::show_all_controls ()
561 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
562 (*i)->set_visible (true);
565 _parent->update_gui_object_state (this);
569 ProcessorEntry::hide_all_controls ()
571 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
572 (*i)->set_visible (false);
575 _parent->update_gui_object_state (this);
579 ProcessorEntry::add_control_state (XMLNode* node) const
581 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
582 (*i)->add_state (node);
585 if (_plugin_display) {
586 XMLNode* c = new XMLNode (X_("Object"));
587 c->add_property (X_("id"), X_("InlineDisplay"));
588 c->add_property (X_("visible"), _plugin_display->is_visible ());
589 node->add_child_nocopy (*c);
594 ProcessorEntry::set_control_state (XMLNode const * node)
596 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
597 (*i)->set_state (node);
600 if (_plugin_display) {
601 XMLNode* n = GUIObjectState::get_node (node, X_("InlineDisplay"));
602 XMLProperty* p = n ? n->property (X_("visible")) : NULL;
604 if (string_is_affirmative (p->value ())) {
605 _plugin_display->show();
607 _plugin_display->hide();
614 ProcessorEntry::state_id () const
616 return string_compose ("processor %1", _processor->id().to_s());
620 ProcessorEntry::hide_things ()
622 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
623 (*i)->hide_things ();
629 ProcessorEntry::build_controls_menu ()
631 using namespace Menu_Helpers;
632 Menu* menu = manage (new Menu);
633 MenuList& items = menu->items ();
635 if (_plugin_display) {
636 items.push_back (CheckMenuElem (_("Inline Display")));
637 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
638 c->set_active (_plugin_display->is_visible ());
639 c->signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::toggle_inline_display_visibility));
640 items.push_back (SeparatorElem ());
644 MenuElem (_("Show All Controls"), sigc::mem_fun (*this, &ProcessorEntry::show_all_controls))
648 MenuElem (_("Hide All Controls"), sigc::mem_fun (*this, &ProcessorEntry::hide_all_controls))
651 if (!_controls.empty ()) {
652 items.push_back (SeparatorElem ());
655 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
656 items.push_back (CheckMenuElem ((*i)->name ()));
657 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
658 c->set_active ((*i)->visible ());
659 c->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &ProcessorEntry::toggle_control_visibility), *i));
666 ProcessorEntry::toggle_inline_display_visibility ()
668 if (_plugin_display->is_visible ()) {
669 _plugin_display->hide();
671 _plugin_display->show();
673 _parent->update_gui_object_state (this);
677 ProcessorEntry::toggle_control_visibility (Control* c)
679 c->set_visible (!c->visible ());
680 _parent->update_gui_object_state (this);
684 ProcessorEntry::build_send_options_menu ()
686 using namespace Menu_Helpers;
687 Menu* menu = manage (new Menu);
688 MenuList& items = menu->items ();
690 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (_processor);
693 items.push_back (CheckMenuElem (_("Link panner controls")));
694 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
695 c->set_active (send->panner_shell()->is_linked_to_route());
696 c->signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::toggle_panner_link));
703 ProcessorEntry::toggle_panner_link ()
705 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (_processor);
707 send->panner_shell()->set_linked_to_route(!send->panner_shell()->is_linked_to_route());
711 ProcessorEntry::Control::Control (boost::shared_ptr<AutomationControl> c, string const & n)
713 , _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1)
714 , _slider (&_adjustment, boost::shared_ptr<PBD::Controllable>(), 0, max(13.f, rintf(13.f * UIConfiguration::instance().get_ui_scale())))
715 , _slider_persistant_tooltip (&_slider)
716 , _button (ArdourButton::led_default_elements)
717 , _ignore_ui_adjustment (false)
721 _slider.set_controllable (c);
722 box.set_padding(0, 0, 4, 4);
725 _button.set_text (_name);
726 _button.set_led_left (true);
727 _button.set_name ("processor control button");
731 _button.signal_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked));
732 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked_event));
733 // dup. currently timers are used :(
734 //c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
738 _slider.set_name ("ProcessorControlSlider");
739 _slider.set_text (_name);
744 const ARDOUR::ParameterDescriptor& desc = c->desc();
745 double const lo = c->internal_to_interface(desc.lower);
746 double const up = c->internal_to_interface(desc.upper);
747 double const normal = c->internal_to_interface(desc.normal);
748 double smallstep = desc.smallstep;
749 double largestep = desc.largestep;
751 if (smallstep == 0.0) {
752 smallstep = up / 1000.;
754 smallstep = c->internal_to_interface(desc.lower + smallstep);
757 if (largestep == 0.0) {
758 largestep = up / 40.;
760 largestep = c->internal_to_interface(desc.lower + largestep);
763 _adjustment.set_lower (lo);
764 _adjustment.set_upper (up);
765 _adjustment.set_step_increment (smallstep);
766 _adjustment.set_page_increment (largestep);
767 _slider.set_default_value (normal);
769 _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &Control::slider_adjusted));
770 // dup. currently timers are used :(
771 //c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
774 // yuck, do we really need to do this?
775 // according to c404374 this is only needed for send automation
776 timer_connection = Timers::rapid_connect (sigc::mem_fun (*this, &Control::control_changed));
781 /* We're providing our own PersistentTooltip */
782 set_no_tooltip_whatsoever (_slider);
785 ProcessorEntry::Control::~Control ()
787 timer_connection.disconnect ();
791 ProcessorEntry::Control::set_tooltip ()
793 boost::shared_ptr<AutomationControl> c = _control.lock ();
800 snprintf (tmp, sizeof(tmp), "%s: %s", _name.c_str(), c->get_value() > 0.5 ? _("on") : _("off"));
802 snprintf (tmp, sizeof(tmp), "%s: %.2f", _name.c_str(), c->internal_to_user (c->get_value ()));
805 string sm = Gtkmm2ext::markup_escape_text (tmp);
806 _slider_persistant_tooltip.set_tip (sm);
807 ARDOUR_UI_UTILS::set_tooltip (_button, sm);
811 ProcessorEntry::Control::slider_adjusted ()
813 if (_ignore_ui_adjustment) {
817 boost::shared_ptr<AutomationControl> c = _control.lock ();
823 c->set_value ( c->interface_to_internal(_adjustment.get_value ()) , Controllable::NoGroup);
828 ProcessorEntry::Control::button_clicked ()
830 boost::shared_ptr<AutomationControl> c = _control.lock ();
836 bool const n = _button.get_active ();
838 c->set_value (n ? 0 : 1, Controllable::NoGroup);
839 _button.set_active (!n);
844 ProcessorEntry::Control::button_clicked_event (GdkEventButton *ev)
852 ProcessorEntry::Control::control_changed ()
854 boost::shared_ptr<AutomationControl> c = _control.lock ();
859 _ignore_ui_adjustment = true;
863 _button.set_active (c->get_value() > 0.5);
866 // as long as rapid timers are used, only update the tooltip
867 // if the value has changed.
868 const double nval = c->internal_to_interface (c->get_value ());
869 if (_adjustment.get_value() != nval) {
870 _adjustment.set_value (nval);
875 _ignore_ui_adjustment = false;
879 ProcessorEntry::Control::add_state (XMLNode* node) const
881 XMLNode* c = new XMLNode (X_("Object"));
882 c->add_property (X_("id"), state_id ());
883 c->add_property (X_("visible"), _visible);
884 node->add_child_nocopy (*c);
888 ProcessorEntry::Control::set_state (XMLNode const * node)
890 XMLNode* n = GUIObjectState::get_node (node, state_id ());
892 XMLProperty* p = n->property (X_("visible"));
893 set_visible (p && string_is_affirmative (p->value ()));
900 ProcessorEntry::Control::set_visible (bool v)
911 /** Called when the Editor might have re-shown things that
915 ProcessorEntry::Control::hide_things ()
923 ProcessorEntry::Control::state_id () const
925 boost::shared_ptr<AutomationControl> c = _control.lock ();
928 return string_compose (X_("control %1"), c->id().to_s ());
931 PluginInsertProcessorEntry::PluginInsertProcessorEntry (ProcessorBox* b, boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
932 : ProcessorEntry (b, p, w)
935 p->PluginIoReConfigure.connect (
936 _splitting_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::plugin_insert_splitting_changed, this), gui_context()
939 plugin_insert_splitting_changed ();
943 PluginInsertProcessorEntry::plugin_insert_splitting_changed ()
945 ChanCount in, out; // actual configured i/o
946 _plugin_insert->configured_io (in, out);
948 /* get number of input ports */
949 ChanCount sinks = _plugin_insert->natural_input_streams();
950 if (!_plugin_insert->splitting () && _plugin_insert->get_count() > 1) {
951 /* replicated instances */
952 for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
953 sinks.set(*t, sinks.get(*t) * _plugin_insert->get_count());
957 if (_plugin_insert->natural_output_streams().n_midi() == 0 &&
958 _plugin_insert->output_streams().n_midi() == 1) {
959 in.set(DataType::MIDI, 1);
960 out.set(DataType::MIDI, 1);
961 sinks.set(DataType::MIDI, 1);
964 /* the Input streams available (*valid* outputs from prev. plugin)
965 * this will be <= sinks. Some input-ports of this processor
966 * may be unconnected.
968 _routing_icon.set_sources(in);
970 /* the actual input ports of this processor */
971 _input_icon.set_ports(sinks);
972 _routing_icon.set_sinks(sinks);
974 /* set/override plugin-output ports to actual outputs-streams.
976 * This plugin may have unconnected output-ports (currently only in Mixbus,
977 * e.g channelstrip-EQ at the top of a MIDI-channel before the synth).
979 * The *next* processor below this one will only see the
980 * actual available streams (it cannot know the real outputs
983 * There is currently no API to query the ports of the previous (or next)
986 * (normally - iff configuration succeeds - this is set during
987 * ProcessorEntry::processor_configuration_changed() and should
988 * equal _plugin_insert->output_streams())
990 _output_icon.set_ports(out);
992 if (out != _plugin_insert->output_streams()) {
993 std::cerr << "Processor Wiring: " << processor()->name()
994 << " out-ports: " << _plugin_insert->output_streams() // NB. does not include midi-bypass
995 << " out-connections: " << out
1000 _routing_icon.set_splitting(_plugin_insert->splitting ());
1002 if (_plugin_insert->splitting () || in != sinks)
1004 _routing_icon.set_size_request (-1, std::max (7.f, rintf(7.f * UIConfiguration::instance().get_ui_scale())));
1005 _routing_icon.set_visible(true);
1008 _routing_icon.set_visible(false);
1009 if (_position_num != 0) {
1014 _input_icon.queue_draw();
1015 _output_icon.queue_draw();
1016 _routing_icon.queue_draw();
1020 PluginInsertProcessorEntry::hide_things ()
1022 ProcessorEntry::hide_things ();
1023 plugin_insert_splitting_changed ();
1026 ProcessorEntry::PortIcon::PortIcon(bool input) {
1028 _ports = ARDOUR::ChanCount(ARDOUR::DataType::AUDIO, 1);
1029 set_size_request (-1, std::max (2.f, rintf(2.f * UIConfiguration::instance().get_ui_scale())));
1033 ProcessorEntry::PortIcon::on_expose_event (GdkEventExpose* ev)
1035 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
1037 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
1040 Gtk::Allocation a = get_allocation();
1041 double const width = a.get_width();
1042 double const height = a.get_height();
1044 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
1045 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
1047 cairo_rectangle (cr, 0, 0, width, height);
1050 const double dx = rint(max(2., 2. * UIConfiguration::instance().get_ui_scale()));
1051 if (_ports.n_total() > 1) {
1052 for (uint32_t i = 0; i < _ports.n_total(); ++i) {
1053 if (i < _ports.n_midi()) {
1054 cairo_set_source_rgb (cr,
1055 UINT_RGBA_R_FLT(midi_port_color),
1056 UINT_RGBA_G_FLT(midi_port_color),
1057 UINT_RGBA_B_FLT(midi_port_color));
1059 cairo_set_source_rgb (cr,
1060 UINT_RGBA_R_FLT(audio_port_color),
1061 UINT_RGBA_G_FLT(audio_port_color),
1062 UINT_RGBA_B_FLT(audio_port_color));
1064 const float x = rintf(width * (.2f + .6f * i / (_ports.n_total() - 1.f)));
1065 cairo_rectangle (cr, x-dx * .5, 0, 1+dx, height);
1068 } else if (_ports.n_total() == 1) {
1069 if (_ports.n_midi() == 1) {
1070 cairo_set_source_rgb (cr,
1071 UINT_RGBA_R_FLT(midi_port_color),
1072 UINT_RGBA_G_FLT(midi_port_color),
1073 UINT_RGBA_B_FLT(midi_port_color));
1075 cairo_set_source_rgb (cr,
1076 UINT_RGBA_R_FLT(audio_port_color),
1077 UINT_RGBA_G_FLT(audio_port_color),
1078 UINT_RGBA_B_FLT(audio_port_color));
1080 const float x = rintf(width * .5);
1081 cairo_rectangle (cr, x-dx * .5, 0, 1+dx, height);
1091 ProcessorEntry::RoutingIcon::on_expose_event (GdkEventExpose* ev)
1093 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
1095 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
1098 cairo_set_line_width (cr, max (1.f, UIConfiguration::instance().get_ui_scale()));
1099 cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
1101 Gtk::Allocation a = get_allocation();
1102 double const width = a.get_width();
1103 double const height = a.get_height();
1105 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
1106 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
1108 cairo_rectangle (cr, 0, 0, width, height);
1111 Gdk::Color const fg = get_style()->get_fg (STATE_NORMAL);
1112 cairo_set_source_rgb (cr, fg.get_red_p (), fg.get_green_p (), fg.get_blue_p ());
1114 const uint32_t sources = _sources.n_total();
1115 const uint32_t sinks = _sinks.n_total();
1117 const uint32_t midi_sources = _sources.n_midi();
1118 const uint32_t midi_sinks = _sinks.n_midi();
1119 const uint32_t audio_sources = _sources.n_audio();
1120 const uint32_t audio_sinks = _sinks.n_audio();
1123 cairo_set_source_rgb (cr,
1124 UINT_RGBA_R_FLT(midi_port_color),
1125 UINT_RGBA_G_FLT(midi_port_color),
1126 UINT_RGBA_B_FLT(midi_port_color));
1127 if (midi_sources > 0 && midi_sinks > 0 && sinks > 1 && sources > 1) {
1128 for (uint32_t i = 0 ; i < midi_sources; ++i) {
1129 const float si_x = rintf(width * (.2f + .6f * i / (sinks - 1.f))) + .5f;
1130 const float si_x0 = rintf(width * (.2f + .6f * i / (sources - 1.f))) + .5f;
1131 cairo_move_to (cr, si_x, height);
1132 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
1135 } else if (midi_sources == 1 && midi_sinks == 1 && sinks == 1 && sources == 1) {
1136 const float si_x = rintf(width * .5f) + .5f;
1137 cairo_move_to (cr, si_x, height);
1138 cairo_line_to (cr, si_x, 0);
1140 } else if (midi_sources == 1 && midi_sinks == 1) {
1141 /* unusual cases -- removed synth, midi-track w/audio plugins */
1142 const float si_x = rintf(width * (sinks > 1 ? .2f : .5f)) + .5f;
1143 const float si_x0 = rintf(width * (sources > 1 ? .2f : .5f)) + .5f;
1144 cairo_move_to (cr, si_x, height);
1145 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
1147 } else if (midi_sources == 0 && midi_sinks == 1) {
1148 const double dx = 1 + rint(max(2., 2. * UIConfiguration::instance().get_ui_scale()));
1150 // TODO connect back to track-input of last midi-out if any, otherwise draw "X"
1151 const float si_x = rintf(width * .2f) + .5f;
1152 cairo_move_to (cr, si_x, height);
1153 cairo_line_to (cr, si_x, height * .66);
1154 cairo_move_to (cr, si_x - dx, height * .66);
1155 cairo_line_to (cr, si_x + dx, height * .66);
1158 } else if (midi_sources != 0 && midi_sinks != 0) {
1159 PBD::warning << string_compose("Programming error: midi routing display: A %1 -> %2 | M %3 -> %4 | T %5 -> %6",
1160 audio_sources, audio_sinks, midi_sources, midi_sinks, sources, sinks) << endmsg;
1165 cairo_set_source_rgb (cr,
1166 UINT_RGBA_R_FLT(audio_port_color),
1167 UINT_RGBA_G_FLT(audio_port_color),
1168 UINT_RGBA_B_FLT(audio_port_color));
1171 assert(audio_sources < 2);
1172 assert(audio_sinks > 1);
1173 /* assume there is only ever one MIDI port */
1174 const float si_x0 = rintf(width * (midi_sources > 0 ? .8f : .5f)) + .5f;
1175 for (uint32_t i = midi_sinks; i < sinks; ++i) {
1176 const float si_x = rintf(width * (.2f + .6f * i / (sinks - 1.f))) + .5f;
1177 cairo_move_to (cr, si_x, height);
1178 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
1181 } else if (audio_sources > 1 && sinks > 1) {
1182 for (uint32_t i = 0 ; i < audio_sources; ++i) {
1183 const float si_x = rintf(width * (.2f + .6f * (i + midi_sinks) / (sinks - 1.f))) + .5f;
1184 const float si_x0 = rintf(width * (.2f + .6f * (i + midi_sources) / (sources - 1.f))) + .5f;
1185 cairo_move_to (cr, si_x, height);
1186 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
1189 } else if (audio_sources == 1 && audio_sinks > 0) {
1192 si_x = rintf(width * .5f) + .5f;
1194 si_x = rintf(width * (.2f + .6f * midi_sinks / (sinks - 1.f))) + .5f;
1197 si_x0 = rintf(width * .5f) + .5f;
1199 si_x0 = rintf(width * (.2f + .6f * midi_sources / (sources - 1.f))) + .5f;
1201 cairo_move_to (cr, si_x, height);
1202 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
1205 } else if (audio_sources != 0 && audio_sinks != 0) {
1206 PBD::warning << string_compose("Programming error: audio routing display: A %1 -> %2 | M %3 -> %4 | T %5 -> %6",
1207 audio_sources, audio_sinks, midi_sources, midi_sinks, sources, sinks) << endmsg;
1215 ProcessorEntry::PluginDisplay::PluginDisplay (boost::shared_ptr<ARDOUR::Plugin> p, uint32_t max_height)
1218 , _max_height (max_height)
1222 set_name ("processor prefader");
1223 _plug->QueueDraw.connect (_qdraw_connection, invalidator (*this),
1224 boost::bind (&Gtk::Widget::queue_draw, this), gui_context ());
1227 ProcessorEntry::PluginDisplay::~PluginDisplay ()
1230 cairo_surface_destroy (_surf);
1235 ProcessorEntry::PluginDisplay::on_size_request (Gtk::Requisition* req)
1238 req->height = _cur_height;
1243 ProcessorEntry::PluginDisplay::update_height_alloc (uint32_t inline_height)
1245 /* work-around scroll-bar + aspect ratio
1246 * show inline-view -> height changes -> scrollbar gets added
1247 * -> width changes -> inline-view, fixed aspect ratio -> height changes
1248 * -> scroll bar is removed [-> width changes ; repeat ]
1250 uint32_t shm = std::min (_max_height, inline_height);
1252 Gtk::Container* pr = get_parent();
1253 for (uint32_t i = 0; i < 4 && pr; ++i) {
1254 // VBox, EventBox, ViewPort, ScrolledWindow
1255 pr = pr->get_parent();
1257 Gtk::ScrolledWindow* sw = dynamic_cast<Gtk::ScrolledWindow*> (pr);
1259 const Gtk::VScrollbar* vsb = sw->get_vscrollbar();
1260 sc = vsb && vsb->is_visible();
1263 if (shm != _cur_height) {
1264 if (_scroll == sc || _cur_height < shm) {
1273 ProcessorEntry::PluginDisplay::render_inline (cairo_t* cr, uint32_t width)
1275 Plugin::Display_Image_Surface* dis = _plug->render_inline_display (width, _max_height);
1280 /* allocate a local image-surface,
1281 * We cannot re-use the data via cairo_image_surface_create_for_data(),
1282 * since pixman keeps a reference to it.
1283 * we'd need to hand over the data and ha cairo_surface_destroy to free it.
1284 * it might be possible to work around via cairo_surface_set_user_data().
1287 || dis->width != cairo_image_surface_get_width (_surf)
1288 || dis->height != cairo_image_surface_get_height (_surf)
1291 cairo_surface_destroy (_surf);
1293 _surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, dis->width, dis->height);
1296 if (cairo_image_surface_get_stride (_surf) == dis->stride) {
1297 memcpy (cairo_image_surface_get_data (_surf), dis->data, dis->stride * dis->height);
1299 unsigned char *src = dis->data;
1300 unsigned char *dst = cairo_image_surface_get_data (_surf);
1301 const int dst_stride = cairo_image_surface_get_stride (_surf);
1302 for (int y = 0; y < dis->height; ++y) {
1303 memcpy (dst, src, dis->width * 4 /*ARGB32*/);
1309 cairo_surface_mark_dirty(_surf);
1310 const double xc = floor ((width - dis->width) * .5);
1311 cairo_set_source_surface(cr, _surf, xc, 0);
1318 ProcessorEntry::PluginDisplay::on_expose_event (GdkEventExpose* ev)
1320 Gtk::Allocation a = get_allocation();
1321 double const width = a.get_width();
1322 double const height = a.get_height();
1324 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
1325 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
1328 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
1329 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
1330 cairo_rectangle (cr, 0, 0, width, height);
1334 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
1335 Gtkmm2ext::rounded_rectangle (cr, .5, -1.5, width - 1, height + 1, 7);
1337 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1339 uint32_t ht = render_inline (cr, width);
1344 if (_cur_height != 1) {
1351 update_height_alloc (ht);
1354 bool failed = false;
1355 std::string name = get_name();
1356 ArdourCanvas::Color fill_color = UIConfiguration::instance().color (string_compose ("%1: fill active", name), &failed);
1358 Gtkmm2ext::rounded_rectangle (cr, .5, -1.5, width - 1, height + 1, 7);
1359 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1360 cairo_set_line_width(cr, 1.0);
1361 ArdourCanvas::set_source_rgb_a (cr, fill_color, 1.0);
1368 ProcessorEntry::LuaPluginDisplay::LuaPluginDisplay (boost::shared_ptr<ARDOUR::LuaProc> p, uint32_t max_height)
1369 : PluginDisplay (p, max_height)
1371 , _lua_render_inline (0)
1373 p->setup_lua_inline_gui (&lua_gui);
1375 lua_State* LG = lua_gui.getState ();
1376 LuaInstance::bind_cairo (LG);
1377 luabridge::LuaRef lua_render = luabridge::getGlobal (LG, "render_inline");
1378 assert (lua_render.isFunction ());
1379 _lua_render_inline = new luabridge::LuaRef (lua_render);
1382 ProcessorEntry::LuaPluginDisplay::~LuaPluginDisplay ()
1384 delete (_lua_render_inline);
1388 ProcessorEntry::LuaPluginDisplay::render_inline (cairo_t *cr, uint32_t width)
1390 Cairo::Context ctx (cr);
1392 luabridge::LuaRef rv = (*_lua_render_inline)((Cairo::Context *)&ctx, width, _max_height);
1393 if (rv.isTable ()) {
1397 } catch (luabridge::LuaException const& e) {
1404 static std::list<Gtk::TargetEntry> drop_targets()
1406 std::list<Gtk::TargetEntry> tmp;
1407 tmp.push_back (Gtk::TargetEntry ("processor")); // from processor-box to processor-box
1408 tmp.push_back (Gtk::TargetEntry ("PluginInfoPtr")); // from plugin-manager
1409 tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr")); // from sidebar
1413 static std::list<Gtk::TargetEntry> drag_targets()
1415 std::list<Gtk::TargetEntry> tmp;
1416 tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr")); // to sidebar (optional preset)
1417 tmp.push_back (Gtk::TargetEntry ("processor")); // to processor-box (copy)
1421 static std::list<Gtk::TargetEntry> drag_targets_noplugin()
1423 std::list<Gtk::TargetEntry> tmp;
1424 tmp.push_back (Gtk::TargetEntry ("processor")); // to processor box (sends, faders re-order)
1428 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
1429 RouteProcessorSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
1430 : _parent_strip (parent)
1431 , _owner_is_mixer (owner_is_mixer)
1432 , ab_direction (true)
1433 , _get_plugin_selector (get_plugin_selector)
1435 , _visible_prefader_processors (0)
1436 , _rr_selection(rsel)
1437 , processor_display (drop_targets())
1438 , _redisplay_pending (false)
1442 /* ProcessorBox actions and bindings created statically by call to
1443 * ProcessorBox::register_actions(), made by ARDOUR_UI so that actions
1444 * are available for context menus.
1447 processor_display.set_data ("ardour-bindings", bindings);
1451 no_processor_redisplay = false;
1453 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
1454 processor_scroller.add (processor_display);
1455 pack_start (processor_scroller, true, true);
1457 processor_display.set_flags (CAN_FOCUS);
1458 processor_display.set_name ("ProcessorList");
1459 processor_display.set_data ("processorbox", this);
1460 processor_display.set_size_request (48, -1);
1461 processor_display.set_spacing (0);
1463 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
1464 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
1466 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
1467 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
1469 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
1470 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
1471 processor_display.DropFromExternal.connect (sigc::mem_fun (*this, &ProcessorBox::plugin_drop));
1473 processor_scroller.show ();
1474 processor_display.show ();
1477 parent->DeliveryChanged.connect (
1478 _mixer_strip_connections, invalidator (*this), boost::bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
1482 ARDOUR_UI_UTILS::set_tooltip (processor_display, _("Right-click to add/remove/edit\nplugins,inserts,sends and more"));
1485 ProcessorBox::~ProcessorBox ()
1487 /* it may appear as if we should delete processor_menu but that is a
1488 * pointer to a widget owned by the UI Manager, and has potentially
1489 * be returned to many other ProcessorBoxes. GTK doesn't really make
1490 * clear the ownership of this widget, which is a menu and thus is
1491 * never packed into any container other than an implict GtkWindow.
1493 * For now, until or if we ever get clarification over the ownership
1494 * story just let it continue to exist. At worst, its a small memory leak.
1499 ProcessorBox::set_route (boost::shared_ptr<Route> r)
1505 _route_connections.drop_connections();
1507 /* new route: any existing block on processor redisplay must be meaningless */
1508 no_processor_redisplay = false;
1511 _route->processors_changed.connect (
1512 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
1515 _route->DropReferences.connect (
1516 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
1519 _route->PropertyChanged.connect (
1520 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
1523 redisplay_processors ();
1527 ProcessorBox::route_going_away ()
1529 /* don't keep updating display as processors are deleted */
1530 no_processor_redisplay = true;
1534 boost::shared_ptr<Processor>
1535 ProcessorBox::find_drop_position (ProcessorEntry* position)
1537 boost::shared_ptr<Processor> p;
1539 p = position->processor ();
1541 /* dropped on the blank entry (which will be before the
1542 fader), so use the first non-blank child as our
1543 `dropped on' processor */
1544 list<ProcessorEntry*> c = processor_display.children ();
1545 list<ProcessorEntry*>::iterator i = c.begin ();
1547 assert (i != c.end ());
1548 p = (*i)->processor ();
1556 ProcessorBox::_drop_plugin_preset (Gtk::SelectionData const &data, Route::ProcessorList &pl)
1558 const void * d = data.get_data();
1559 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
1561 PluginPresetList nfos;
1563 tv->get_object_drag_data (nfos, &source);
1565 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1566 PluginPresetPtr ppp = (*i);
1567 PluginInfoPtr pip = ppp->_pip;
1568 PluginPtr p = pip->load (*_session);
1573 if (ppp->_preset.valid) {
1574 p->load_preset (ppp->_preset);
1577 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
1578 if (Config->get_new_plugins_active ()) {
1579 processor->activate ();
1581 pl.push_back (processor);
1586 ProcessorBox::_drop_plugin (Gtk::SelectionData const &data, Route::ProcessorList &pl)
1588 const void * d = data.get_data();
1589 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>*>(d);
1590 PluginInfoList nfos;
1593 tv->get_object_drag_data (nfos, &source);
1595 for (list<PluginInfoPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1596 PluginPtr p = (*i)->load (*_session);
1600 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
1601 if (Config->get_new_plugins_active ()) {
1602 processor->activate ();
1604 pl.push_back (processor);
1609 ProcessorBox::plugin_drop (Gtk::SelectionData const &data, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
1615 boost::shared_ptr<Processor> p = find_drop_position (position);
1616 Route::ProcessorList pl;
1618 if (data.get_target() == "PluginInfoPtr") {
1619 _drop_plugin (data, pl);
1621 else if (data.get_target() == "PluginPresetPtr") {
1622 _drop_plugin_preset (data, pl);
1628 Route::ProcessorStreams err;
1629 if (_route->add_processors (pl, p, &err)) {
1631 "Processor Drag/Drop failed. Probably because\n\
1632 the I/O configuration of the plugins could\n\
1633 not match the configuration of this track.");
1634 MessageDialog am (msg);
1640 ProcessorBox::object_drop (DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
1642 if (Gdk::ACTION_LINK == context->get_selected_action()) {
1643 list<ProcessorEntry*> children = source->selection ();
1644 assert (children.size() == 1);
1645 ProcessorEntry* other = *children.begin();
1646 assert (other->can_copy_state (position));
1647 boost::shared_ptr<ARDOUR::Processor> otherproc = other->processor();
1648 boost::shared_ptr<ARDOUR::Processor> proc = position->processor();
1649 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (proc);
1650 assert (otherproc && proc && pi);
1652 PBD::ID id = pi->id();
1653 XMLNode& state = otherproc->get_state ();
1654 proc->set_state (state, Stateful::loading_state_version);
1655 boost::dynamic_pointer_cast<PluginInsert>(proc)->update_id (id);
1659 boost::shared_ptr<Processor> p = find_drop_position (position);
1661 list<ProcessorEntry*> children = source->selection ();
1662 list<boost::shared_ptr<Processor> > procs;
1663 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
1664 if ((*i)->processor ()) {
1665 if (boost::dynamic_pointer_cast<UnknownProcessor> ((*i)->processor())) {
1668 procs.push_back ((*i)->processor ());
1672 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
1673 XMLNode& state = (*i)->get_state ();
1675 nlist.push_back (&state);
1676 paste_processor_state (nlist, p);
1680 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
1684 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
1685 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
1687 other->delete_dragged_processors (procs);
1693 ProcessorBox::set_width (Width w)
1701 list<ProcessorEntry*> children = processor_display.children ();
1702 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1703 (*i)->set_enum_width (w);
1710 ProcessorBox::build_possible_aux_menu ()
1712 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
1715 /* No aux sends if there are no busses */
1719 if (_route->is_monitor ()) {
1723 using namespace Menu_Helpers;
1724 Menu* menu = manage (new Menu);
1725 MenuList& items = menu->items();
1727 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
1728 if (!_route->internal_send_for (*r) && *r != _route) {
1729 items.push_back (MenuElem ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
1737 ProcessorBox::show_processor_menu (int arg)
1739 if (processor_menu == 0) {
1740 processor_menu = build_processor_menu ();
1741 processor_menu->signal_unmap().connect (sigc::mem_fun (*this, &ProcessorBox::processor_menu_unmapped));
1744 /* Sort out the plugin submenu */
1746 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newplugin"));
1748 if (plugin_menu_item) {
1749 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
1752 /* And the aux submenu */
1754 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newaux"));
1756 if (aux_menu_item) {
1757 Menu* m = build_possible_aux_menu();
1758 if (m && !m->items().empty()) {
1759 aux_menu_item->set_submenu (*m);
1760 aux_menu_item->set_sensitive (true);
1762 /* stupid gtkmm: we need to pass a null reference here */
1763 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
1764 aux_menu_item->set_sensitive (false);
1768 ActionManager::get_action (X_("ProcessorMenu"), "newinsert")->set_sensitive (!_route->is_monitor ());
1769 ActionManager::get_action (X_("ProcessorMenu"), "newsend")->set_sensitive (!_route->is_monitor ());
1771 ProcessorEntry* single_selection = 0;
1772 if (processor_display.selection().size() == 1) {
1773 single_selection = processor_display.selection().front();
1776 /* And the controls submenu */
1778 Gtk::MenuItem* controls_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/controls"));
1780 if (controls_menu_item) {
1781 if (single_selection) {
1782 Menu* m = single_selection->build_controls_menu ();
1783 if (m && !m->items().empty()) {
1784 controls_menu_item->set_submenu (*m);
1785 controls_menu_item->set_sensitive (true);
1787 gtk_menu_item_set_submenu (controls_menu_item->gobj(), 0);
1788 controls_menu_item->set_sensitive (false);
1791 controls_menu_item->set_sensitive (false);
1795 Gtk::MenuItem* send_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/send_options"));
1796 if (send_menu_item) {
1797 if (single_selection && !_route->is_monitor()) {
1798 Menu* m = single_selection->build_send_options_menu ();
1799 if (m && !m->items().empty()) {
1800 send_menu_item->set_submenu (*m);
1801 send_menu_item->set_sensitive (true);
1803 gtk_menu_item_set_submenu (send_menu_item->gobj(), 0);
1804 send_menu_item->set_sensitive (false);
1807 send_menu_item->set_sensitive (false);
1811 /* Sensitise actions as approprioate */
1814 const bool sensitive = !processor_display.selection().empty() && ! stub_processor_selected ();
1816 paste_action->set_sensitive (!_rr_selection.processors.empty());
1817 cut_action->set_sensitive (sensitive && can_cut ());
1818 copy_action->set_sensitive (sensitive);
1819 delete_action->set_sensitive (sensitive || stub_processor_selected ());
1821 edit_action->set_sensitive (one_processor_can_be_edited ());
1822 edit_generic_action->set_sensitive (one_processor_can_be_edited ());
1824 boost::shared_ptr<PluginInsert> pi;
1825 if (single_selection) {
1826 pi = boost::dynamic_pointer_cast<PluginInsert> (single_selection->processor ());
1829 manage_pins_action->set_sensitive (pi != 0);
1831 /* allow editing with an Ardour-generated UI for plugin inserts with editors */
1832 edit_action->set_sensitive (pi && pi->plugin()->has_editor ());
1834 /* disallow rename for multiple selections, for plugin inserts and for the fader */
1835 rename_action->set_sensitive (single_selection
1837 && !boost::dynamic_pointer_cast<Amp> (single_selection->processor ())
1838 && !boost::dynamic_pointer_cast<UnknownProcessor> (single_selection->processor ()));
1840 processor_menu->popup (1, arg);
1842 /* Add a placeholder gap to the processor list to indicate where a processor would be
1843 inserted were one chosen from the menu.
1846 processor_display.get_pointer (x, y);
1847 _placement = processor_display.add_placeholder (y);
1849 if (_visible_prefader_processors == 0 && _placement > 0) {
1855 ProcessorBox::enter_notify (GdkEventCrossing*)
1857 processor_display.grab_focus ();
1858 _current_processor_box = this;
1863 ProcessorBox::leave_notify (GdkEventCrossing* ev)
1865 if (ev->detail == GDK_NOTIFY_INFERIOR) {
1869 Widget* top = get_toplevel();
1871 if (top->is_toplevel()) {
1872 Window* win = dynamic_cast<Window*> (top);
1873 gtk_window_set_focus (win->gobj(), 0);
1880 ProcessorBox::processor_operation (ProcessorOperation op)
1882 ProcSelection targets;
1884 get_selected_processors (targets);
1886 /* if (targets.empty()) {
1889 processor_display.get_pointer (x, y);
1891 pair<ProcessorEntry *, double> const pointer = processor_display.get_child_at_position (y);
1893 if (pointer.first && pointer.first->processor()) {
1894 targets.push_back (pointer.first->processor ());
1899 if ((op == ProcessorsDelete) && targets.empty()) {
1900 return false; //nothing to delete. return false so the editor-mixer, because the user was probably intending to delete something in the editor
1904 case ProcessorsSelectAll:
1905 processor_display.select_all ();
1908 case ProcessorsSelectNone:
1909 processor_display.select_none ();
1912 case ProcessorsCopy:
1913 copy_processors (targets);
1917 cut_processors (targets);
1920 case ProcessorsPaste:
1921 // some processors are not selectable (e.g fader, meter), target is empty.
1922 if (targets.empty() && _placement >= 0) {
1924 boost::shared_ptr<Processor> proc = _route->before_processor_for_index (_placement);
1926 targets.push_back (proc);
1929 if (targets.empty()) {
1930 paste_processors ();
1932 paste_processors (targets.front());
1936 case ProcessorsDelete:
1937 delete_processors (targets);
1940 case ProcessorsToggleActive:
1941 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
1942 if ((*i)->active()) {
1943 (*i)->deactivate ();
1961 ProcessorWindowProxy*
1962 ProcessorBox::find_window_proxy (boost::shared_ptr<Processor> processor) const
1964 return processor->window_proxy();
1969 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
1971 boost::shared_ptr<Processor> processor;
1973 processor = child->processor ();
1977 bool selected = processor_display.selected (child);
1979 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
1981 if (_session->engine().connected()) {
1982 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
1984 if (!one_processor_can_be_edited ()) {
1988 if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
1989 generic_edit_processor (processor);
1991 edit_processor (processor);
1997 } else if (Keyboard::is_context_menu_event (ev)) {
1999 show_processor_menu (ev->time);
2003 } else if (processor && ev->button == 1 && selected) {
2005 // this is purely informational but necessary for route params UI
2006 ProcessorSelected (processor); // emit
2008 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
2011 _get_plugin_selector()->show_manager ();
2018 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
2020 boost::shared_ptr<Processor> processor;
2022 processor = child->processor ();
2025 if (processor && Keyboard::is_delete_event (ev)) {
2027 Glib::signal_idle().connect (sigc::bind (
2028 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
2029 boost::weak_ptr<Processor>(processor)));
2031 } else if (processor && Keyboard::is_button2_event (ev)
2033 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
2037 /* button2-click with no/appropriate modifiers */
2039 if (processor->active()) {
2040 processor->deactivate ();
2042 processor->activate ();
2050 ProcessorBox::build_processor_menu ()
2052 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/ProcessorMenu") );
2053 processor_menu->set_name ("ArdourContextMenu");
2054 return processor_menu;
2058 ProcessorBox::select_all_processors ()
2060 processor_display.select_all ();
2064 ProcessorBox::deselect_all_processors ()
2066 processor_display.select_none ();
2070 ProcessorBox::choose_plugin ()
2072 _get_plugin_selector()->set_interested_object (*this);
2075 /** @return true if an error occurred, otherwise false */
2077 ProcessorBox::choose_lua ()
2079 LuaScriptInfoPtr spi;
2081 ScriptSelector ss (_("Add Lua DSP Processor"), LuaScriptInfo::DSP);
2082 switch (ss.run ()) {
2083 case Gtk::RESPONSE_ACCEPT:
2093 LuaPluginInfoPtr lpi (new LuaPluginInfo(spi));
2094 p = (lpi->load (*_session));
2097 "Failed to instantiate Lua DSP Processor,\n"
2098 "probably because the script is invalid (no dsp function).");
2099 MessageDialog am (msg);
2104 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
2106 Route::ProcessorStreams err_streams;
2107 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
2109 "Failed to add Lua DSP Processor at the given position,\n"
2110 "probably because the I/O configuration of the plugins\n"
2111 "could not match the configuration of this track.");
2112 MessageDialog am (msg);
2118 /** @return true if an error occurred, otherwise false */
2120 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
2122 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
2124 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
2126 Route::ProcessorStreams err_streams;
2128 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
2129 weird_plugin_dialog (**p, err_streams);
2131 // XXX SHAREDPTR delete plugin here .. do we even need to care?
2132 } else if (plugins.size() == 1 && UIConfiguration::instance().get_open_gui_after_adding_plugin()) {
2133 if (boost::dynamic_pointer_cast<PluginInsert>(processor)->plugin()->has_inline_display() && UIConfiguration::instance().get_prefer_inline_over_gui()) {
2135 } else if (_session->engine().connected () && processor_can_be_edited (processor)) {
2136 if ((*p)->has_editor ()) {
2137 edit_processor (processor);
2139 generic_edit_processor (processor);
2149 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
2151 ArdourDialog dialog (_("Plugin Incompatibility"));
2154 string text = string_compose(_("You attempted to add the plugin \"%1\" in slot %2.\n"),
2155 p.name(), streams.index);
2157 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
2158 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
2160 text += _("\nThis plugin has:\n");
2162 uint32_t const n = p.get_info()->n_inputs.n_midi ();
2163 text += string_compose (ngettext ("\t%1 MIDI input\n", "\t%1 MIDI inputs\n", n), n);
2166 uint32_t const n = p.get_info()->n_inputs.n_audio ();
2167 text += string_compose (ngettext ("\t%1 audio input\n", "\t%1 audio inputs\n", n), n);
2170 text += _("\nbut at the insertion point, there are:\n");
2172 uint32_t const n = streams.count.n_midi ();
2173 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
2176 uint32_t const n = streams.count.n_audio ();
2177 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
2180 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
2181 label.set_text(text);
2183 dialog.get_vbox()->pack_start (label);
2184 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
2186 dialog.set_name (X_("PluginIODialog"));
2187 dialog.set_modal (true);
2194 ProcessorBox::choose_insert ()
2196 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->pannable(), _route->mute_master()));
2197 _route->add_processor_by_index (processor, _placement);
2200 /* Caller must not hold process lock */
2202 ProcessorBox::choose_send ()
2204 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
2205 boost::shared_ptr<Send> send (new Send (*_session, sendpan, _route->mute_master()));
2207 /* make an educated guess at the initial number of outputs for the send */
2208 ChanCount outs = (_session->master_out())
2209 ? _session->master_out()->n_outputs()
2210 : _route->n_outputs();
2212 /* XXX need processor lock on route */
2214 Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock());
2215 send->output()->ensure_io (outs, false, this);
2216 } catch (AudioEngine::PortRegistrationFailure& err) {
2217 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
2221 /* let the user adjust the IO setup before creation.
2223 Note: this dialog is NOT modal - we just leave it to run and it will
2224 return when its Finished signal is emitted - typically when the window
2228 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
2231 /* keep a reference to the send so it doesn't get deleted while
2232 the IOSelectorWindow is doing its stuff
2234 _processor_being_created = send;
2236 ios->selector().Finished.connect (sigc::bind (
2237 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
2238 boost::weak_ptr<Processor>(send), ios));
2243 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
2245 boost::shared_ptr<Processor> processor (weak_processor.lock());
2247 /* drop our temporary reference to the new send */
2248 _processor_being_created.reset ();
2255 case IOSelector::Cancelled:
2256 // processor will go away when all shared_ptrs to it vanish
2259 case IOSelector::Accepted:
2260 _route->add_processor_by_index (processor, _placement);
2264 delete_when_idle (ios);
2268 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
2270 boost::shared_ptr<Processor> processor (weak_processor.lock());
2272 /* drop our temporary reference to the new return */
2273 _processor_being_created.reset ();
2280 case IOSelector::Cancelled:
2281 // processor will go away when all shared_ptrs to it vanish
2284 case IOSelector::Accepted:
2285 _route->add_processor_by_index (processor, _placement);
2289 delete_when_idle (ios);
2293 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
2299 boost::shared_ptr<Route> target = wr.lock();
2305 _session->add_internal_send (target, _placement, _route);
2309 ProcessorBox::route_processors_changed (RouteProcessorChange c)
2311 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
2312 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
2316 redisplay_processors ();
2320 ProcessorBox::redisplay_processors ()
2322 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors);
2325 if (no_processor_redisplay) {
2329 processor_display.clear ();
2331 _visible_prefader_processors = 0;
2334 _route->foreach_processor (sigc::bind (sigc::mem_fun (*this, &ProcessorBox::help_count_visible_prefader_processors),
2335 &_visible_prefader_processors, &fader_seen));
2337 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
2338 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
2339 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_pin_mgr));
2340 setup_entry_positions ();
2343 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
2344 * not already have one.
2347 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
2349 boost::shared_ptr<Processor> p = w.lock ();
2353 if (p->window_proxy()) {
2357 /* not on the list; add it */
2360 #if 0 // is this still needed? Why?
2361 if (_parent_strip) {
2362 if (_parent_strip->mixer_owned()) {
2374 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
2375 string_compose ("%1-%2-%3", loc, _route->id(), p->id()),
2379 const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
2382 wp->set_state (*ui_xml, 0);
2385 void* existing_ui = p->get_ui ();
2388 wp->use_window (*(reinterpret_cast<Gtk::Window*>(existing_ui)));
2391 p->set_window_proxy (wp);
2392 WM::Manager::instance().register_window (wp);
2396 ProcessorBox::maybe_add_processor_pin_mgr (boost::weak_ptr<Processor> w)
2398 boost::shared_ptr<Processor> p = w.lock ();
2399 if (!p || p->pinmgr_proxy ()) {
2403 PluginPinWindowProxy* wp = new PluginPinWindowProxy (
2404 string_compose ("PM-%2-%3", _route->id(), p->id()), w);
2406 const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
2408 wp->set_state (*ui_xml, 0);
2411 void* existing_ui = p->get_ui ();
2414 wp->use_window (*(reinterpret_cast<Gtk::Window*>(existing_ui)));
2417 p->set_pingmgr_proxy (wp);
2418 WM::Manager::instance().register_window (wp);
2421 ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor> p, uint32_t* cnt, bool* amp_seen)
2423 boost::shared_ptr<Processor> processor (p.lock ());
2425 if (processor && ( processor->display_to_user()
2427 || show_all_processors
2432 if (boost::dynamic_pointer_cast<Amp>(processor) &&
2433 boost::dynamic_pointer_cast<Amp>(processor)->gain_control()->parameter().type() == GainAutomation) {
2444 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
2446 boost::shared_ptr<Processor> processor (p.lock ());
2448 if (!processor || ( !processor->display_to_user()
2450 && !show_all_processors
2457 boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
2459 ProcessorEntry* e = 0;
2460 if (plugin_insert) {
2461 e = new PluginInsertProcessorEntry (this, plugin_insert, _width);
2463 e = new ProcessorEntry (this, processor, _width);
2466 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
2467 boost::shared_ptr<PortInsert> ext = boost::dynamic_pointer_cast<PortInsert> (processor);
2468 boost::shared_ptr<UnknownProcessor> stub = boost::dynamic_pointer_cast<UnknownProcessor> (processor);
2470 //faders and meters are not deletable, copy/paste-able, so they shouldn't be selectable
2471 if (!send && !plugin_insert && !ext && !stub)
2472 e->set_selectable(false);
2474 bool mark_send_visible = false;
2475 if (send && _parent_strip) {
2476 /* show controls of new sends by default */
2477 GUIObjectState& st = _parent_strip->gui_object_state ();
2478 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
2480 /* check if state exists, if not it must be a new send */
2481 if (!st.get_node(strip, e->state_id())) {
2482 mark_send_visible = true;
2486 /* Set up this entry's state from the GUIObjectState */
2487 XMLNode* proc = entry_gui_object_state (e);
2489 e->set_control_state (proc);
2492 if (mark_send_visible) {
2493 e->show_all_controls ();
2498 && !plugin_insert->plugin(0)->is_channelstrip()
2502 processor_display.add_child (e, drag_targets());
2504 processor_display.add_child (e, drag_targets_noplugin());
2509 ProcessorBox::reordered ()
2511 compute_processor_sort_keys ();
2512 setup_entry_positions ();
2516 ProcessorBox::setup_entry_positions ()
2518 list<ProcessorEntry*> children = processor_display.children ();
2519 bool pre_fader = true;
2522 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2523 if (boost::dynamic_pointer_cast<Amp>((*i)->processor()) &&
2524 boost::dynamic_pointer_cast<Amp>((*i)->processor())->gain_control()->parameter().type() == GainAutomation) {
2526 (*i)->set_position (ProcessorEntry::Fader, num++);
2529 (*i)->set_position (ProcessorEntry::PreFader, num++);
2531 (*i)->set_position (ProcessorEntry::PostFader, num++);
2538 ProcessorBox::compute_processor_sort_keys ()
2540 list<ProcessorEntry*> children = processor_display.children ();
2541 Route::ProcessorList our_processors;
2543 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2544 if ((*i)->processor()) {
2545 our_processors.push_back ((*i)->processor ());
2549 if (_route->reorder_processors (our_processors)) {
2550 /* Reorder failed, so report this to the user. As far as I can see this must be done
2551 in an idle handler: it seems that the redisplay_processors() that happens below destroys
2552 widgets that were involved in the drag-and-drop on the processor list, which causes problems
2553 when the drag is torn down after this handler function is finished.
2555 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
2560 ProcessorBox::report_failed_reorder ()
2562 /* reorder failed, so redisplay */
2564 redisplay_processors ();
2566 /* now tell them about the problem */
2568 ArdourDialog dialog (_("Plugin Incompatibility"));
2571 label.set_text (_("\
2572 You cannot reorder these plugins/sends/inserts\n\
2573 in that way because the inputs and\n\
2574 outputs will not work correctly."));
2576 dialog.get_vbox()->set_border_width (12);
2577 dialog.get_vbox()->pack_start (label);
2578 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
2580 dialog.set_name (X_("PluginIODialog"));
2581 dialog.set_modal (true);
2588 ProcessorBox::rename_processors ()
2590 ProcSelection to_be_renamed;
2592 get_selected_processors (to_be_renamed);
2594 if (to_be_renamed.empty()) {
2598 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
2599 rename_processor (*i);
2604 ProcessorBox::can_cut () const
2606 vector<boost::shared_ptr<Processor> > sel;
2608 get_selected_processors (sel);
2610 /* cut_processors () does not cut inserts */
2612 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
2614 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
2615 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
2616 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
2625 ProcessorBox::stub_processor_selected () const
2627 vector<boost::shared_ptr<Processor> > sel;
2629 get_selected_processors (sel);
2631 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
2632 if (boost::dynamic_pointer_cast<UnknownProcessor>((*i)) != 0) {
2641 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
2643 if (to_be_removed.empty()) {
2647 XMLNode* node = new XMLNode (X_("cut"));
2648 Route::ProcessorList to_cut;
2650 no_processor_redisplay = true;
2651 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
2652 // Cut only plugins, sends and returns
2653 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
2654 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
2655 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
2657 Window* w = get_processor_ui (*i);
2663 XMLNode& child ((*i)->get_state());
2664 node->add_child_nocopy (child);
2665 to_cut.push_back (*i);
2669 if (_route->remove_processors (to_cut) != 0) {
2671 no_processor_redisplay = false;
2675 _rr_selection.set (node);
2677 no_processor_redisplay = false;
2678 redisplay_processors ();
2682 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
2684 if (to_be_copied.empty()) {
2688 XMLNode* node = new XMLNode (X_("copy"));
2690 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
2691 // Copy only plugins, sends, returns
2692 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
2693 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
2694 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
2695 node->add_child_nocopy ((*i)->get_state());
2699 _rr_selection.set (node);
2703 ProcessorBox::delete_processors (const ProcSelection& targets)
2705 if (targets.empty()) {
2709 no_processor_redisplay = true;
2711 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
2713 Window* w = get_processor_ui (*i);
2719 _route->remove_processor(*i);
2722 no_processor_redisplay = false;
2723 redisplay_processors ();
2727 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
2729 list<boost::shared_ptr<Processor> >::const_iterator x;
2731 no_processor_redisplay = true;
2732 for (x = procs.begin(); x != procs.end(); ++x) {
2734 Window* w = get_processor_ui (*x);
2740 _route->remove_processor(*x);
2743 no_processor_redisplay = false;
2744 redisplay_processors ();
2748 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
2750 boost::shared_ptr<Processor> processor (weak_processor.lock());
2756 /* NOT copied to _mixer.selection() */
2758 no_processor_redisplay = true;
2759 _route->remove_processor (processor);
2760 no_processor_redisplay = false;
2761 redisplay_processors ();
2767 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
2769 ArdourPrompter name_prompter (true);
2771 name_prompter.set_title (_("Rename Processor"));
2772 name_prompter.set_prompt (_("New name:"));
2773 name_prompter.set_initial_text (processor->name());
2774 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
2775 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
2776 name_prompter.show_all ();
2778 switch (name_prompter.run ()) {
2780 case Gtk::RESPONSE_ACCEPT:
2781 name_prompter.get_result (result);
2782 if (result.length()) {
2785 string test = result;
2787 while (tries < 100) {
2788 if (_session->io_name_is_legal (test)) {
2794 test = string_compose ("%1-%2", result, tries);
2798 processor->set_name (result);
2801 ARDOUR_UI::instance()->popup_error
2802 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
2812 ProcessorBox::paste_processors ()
2814 if (_rr_selection.processors.empty()) {
2818 paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
2822 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
2825 if (_rr_selection.processors.empty()) {
2829 paste_processor_state (_rr_selection.processors.get_node().children(), before);
2833 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
2835 XMLNodeConstIterator niter;
2836 list<boost::shared_ptr<Processor> > copies;
2838 if (nlist.empty()) {
2842 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2844 XMLProperty const * type = (*niter)->property ("type");
2845 XMLProperty const * role = (*niter)->property ("role");
2848 boost::shared_ptr<Processor> p;
2850 if (type->value() == "meter" ||
2851 type->value() == "main-outs" ||
2852 type->value() == "amp" ||
2853 type->value() == "intreturn") {
2854 /* do not paste meter, main outs, amp or internal returns */
2857 } else if (type->value() == "intsend") {
2859 /* aux sends are OK, but those used for
2860 * other purposes, are not.
2865 if (role->value() != "Aux") {
2869 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
2870 XMLNode n (**niter);
2871 InternalSend* s = new InternalSend (*_session, sendpan, _route->mute_master(),
2872 _route, boost::shared_ptr<Route>(), Delivery::Aux);
2874 IOProcessor::prepare_for_reset (n, s->name());
2876 if (s->set_state (n, Stateful::loading_state_version)) {
2883 } else if (type->value() == "send") {
2885 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
2886 XMLNode n (**niter);
2888 Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
2890 IOProcessor::prepare_for_reset (n, s->name());
2892 if (s->set_state (n, Stateful::loading_state_version)) {
2899 } else if (type->value() == "return") {
2901 XMLNode n (**niter);
2902 Return* r = new Return (*_session);
2904 IOProcessor::prepare_for_reset (n, r->name());
2906 if (r->set_state (n, Stateful::loading_state_version)) {
2913 } else if (type->value() == "port") {
2915 XMLNode n (**niter);
2916 PortInsert* pi = new PortInsert (*_session, _route->pannable (), _route->mute_master ());
2918 IOProcessor::prepare_for_reset (n, pi->name());
2920 if (pi->set_state (n, Stateful::loading_state_version)) {
2926 /* XXX its a bit limiting to assume that everything else
2929 p.reset (new PluginInsert (*_session));
2930 PBD::ID id = p->id();
2931 p->set_state (**niter, Stateful::current_state_version);
2932 boost::dynamic_pointer_cast<PluginInsert>(p)->update_id (id);
2935 copies.push_back (p);
2939 error << _("plugin insert constructor failed") << endmsg;
2943 if (copies.empty()) {
2947 if (_route->add_processors (copies, p)) {
2950 "Copying the set of processors on the clipboard failed,\n\
2951 probably because the I/O configuration of the plugins\n\
2952 could not match the configuration of this track.");
2953 MessageDialog am (msg);
2959 ProcessorBox::get_selected_processors (ProcSelection& processors) const
2961 const list<ProcessorEntry*> selection = processor_display.selection ();
2962 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
2963 processors.push_back ((*i)->processor ());
2968 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
2970 list<ProcessorEntry*> selection = processor_display.selection ();
2971 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
2972 (this->*method) ((*i)->processor ());
2977 ProcessorBox::all_visible_processors_active (bool state)
2979 _route->all_visible_processors_active (state);
2983 ProcessorBox::ab_plugins ()
2985 _route->ab_plugins (ab_direction);
2986 ab_direction = !ab_direction;
2991 ProcessorBox::clear_processors ()
2994 vector<string> choices;
2996 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
2997 "(this cannot be undone)"), _route->name());
2999 choices.push_back (_("Cancel"));
3000 choices.push_back (_("Yes, remove them all"));
3002 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
3004 if (prompter.run () == 1) {
3005 _route->clear_processors (PreFader);
3006 _route->clear_processors (PostFader);
3011 ProcessorBox::clear_processors (Placement p)
3014 vector<string> choices;
3016 if (p == PreFader) {
3017 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
3018 "(this cannot be undone)"), _route->name());
3020 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
3021 "(this cannot be undone)"), _route->name());
3024 choices.push_back (_("Cancel"));
3025 choices.push_back (_("Yes, remove them all"));
3027 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
3029 if (prompter.run () == 1) {
3030 _route->clear_processors (p);
3035 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
3037 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
3038 if (at && at->freeze_state() == AudioTrack::Frozen) {
3043 boost::dynamic_pointer_cast<Send> (processor) ||
3044 boost::dynamic_pointer_cast<Return> (processor) ||
3045 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
3046 boost::dynamic_pointer_cast<PortInsert> (processor)
3055 ProcessorBox::one_processor_can_be_edited ()
3057 list<ProcessorEntry*> selection = processor_display.selection ();
3058 list<ProcessorEntry*>::iterator i = selection.begin();
3059 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
3063 return (i != selection.end());
3067 ProcessorBox::get_editor_window (boost::shared_ptr<Processor> processor, bool use_custom)
3069 boost::shared_ptr<Send> send;
3070 boost::shared_ptr<InternalSend> internal_send;
3071 boost::shared_ptr<Return> retrn;
3072 boost::shared_ptr<PluginInsert> plugin_insert;
3073 boost::shared_ptr<PortInsert> port_insert;
3076 /* This method may or may not return a Window, but if it does not it
3077 * will modify the parent mixer strip appearance layout to allow
3078 * "editing" the @param processor that was passed in.
3080 * So for example, if the processor is an Amp (gain), the parent strip
3081 * will be forced back into a model where the fader controls the main gain.
3082 * If the processor is a send, then we map the send controls onto the
3085 * Plugins and others will return a window for control.
3088 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
3090 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
3095 if (boost::dynamic_pointer_cast<Amp> (processor) && boost::dynamic_pointer_cast<Amp> (processor)->gain_control()->parameter().type() == GainAutomation) {
3097 if (_parent_strip) {
3098 _parent_strip->revert_to_default_display ();
3101 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
3103 if (!_session->engine().connected()) {
3107 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
3109 gidget = new SendUIWindow (send, _session);
3112 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
3114 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
3115 /* no GUI for these */
3119 if (!_session->engine().connected()) {
3123 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
3125 ReturnUIWindow *return_ui;
3126 Window* w = get_processor_ui (retrn);
3130 return_ui = new ReturnUIWindow (retrn, _session);
3131 return_ui->set_title (retrn->name ());
3132 set_processor_ui (send, return_ui);
3135 return_ui = dynamic_cast<ReturnUIWindow *> (w);
3140 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
3142 PluginUIWindow *plugin_ui;
3144 /* these are both allowed to be null */
3146 Window* w = get_processor_ui (plugin_insert);
3149 plugin_ui = new PluginUIWindow (plugin_insert, false, use_custom);
3150 plugin_ui->set_title (generate_processor_title (plugin_insert));
3151 set_processor_ui (plugin_insert, plugin_ui);
3154 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
3159 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
3161 if (!_session->engine().connected()) {
3162 MessageDialog msg ( _("Not connected to audio engine - no I/O changes are possible"));
3167 PortInsertWindow *io_selector;
3169 Window* w = get_processor_ui (port_insert);
3172 io_selector = new PortInsertWindow (_session, port_insert);
3173 set_processor_ui (port_insert, io_selector);
3176 io_selector = dynamic_cast<PortInsertWindow *> (w);
3179 gidget = io_selector;
3186 ProcessorBox::get_generic_editor_window (boost::shared_ptr<Processor> processor)
3188 boost::shared_ptr<PluginInsert> plugin_insert
3189 = boost::dynamic_pointer_cast<PluginInsert>(processor);
3191 if (!plugin_insert) {
3195 PluginUIWindow* win = new PluginUIWindow (plugin_insert, true, false);
3196 win->set_title (generate_processor_title (plugin_insert));
3202 ProcessorBox::register_actions ()
3204 processor_box_actions = myactions.create_action_group (X_("ProcessorMenu"));
3206 Glib::RefPtr<Action> act;
3209 myactions.register_action (processor_box_actions, X_("newplugin"), _("New Plugin"),
3210 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
3212 act = myactions.register_action (processor_box_actions, X_("newlua"), _("New Lua Proc"),
3213 sigc::ptr_fun (ProcessorBox::rb_choose_lua));
3214 act = myactions.register_action (processor_box_actions, X_("newinsert"), _("New Insert"),
3215 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
3216 ActionManager::engine_sensitive_actions.push_back (act);
3217 act = myactions.register_action (processor_box_actions, X_("newsend"), _("New External Send ..."),
3218 sigc::ptr_fun (ProcessorBox::rb_choose_send));
3219 ActionManager::engine_sensitive_actions.push_back (act);
3221 myactions.register_action (processor_box_actions, X_("newaux"), _("New Aux Send ..."));
3223 myactions.register_action (processor_box_actions, X_("controls"), _("Controls"));
3224 myactions.register_action (processor_box_actions, X_("send_options"), _("Send Options"));
3226 myactions.register_action (processor_box_actions, X_("clear"), _("Clear (all)"),
3227 sigc::ptr_fun (ProcessorBox::rb_clear));
3228 myactions.register_action (processor_box_actions, X_("clear_pre"), _("Clear (pre-fader)"),
3229 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
3230 myactions.register_action (processor_box_actions, X_("clear_post"), _("Clear (post-fader)"),
3231 sigc::ptr_fun (ProcessorBox::rb_clear_post));
3233 /* standard editing stuff */
3235 cut_action = myactions.register_action (processor_box_actions, X_("cut"), _("Cut"),
3236 sigc::ptr_fun (ProcessorBox::rb_cut));
3237 copy_action = myactions.register_action (processor_box_actions, X_("copy"), _("Copy"),
3238 sigc::ptr_fun (ProcessorBox::rb_copy));
3239 delete_action = myactions.register_action (processor_box_actions, X_("delete"), _("Delete"),
3240 sigc::ptr_fun (ProcessorBox::rb_delete));
3242 ActionManager::plugin_selection_sensitive_actions.push_back (cut_action);
3243 ActionManager::plugin_selection_sensitive_actions.push_back (copy_action);
3244 ActionManager::plugin_selection_sensitive_actions.push_back (delete_action);
3246 paste_action = myactions.register_action (processor_box_actions, X_("paste"), _("Paste"),
3247 sigc::ptr_fun (ProcessorBox::rb_paste));
3248 rename_action = myactions.register_action (processor_box_actions, X_("rename"), _("Rename"),
3249 sigc::ptr_fun (ProcessorBox::rb_rename));
3250 myactions.register_action (processor_box_actions, X_("selectall"), _("Select All"),
3251 sigc::ptr_fun (ProcessorBox::rb_select_all));
3252 myactions.register_action (processor_box_actions, X_("deselectall"), _("Deselect All"),
3253 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
3255 /* activation etc. */
3257 myactions.register_action (processor_box_actions, X_("activate_all"), _("Activate All"),
3258 sigc::ptr_fun (ProcessorBox::rb_activate_all));
3259 myactions.register_action (processor_box_actions, X_("deactivate_all"), _("Deactivate All"),
3260 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
3261 myactions.register_action (processor_box_actions, X_("ab_plugins"), _("A/B Plugins"),
3262 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
3264 manage_pins_action = myactions.register_action (
3265 processor_box_actions, X_("manage-pins"), _("Pin Management..."),
3266 sigc::ptr_fun (ProcessorBox::rb_manage_pins));
3269 edit_action = myactions.register_action (
3270 processor_box_actions, X_("edit"), _("Edit..."),
3271 sigc::ptr_fun (ProcessorBox::rb_edit));
3273 edit_generic_action = myactions.register_action (
3274 processor_box_actions, X_("edit-generic"), _("Edit with generic controls..."),
3275 sigc::ptr_fun (ProcessorBox::rb_edit_generic));
3281 ProcessorBox::rb_edit_generic ()
3283 if (_current_processor_box == 0) {
3287 _current_processor_box->for_selected_processors (&ProcessorBox::generic_edit_processor);
3291 ProcessorBox::rb_ab_plugins ()
3293 if (_current_processor_box == 0) {
3297 _current_processor_box->ab_plugins ();
3301 ProcessorBox::rb_manage_pins ()
3303 if (_current_processor_box == 0) {
3307 _current_processor_box->for_selected_processors (&ProcessorBox::manage_pins);
3310 ProcessorBox::rb_choose_plugin ()
3312 if (_current_processor_box == 0) {
3315 _current_processor_box->choose_plugin ();
3319 ProcessorBox::rb_choose_lua ()
3321 if (_current_processor_box == 0) {
3324 _current_processor_box->choose_lua ();
3328 ProcessorBox::rb_choose_insert ()
3330 if (_current_processor_box == 0) {
3333 _current_processor_box->choose_insert ();
3337 ProcessorBox::rb_choose_send ()
3339 if (_current_processor_box == 0) {
3342 _current_processor_box->choose_send ();
3346 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
3348 if (_current_processor_box == 0) {
3352 _current_processor_box->choose_aux (wr);
3356 ProcessorBox::rb_clear ()
3358 if (_current_processor_box == 0) {
3362 _current_processor_box->clear_processors ();
3367 ProcessorBox::rb_clear_pre ()
3369 if (_current_processor_box == 0) {
3373 _current_processor_box->clear_processors (PreFader);
3378 ProcessorBox::rb_clear_post ()
3380 if (_current_processor_box == 0) {
3384 _current_processor_box->clear_processors (PostFader);
3388 ProcessorBox::rb_cut ()
3390 if (_current_processor_box == 0) {
3394 _current_processor_box->processor_operation (ProcessorsCut);
3398 ProcessorBox::rb_delete ()
3400 if (_current_processor_box == 0) {
3404 _current_processor_box->processor_operation (ProcessorsDelete);
3408 ProcessorBox::rb_copy ()
3410 if (_current_processor_box == 0) {
3413 _current_processor_box->processor_operation (ProcessorsCopy);
3417 ProcessorBox::rb_paste ()
3419 if (_current_processor_box == 0) {
3423 _current_processor_box->processor_operation (ProcessorsPaste);
3427 ProcessorBox::rb_rename ()
3429 if (_current_processor_box == 0) {
3432 _current_processor_box->rename_processors ();
3436 ProcessorBox::rb_select_all ()
3438 if (_current_processor_box == 0) {
3442 _current_processor_box->processor_operation (ProcessorsSelectAll);
3446 ProcessorBox::rb_deselect_all ()
3448 if (_current_processor_box == 0) {
3452 _current_processor_box->deselect_all_processors ();
3456 ProcessorBox::rb_activate_all ()
3458 if (_current_processor_box == 0) {
3462 _current_processor_box->all_visible_processors_active (true);
3466 ProcessorBox::rb_deactivate_all ()
3468 if (_current_processor_box == 0) {
3471 _current_processor_box->all_visible_processors_active (false);
3475 ProcessorBox::rb_edit ()
3477 if (_current_processor_box == 0) {
3481 _current_processor_box->for_selected_processors (&ProcessorBox::edit_processor);
3485 ProcessorBox::edit_aux_send (boost::shared_ptr<Processor> processor)
3487 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
3491 if (_parent_strip) {
3492 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
3493 if (_parent_strip->current_delivery() == send) {
3494 _parent_strip->revert_to_default_display ();
3496 _parent_strip->show_send(send);
3503 ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
3508 if (edit_aux_send (processor)) {
3512 ProcessorWindowProxy* proxy = find_window_proxy (processor);
3515 proxy->set_custom_ui_mode (true);
3516 proxy->show_the_right_window ();
3521 ProcessorBox::generic_edit_processor (boost::shared_ptr<Processor> processor)
3526 if (edit_aux_send (processor)) {
3530 ProcessorWindowProxy* proxy = find_window_proxy (processor);
3533 proxy->set_custom_ui_mode (false);
3534 proxy->show_the_right_window ();
3539 ProcessorBox::manage_pins (boost::shared_ptr<Processor> processor)
3544 PluginPinWindowProxy* proxy = processor->pinmgr_proxy ();
3553 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
3555 if (!what_changed.contains (ARDOUR::Properties::name)) {
3559 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
3561 boost::shared_ptr<Processor> processor;
3562 boost::shared_ptr<PluginInsert> plugin_insert;
3563 boost::shared_ptr<Send> send;
3565 list<ProcessorEntry*> children = processor_display.children();
3567 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
3569 processor = (*iter)->processor ();
3575 Window* w = get_processor_ui (processor);
3581 /* rename editor windows for sends and plugins */
3583 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
3584 w->set_title (send->name ());
3585 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
3586 w->set_title (generate_processor_title (plugin_insert));
3592 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
3594 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
3595 string::size_type email_pos;
3597 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
3598 maker = maker.substr (0, email_pos - 1);
3601 if (maker.length() > 32) {
3602 maker = maker.substr (0, 32);
3606 SessionObject* owner = pi->owner();
3609 return string_compose(_("%1: %2 (by %3)"), owner->name(), pi->name(), maker);
3611 return string_compose(_("%1 (by %2)"), pi->name(), maker);
3615 /** @param p Processor.
3616 * @return the UI window for \a p.
3619 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
3621 ProcessorWindowProxy* wp = p->window_proxy();
3628 /** Make a note of the UI window that a processor is using.
3629 * @param p Processor.
3630 * @param w UI window.
3633 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
3635 assert (p->window_proxy());
3637 p->window_proxy()->use_window (*w);
3641 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
3643 boost::shared_ptr<Delivery> d = w.lock ();
3648 list<ProcessorEntry*> children = processor_display.children ();
3649 list<ProcessorEntry*>::const_iterator i = children.begin();
3650 while (i != children.end() && (*i)->processor() != d) {
3654 if (i == children.end()) {
3655 processor_display.set_active (0);
3657 processor_display.set_active (*i);
3661 /** Called to repair the damage of Editor::show_window doing a show_all() */
3663 ProcessorBox::hide_things ()
3665 list<ProcessorEntry*> c = processor_display.children ();
3666 for (list<ProcessorEntry*>::iterator i = c.begin(); i != c.end(); ++i) {
3667 (*i)->hide_things ();
3672 ProcessorBox::processor_menu_unmapped ()
3674 processor_display.remove_placeholder ();
3675 /* make all possibly-desensitized actions sensitive again so that
3676 they be activated by other means (e.g. bindings)
3678 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, true);
3682 ProcessorBox::entry_gui_object_state (ProcessorEntry* entry)
3684 if (!_parent_strip) {
3688 GUIObjectState& st = _parent_strip->gui_object_state ();
3690 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
3692 return st.get_or_add_node (strip, entry->state_id());
3696 ProcessorBox::update_gui_object_state (ProcessorEntry* entry)
3698 XMLNode* proc = entry_gui_object_state (entry);
3703 /* XXX: this is a bit inefficient; we just remove all child nodes and re-add them */
3704 proc->remove_nodes_and_delete (X_("Object"));
3705 entry->add_control_state (proc);
3709 ProcessorBox::is_editor_mixer_strip() const
3711 return _parent_strip && !_parent_strip->mixer_owned();
3714 ProcessorWindowProxy::ProcessorWindowProxy (string const & name, ProcessorBox* box, boost::weak_ptr<Processor> processor)
3715 : WM::ProxyBase (name, string())
3716 , _processor_box (box)
3717 , _processor (processor)
3719 , want_custom (false)
3721 boost::shared_ptr<Processor> p = _processor.lock ();
3725 p->DropReferences.connect (going_away_connection, MISSING_INVALIDATOR, boost::bind (&ProcessorWindowProxy::processor_going_away, this), gui_context());
3728 ProcessorWindowProxy::~ProcessorWindowProxy()
3730 /* processor window proxies do not own the windows they create with
3731 * ::get(), so set _window to null before the normal WindowProxy method
3738 ProcessorWindowProxy::processor_going_away ()
3742 WM::Manager::instance().remove (this);
3743 /* should be no real reason to do this, since the object that would
3744 send DropReferences is about to be deleted, but lets do it anyway.
3746 going_away_connection.disconnect();
3749 ARDOUR::SessionHandlePtr*
3750 ProcessorWindowProxy::session_handle()
3757 ProcessorWindowProxy::get_state ()
3760 node = &ProxyBase::get_state();
3761 node->add_property (X_("custom-ui"), is_custom? X_("yes") : X_("no"));
3766 ProcessorWindowProxy::set_state (const XMLNode& node, int /*version*/)
3768 XMLNodeList children = node.children ();
3769 XMLNodeList::const_iterator i = children.begin ();
3770 while (i != children.end()) {
3771 XMLProperty* prop = (*i)->property (X_("name"));
3772 if ((*i)->name() == X_("Window") && prop && prop->value() == _name) {
3778 if (i != children.end()) {
3780 if ((prop = (*i)->property (X_("custom-ui"))) != 0) {
3781 want_custom = PBD::string_is_affirmative (prop->value ());
3785 return ProxyBase::set_state (node, 0);
3789 ProcessorWindowProxy::get (bool create)
3791 boost::shared_ptr<Processor> p = _processor.lock ();
3796 if (_window && (is_custom != want_custom)) {
3797 /* drop existing window - wrong type */
3806 is_custom = want_custom;
3807 _window = _processor_box->get_editor_window (p, is_custom);
3813 _window->show_all ();
3818 ProcessorWindowProxy::show_the_right_window ()
3820 if (_window && (is_custom != want_custom)) {
3821 /* drop existing window - wrong type */
3826 is_custom = want_custom;
3833 PluginPinWindowProxy::PluginPinWindowProxy(std::string const &name, boost::weak_ptr<ARDOUR::Processor> processor)
3834 : WM::ProxyBase (name, string())
3835 , _processor (processor)
3837 boost::shared_ptr<Processor> p = _processor.lock ();
3841 p->DropReferences.connect (going_away_connection, MISSING_INVALIDATOR, boost::bind (&PluginPinWindowProxy::processor_going_away, this), gui_context());
3844 PluginPinWindowProxy::~PluginPinWindowProxy()
3851 PluginPinWindowProxy::get (bool create)
3853 boost::shared_ptr<Processor> p = _processor.lock ();
3854 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (p);
3863 _window = new PluginPinDialog (pi);
3866 _window->show_all ();
3871 PluginPinWindowProxy::processor_going_away ()
3875 WM::Manager::instance().remove (this);
3876 going_away_connection.disconnect();
3880 ProcessorBox::load_bindings ()
3882 bindings = Bindings::get_bindings (X_("Processor Box"), myactions);