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"
65 #include "ardour_dialog.h"
66 #include "ardour_ui.h"
67 #include "gui_thread.h"
68 #include "io_selector.h"
70 #include "luainstance.h"
72 #include "mixer_strip.h"
73 #include "plugin_pin_dialog.h"
74 #include "plugin_selector.h"
75 #include "plugin_ui.h"
76 #include "port_insert_ui.h"
77 #include "processor_box.h"
78 #include "public_editor.h"
79 #include "return_ui.h"
80 #include "route_processor_selection.h"
81 #include "script_selector.h"
85 #include "new_plugin_preset_dialog.h"
89 #ifdef AUDIOUNIT_SUPPORT
94 bool ProcessorBox::show_all_processors = false;
98 using namespace ARDOUR;
101 using namespace Glib;
102 using namespace Gtkmm2ext;
104 ProcessorBox* ProcessorBox::_current_processor_box = 0;
105 RefPtr<Action> ProcessorBox::paste_action;
106 RefPtr<Action> ProcessorBox::cut_action;
107 RefPtr<Action> ProcessorBox::copy_action;
108 RefPtr<Action> ProcessorBox::rename_action;
109 RefPtr<Action> ProcessorBox::delete_action;
110 RefPtr<Action> ProcessorBox::manage_pins_action;
111 RefPtr<Action> ProcessorBox::edit_action;
112 RefPtr<Action> ProcessorBox::edit_generic_action;
113 RefPtr<ActionGroup> ProcessorBox::processor_box_actions;
114 Gtkmm2ext::ActionMap ProcessorBox::myactions (X_("processor box"));
115 Gtkmm2ext::Bindings* ProcessorBox::bindings = 0;
117 static const uint32_t audio_port_color = 0x4A8A0EFF; // Green
118 static const uint32_t midi_port_color = 0x960909FF; //Red
120 ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processor> p, Width w)
121 : _button (ArdourButton::led_default_elements)
122 , _position (PreFader)
125 , _unknown_processor(false)
130 , _output_icon(false)
135 _button.set_distinct_led_click (true);
136 _button.set_fallthrough_to_parent(true);
137 _button.set_led_left (true);
138 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &ProcessorEntry::led_clicked));
139 _button.set_text (name (_width));
141 if (boost::dynamic_pointer_cast<PeakMeter> (_processor)) {
142 _button.set_elements(ArdourButton::Element(_button.elements() & ~ArdourButton::Indicator));
144 if (boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
145 _button.set_elements(ArdourButton::Element(_button.elements() & ~ArdourButton::Indicator));
146 _unknown_processor = true;
149 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
150 if (pi && pi->plugin() && pi->plugin()->get_info()->type != ARDOUR::Lua) {
151 _plugin_preset_pointer = PluginPresetPtr (new PluginPreset (pi->plugin()->get_info()));
156 _vbox.pack_start (_routing_icon);
157 _vbox.pack_start (_input_icon);
158 _vbox.pack_start (_button, true, true);
160 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
161 if (pi && pi->plugin() && pi->plugin()->has_inline_display()) {
162 if (pi->plugin()->get_info()->type != ARDOUR::Lua) {
163 _plugin_display = new PluginDisplay (pi->plugin(),
164 std::max (60.f, rintf(112.f * UIConfiguration::instance().get_ui_scale())));
166 assert (boost::dynamic_pointer_cast<LuaProc>(pi->plugin()));
167 _plugin_display = new LuaPluginDisplay (boost::dynamic_pointer_cast<LuaProc>(pi->plugin()),
168 std::max (60.f, rintf(112.f * UIConfiguration::instance().get_ui_scale())));
170 _vbox.pack_start (*_plugin_display);
171 _plugin_display->set_no_show_all (true);
172 if (UIConfiguration::instance().get_show_inline_display_by_default ()) {
173 _plugin_display->show ();
176 _vbox.pack_end (_output_icon);
178 _button.set_active (_processor->active());
180 _routing_icon.set_no_show_all(true);
181 _input_icon.set_no_show_all(true);
184 _routing_icon.set_visible(false);
188 _processor->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_active_changed, this), gui_context());
189 _processor->PropertyChanged.connect (name_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_property_changed, this, _1), gui_context());
190 _processor->ConfigurationChanged.connect (config_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_configuration_changed, this, _1, _2), gui_context());
192 set<Evoral::Parameter> p = _processor->what_can_be_automated ();
193 for (set<Evoral::Parameter>::iterator i = p.begin(); i != p.end(); ++i) {
195 std::string label = _processor->describe_parameter (*i);
197 if (boost::dynamic_pointer_cast<Send> (_processor)) {
199 } else if (boost::dynamic_pointer_cast<Return> (_processor)) {
203 Control* c = new Control (_processor->automation_control (*i), label);
205 _controls.push_back (c);
207 if (boost::dynamic_pointer_cast<Amp> (_processor) == 0) {
208 /* Add non-Amp (Fader & Trim) controls to the processor box */
209 _vbox.pack_start (c->box);
213 _input_icon.set_ports(_processor->input_streams());
214 _output_icon.set_ports(_processor->output_streams());
216 _routing_icon.set_sources(_processor->input_streams());
217 _routing_icon.set_sinks(_processor->output_streams());
222 _vbox.set_size_request (-1, _button.size_request().height);
226 ProcessorEntry::~ProcessorEntry ()
228 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
231 delete _plugin_display;
235 ProcessorEntry::action_widget ()
241 ProcessorEntry::widget ()
247 ProcessorEntry::drag_text () const
253 ProcessorEntry::can_copy_state (Gtkmm2ext::DnDVBoxChild* o) const
255 ProcessorEntry *other = dynamic_cast<ProcessorEntry*> (o);
259 boost::shared_ptr<ARDOUR::Processor> otherproc = other->processor();
260 boost::shared_ptr<PluginInsert> my_pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
261 boost::shared_ptr<PluginInsert> ot_pi = boost::dynamic_pointer_cast<PluginInsert> (otherproc);
262 if (boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
265 if (boost::dynamic_pointer_cast<UnknownProcessor> (otherproc)) {
268 if (!my_pi || !ot_pi) {
271 if (my_pi->type() != ot_pi->type()) {
274 boost::shared_ptr<Plugin> my_p = my_pi->plugin();
275 boost::shared_ptr<Plugin> ot_p = ot_pi->plugin();
276 if (!my_p || !ot_p) {
279 if (my_p->unique_id() != ot_p->unique_id()) {
286 ProcessorEntry::drag_data_get (Glib::RefPtr<Gdk::DragContext> const, Gtk::SelectionData &data)
288 if (data.get_target() == "PluginPresetPtr") {
289 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
291 if (!_plugin_preset_pointer || !pi) {
292 data.set (data.get_target(), 8, NULL, 0);
296 boost::shared_ptr<ARDOUR::Plugin> plugin = pi->plugin();
299 PluginManager& manager (PluginManager::instance());
300 bool fav = manager.get_status (_plugin_preset_pointer->_pip) == PluginManager::Favorite;
302 NewPluginPresetDialog d (plugin,
303 string_compose(_("New Favorite Preset for \"%1\""),_plugin_preset_pointer->_pip->name), !fav);
305 _plugin_preset_pointer->_preset.valid = false;
308 case Gtk::RESPONSE_CANCEL:
309 data.set (data.get_target(), 8, NULL, 0);
313 case Gtk::RESPONSE_NO:
316 case Gtk::RESPONSE_ACCEPT:
317 if (d.name().empty()) {
322 plugin->remove_preset (d.name ());
325 Plugin::PresetRecord const r = plugin->save_preset (d.name());
327 if (!r.uri.empty ()) {
328 _plugin_preset_pointer->_preset.uri = r.uri;
329 _plugin_preset_pointer->_preset.label = r.label;
330 _plugin_preset_pointer->_preset.user = r.user;
331 _plugin_preset_pointer->_preset.valid = r.valid;
334 data.set (data.get_target(), 8, (const guchar *) &_plugin_preset_pointer, sizeof (PluginPresetPtr));
341 ProcessorEntry::set_position (Position p, uint32_t num)
346 if (_position_num == 0 || _routing_icon.get_visible()) {
356 ProcessorEntry::set_visual_state (Gtkmm2ext::VisualState s, bool yn)
359 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() | s));
361 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() & ~s));
366 ProcessorEntry::setup_visuals ()
368 if (_unknown_processor) {
369 _button.set_name ("processor stub");
375 if (_plugin_display) { _plugin_display->set_name ("processor prefader"); }
376 _button.set_name ("processor prefader");
380 _button.set_name ("processor fader");
384 if (_plugin_display) { _plugin_display->set_name ("processor postfader"); }
385 _button.set_name ("processor postfader");
391 boost::shared_ptr<Processor>
392 ProcessorEntry::processor () const
395 return boost::shared_ptr<Processor>();
401 ProcessorEntry::set_enum_width (Width w)
404 _button.set_text (name (_width));
408 ProcessorEntry::led_clicked(GdkEventButton *ev)
410 bool ctrl_shift_pressed = false;
411 Keyboard::ModifierMask ctrl_shift_mask = Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier);
413 if (Keyboard::modifier_state_equals (ev->state, ctrl_shift_mask)) {
414 ctrl_shift_pressed = true;
418 if (_button.get_active ()) {
419 if (ctrl_shift_pressed) {
420 _parent->all_visible_processors_active(false);
422 if (_position == Fader) {
423 _processor->deactivate ();
427 _processor->deactivate ();
431 if (ctrl_shift_pressed) {
432 _parent->all_visible_processors_active(true);
434 if (_position == Fader) {
435 _processor->activate ();
439 _processor->activate ();
446 ProcessorEntry::processor_active_changed ()
449 _button.set_active (_processor->active());
454 ProcessorEntry::processor_property_changed (const PropertyChange& what_changed)
456 if (what_changed.contains (ARDOUR::Properties::name)) {
457 _button.set_text (name (_width));
463 ProcessorEntry::processor_configuration_changed (const ChanCount in, const ChanCount out)
465 _input_icon.set_ports(in);
466 _output_icon.set_ports(out);
467 _routing_icon.set_sources(in);
468 _routing_icon.set_sinks(out);
469 _input_icon.queue_draw();
470 _output_icon.queue_draw();
471 _routing_icon.queue_draw();
475 ProcessorEntry::setup_tooltip ()
478 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
480 std::string postfix = "";
482 if ((replicated = pi->get_count()) > 1) {
483 postfix = string_compose(_("\nThis mono plugin has been replicated %1 times."), replicated);
485 if (pi->plugin()->has_editor()) {
486 ARDOUR_UI_UTILS::set_tooltip (_button,
487 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));
489 ARDOUR_UI_UTILS::set_tooltip (_button,
490 string_compose (_("<b>%1</b>\nDouble-click to show generic GUI.%2"), name (Wide), postfix));
494 if(boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
495 ARDOUR_UI::instance()->set_tip (_button,
496 string_compose (_("<b>%1</b>\nThe Plugin is not available on this system\nand has been replaced by a stub."), name (Wide)));
500 ARDOUR_UI_UTILS::set_tooltip (_button, string_compose ("<b>%1</b>", name (Wide)));
504 ProcessorEntry::name (Width w) const
506 boost::shared_ptr<Send> send;
513 if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
514 !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
518 /* grab the send name out of its overall name */
520 string::size_type lbracket, rbracket;
521 lbracket = send->name().find ('[');
522 rbracket = send->name().find (']');
526 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
529 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
534 boost::shared_ptr<ARDOUR::PluginInsert> pi;
536 if ((pi = boost::dynamic_pointer_cast<ARDOUR::PluginInsert> (_processor)) != 0
537 && (replicated = pi->get_count()) > 1)
539 name_display += string_compose(_("(%1x1) "), replicated);
544 name_display += _processor->display_name();
547 name_display += PBD::short_version (_processor->display_name(), 5);
557 ProcessorEntry::show_all_controls ()
559 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
560 (*i)->set_visible (true);
563 _parent->update_gui_object_state (this);
567 ProcessorEntry::hide_all_controls ()
569 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
570 (*i)->set_visible (false);
573 _parent->update_gui_object_state (this);
577 ProcessorEntry::add_control_state (XMLNode* node) const
579 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
580 (*i)->add_state (node);
583 if (_plugin_display) {
584 XMLNode* c = new XMLNode (X_("Object"));
585 c->add_property (X_("id"), X_("InlineDisplay"));
586 c->add_property (X_("visible"), _plugin_display->is_visible ());
587 node->add_child_nocopy (*c);
592 ProcessorEntry::set_control_state (XMLNode const * node)
594 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
595 (*i)->set_state (node);
598 if (_plugin_display) {
599 XMLNode* n = GUIObjectState::get_node (node, X_("InlineDisplay"));
600 XMLProperty* p = n ? n->property (X_("visible")) : NULL;
602 if (string_is_affirmative (p->value ())) {
603 _plugin_display->show();
605 _plugin_display->hide();
612 ProcessorEntry::state_id () const
614 return string_compose ("processor %1", _processor->id().to_s());
618 ProcessorEntry::hide_things ()
620 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
621 (*i)->hide_things ();
627 ProcessorEntry::build_controls_menu ()
629 using namespace Menu_Helpers;
630 Menu* menu = manage (new Menu);
631 MenuList& items = menu->items ();
633 if (_plugin_display) {
634 items.push_back (CheckMenuElem (_("Inline Display")));
635 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
636 c->set_active (_plugin_display->is_visible ());
637 c->signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::toggle_inline_display_visibility));
638 items.push_back (SeparatorElem ());
642 MenuElem (_("Show All Controls"), sigc::mem_fun (*this, &ProcessorEntry::show_all_controls))
646 MenuElem (_("Hide All Controls"), sigc::mem_fun (*this, &ProcessorEntry::hide_all_controls))
649 if (!_controls.empty ()) {
650 items.push_back (SeparatorElem ());
653 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
654 items.push_back (CheckMenuElem ((*i)->name ()));
655 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
656 c->set_active ((*i)->visible ());
657 c->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &ProcessorEntry::toggle_control_visibility), *i));
664 ProcessorEntry::toggle_inline_display_visibility ()
666 if (_plugin_display->is_visible ()) {
667 _plugin_display->hide();
669 _plugin_display->show();
671 _parent->update_gui_object_state (this);
675 ProcessorEntry::toggle_control_visibility (Control* c)
677 c->set_visible (!c->visible ());
678 _parent->update_gui_object_state (this);
682 ProcessorEntry::build_send_options_menu ()
684 using namespace Menu_Helpers;
685 Menu* menu = manage (new Menu);
686 MenuList& items = menu->items ();
688 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (_processor);
691 items.push_back (CheckMenuElem (_("Link panner controls")));
692 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
693 c->set_active (send->panner_shell()->is_linked_to_route());
694 c->signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::toggle_panner_link));
701 ProcessorEntry::toggle_panner_link ()
703 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (_processor);
705 send->panner_shell()->set_linked_to_route(!send->panner_shell()->is_linked_to_route());
709 ProcessorEntry::Control::Control (boost::shared_ptr<AutomationControl> c, string const & n)
711 , _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1)
712 , _slider (&_adjustment, boost::shared_ptr<PBD::Controllable>(), 0, max(13.f, rintf(13.f * UIConfiguration::instance().get_ui_scale())))
713 , _slider_persistant_tooltip (&_slider)
714 , _button (ArdourButton::led_default_elements)
715 , _ignore_ui_adjustment (false)
719 _slider.set_controllable (c);
720 box.set_padding(0, 0, 4, 4);
723 _button.set_text (_name);
724 _button.set_led_left (true);
725 _button.set_name ("processor control button");
729 _button.signal_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked));
730 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked_event));
731 // dup. currently timers are used :(
732 //c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
736 _slider.set_name ("ProcessorControlSlider");
737 _slider.set_text (_name);
742 const ARDOUR::ParameterDescriptor& desc = c->desc();
743 double const lo = c->internal_to_interface(desc.lower);
744 double const up = c->internal_to_interface(desc.upper);
745 double const normal = c->internal_to_interface(desc.normal);
746 double smallstep = desc.smallstep;
747 double largestep = desc.largestep;
749 if (smallstep == 0.0) {
750 smallstep = up / 1000.;
752 smallstep = c->internal_to_interface(desc.lower + smallstep);
755 if (largestep == 0.0) {
756 largestep = up / 40.;
758 largestep = c->internal_to_interface(desc.lower + largestep);
761 _adjustment.set_lower (lo);
762 _adjustment.set_upper (up);
763 _adjustment.set_step_increment (smallstep);
764 _adjustment.set_page_increment (largestep);
765 _slider.set_default_value (normal);
767 _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &Control::slider_adjusted));
768 // dup. currently timers are used :(
769 //c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
772 // yuck, do we really need to do this?
773 // according to c404374 this is only needed for send automation
774 timer_connection = Timers::rapid_connect (sigc::mem_fun (*this, &Control::control_changed));
779 /* We're providing our own PersistentTooltip */
780 set_no_tooltip_whatsoever (_slider);
783 ProcessorEntry::Control::~Control ()
785 timer_connection.disconnect ();
789 ProcessorEntry::Control::set_tooltip ()
791 boost::shared_ptr<AutomationControl> c = _control.lock ();
798 snprintf (tmp, sizeof(tmp), "%s: %s", _name.c_str(), c->get_value() > 0.5 ? _("on") : _("off"));
800 snprintf (tmp, sizeof(tmp), "%s: %.2f", _name.c_str(), c->internal_to_user (c->get_value ()));
803 string sm = Gtkmm2ext::markup_escape_text (tmp);
804 _slider_persistant_tooltip.set_tip (sm);
805 ARDOUR_UI_UTILS::set_tooltip (_button, sm);
809 ProcessorEntry::Control::slider_adjusted ()
811 if (_ignore_ui_adjustment) {
815 boost::shared_ptr<AutomationControl> c = _control.lock ();
821 c->set_value ( c->interface_to_internal(_adjustment.get_value ()) , Controllable::NoGroup);
826 ProcessorEntry::Control::button_clicked ()
828 boost::shared_ptr<AutomationControl> c = _control.lock ();
834 bool const n = _button.get_active ();
836 c->set_value (n ? 0 : 1, Controllable::NoGroup);
837 _button.set_active (!n);
842 ProcessorEntry::Control::button_clicked_event (GdkEventButton *ev)
850 ProcessorEntry::Control::control_changed ()
852 boost::shared_ptr<AutomationControl> c = _control.lock ();
857 _ignore_ui_adjustment = true;
861 _button.set_active (c->get_value() > 0.5);
864 // as long as rapid timers are used, only update the tooltip
865 // if the value has changed.
866 const double nval = c->internal_to_interface (c->get_value ());
867 if (_adjustment.get_value() != nval) {
868 _adjustment.set_value (nval);
873 _ignore_ui_adjustment = false;
877 ProcessorEntry::Control::add_state (XMLNode* node) const
879 XMLNode* c = new XMLNode (X_("Object"));
880 c->add_property (X_("id"), state_id ());
881 c->add_property (X_("visible"), _visible);
882 node->add_child_nocopy (*c);
886 ProcessorEntry::Control::set_state (XMLNode const * node)
888 XMLNode* n = GUIObjectState::get_node (node, state_id ());
890 XMLProperty* p = n->property (X_("visible"));
891 set_visible (p && string_is_affirmative (p->value ()));
898 ProcessorEntry::Control::set_visible (bool v)
909 /** Called when the Editor might have re-shown things that
913 ProcessorEntry::Control::hide_things ()
921 ProcessorEntry::Control::state_id () const
923 boost::shared_ptr<AutomationControl> c = _control.lock ();
926 return string_compose (X_("control %1"), c->id().to_s ());
929 PluginInsertProcessorEntry::PluginInsertProcessorEntry (ProcessorBox* b, boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
930 : ProcessorEntry (b, p, w)
933 p->PluginIoReConfigure.connect (
934 _splitting_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::plugin_insert_splitting_changed, this), gui_context()
937 plugin_insert_splitting_changed ();
941 PluginInsertProcessorEntry::plugin_insert_splitting_changed ()
943 ChanCount in, out; // actual configured i/o
944 _plugin_insert->configured_io (in, out);
946 /* get number of input ports */
947 ChanCount sinks = _plugin_insert->natural_input_streams();
948 if (!_plugin_insert->splitting () && _plugin_insert->get_count() > 1) {
949 /* replicated instances */
950 for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
951 sinks.set(*t, sinks.get(*t) * _plugin_insert->get_count());
955 if (_plugin_insert->natural_output_streams().n_midi() == 0 &&
956 _plugin_insert->output_streams().n_midi() == 1) {
957 in.set(DataType::MIDI, 1);
958 out.set(DataType::MIDI, 1);
959 sinks.set(DataType::MIDI, 1);
962 /* the Input streams available (*valid* outputs from prev. plugin)
963 * this will be <= sinks. Some input-ports of this processor
964 * may be unconnected.
966 _routing_icon.set_sources(in);
968 /* the actual input ports of this processor */
969 _input_icon.set_ports(sinks);
970 _routing_icon.set_sinks(sinks);
972 /* set/override plugin-output ports to actual outputs-streams.
974 * This plugin may have unconnected output-ports (currently only in Mixbus,
975 * e.g channelstrip-EQ at the top of a MIDI-channel before the synth).
977 * The *next* processor below this one will only see the
978 * actual available streams (it cannot know the real outputs
981 * There is currently no API to query the ports of the previous (or next)
984 * (normally - iff configuration succeeds - this is set during
985 * ProcessorEntry::processor_configuration_changed() and should
986 * equal _plugin_insert->output_streams())
988 _output_icon.set_ports(out);
990 if (out != _plugin_insert->output_streams()) {
991 std::cerr << "Processor Wiring: " << processor()->name()
992 << " out-ports: " << _plugin_insert->output_streams() // NB. does not include midi-bypass
993 << " out-connections: " << out
998 _routing_icon.set_splitting(_plugin_insert->splitting ());
1000 if (_plugin_insert->splitting () || in != sinks)
1002 _routing_icon.set_size_request (-1, std::max (7.f, rintf(7.f * UIConfiguration::instance().get_ui_scale())));
1003 _routing_icon.set_visible(true);
1006 _routing_icon.set_visible(false);
1007 if (_position_num != 0) {
1012 _input_icon.queue_draw();
1013 _output_icon.queue_draw();
1014 _routing_icon.queue_draw();
1018 PluginInsertProcessorEntry::hide_things ()
1020 ProcessorEntry::hide_things ();
1021 plugin_insert_splitting_changed ();
1024 ProcessorEntry::PortIcon::PortIcon(bool input) {
1026 _ports = ARDOUR::ChanCount(ARDOUR::DataType::AUDIO, 1);
1027 set_size_request (-1, std::max (2.f, rintf(2.f * UIConfiguration::instance().get_ui_scale())));
1031 ProcessorEntry::PortIcon::on_expose_event (GdkEventExpose* ev)
1033 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
1035 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
1038 Gtk::Allocation a = get_allocation();
1039 double const width = a.get_width();
1040 double const height = a.get_height();
1042 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
1043 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
1045 cairo_rectangle (cr, 0, 0, width, height);
1048 const double dx = rint(max(2., 2. * UIConfiguration::instance().get_ui_scale()));
1049 if (_ports.n_total() > 1) {
1050 for (uint32_t i = 0; i < _ports.n_total(); ++i) {
1051 if (i < _ports.n_midi()) {
1052 cairo_set_source_rgb (cr,
1053 UINT_RGBA_R_FLT(midi_port_color),
1054 UINT_RGBA_G_FLT(midi_port_color),
1055 UINT_RGBA_B_FLT(midi_port_color));
1057 cairo_set_source_rgb (cr,
1058 UINT_RGBA_R_FLT(audio_port_color),
1059 UINT_RGBA_G_FLT(audio_port_color),
1060 UINT_RGBA_B_FLT(audio_port_color));
1062 const float x = rintf(width * (.2f + .6f * i / (_ports.n_total() - 1.f)));
1063 cairo_rectangle (cr, x-dx * .5, 0, 1+dx, height);
1066 } else if (_ports.n_total() == 1) {
1067 if (_ports.n_midi() == 1) {
1068 cairo_set_source_rgb (cr,
1069 UINT_RGBA_R_FLT(midi_port_color),
1070 UINT_RGBA_G_FLT(midi_port_color),
1071 UINT_RGBA_B_FLT(midi_port_color));
1073 cairo_set_source_rgb (cr,
1074 UINT_RGBA_R_FLT(audio_port_color),
1075 UINT_RGBA_G_FLT(audio_port_color),
1076 UINT_RGBA_B_FLT(audio_port_color));
1078 const float x = rintf(width * .5);
1079 cairo_rectangle (cr, x-dx * .5, 0, 1+dx, height);
1089 ProcessorEntry::RoutingIcon::on_expose_event (GdkEventExpose* ev)
1091 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
1093 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
1096 cairo_set_line_width (cr, max (1.f, UIConfiguration::instance().get_ui_scale()));
1097 cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
1099 Gtk::Allocation a = get_allocation();
1100 double const width = a.get_width();
1101 double const height = a.get_height();
1103 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
1104 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
1106 cairo_rectangle (cr, 0, 0, width, height);
1109 Gdk::Color const fg = get_style()->get_fg (STATE_NORMAL);
1110 cairo_set_source_rgb (cr, fg.get_red_p (), fg.get_green_p (), fg.get_blue_p ());
1112 const uint32_t sources = _sources.n_total();
1113 const uint32_t sinks = _sinks.n_total();
1115 const uint32_t midi_sources = _sources.n_midi();
1116 const uint32_t midi_sinks = _sinks.n_midi();
1117 const uint32_t audio_sources = _sources.n_audio();
1118 const uint32_t audio_sinks = _sinks.n_audio();
1121 cairo_set_source_rgb (cr,
1122 UINT_RGBA_R_FLT(midi_port_color),
1123 UINT_RGBA_G_FLT(midi_port_color),
1124 UINT_RGBA_B_FLT(midi_port_color));
1125 if (midi_sources > 0 && midi_sinks > 0 && sinks > 1 && sources > 1) {
1126 for (uint32_t i = 0 ; i < midi_sources; ++i) {
1127 const float si_x = rintf(width * (.2f + .6f * i / (sinks - 1.f))) + .5f;
1128 const float si_x0 = rintf(width * (.2f + .6f * i / (sources - 1.f))) + .5f;
1129 cairo_move_to (cr, si_x, height);
1130 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
1133 } else if (midi_sources == 1 && midi_sinks == 1 && sinks == 1 && sources == 1) {
1134 const float si_x = rintf(width * .5f) + .5f;
1135 cairo_move_to (cr, si_x, height);
1136 cairo_line_to (cr, si_x, 0);
1138 } else if (midi_sources == 1 && midi_sinks == 1) {
1139 /* unusual cases -- removed synth, midi-track w/audio plugins */
1140 const float si_x = rintf(width * (sinks > 1 ? .2f : .5f)) + .5f;
1141 const float si_x0 = rintf(width * (sources > 1 ? .2f : .5f)) + .5f;
1142 cairo_move_to (cr, si_x, height);
1143 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
1145 } else if (midi_sources == 0 && midi_sinks == 1) {
1146 const double dx = 1 + rint(max(2., 2. * UIConfiguration::instance().get_ui_scale()));
1148 // TODO connect back to track-input of last midi-out if any, otherwise draw "X"
1149 const float si_x = rintf(width * .2f) + .5f;
1150 cairo_move_to (cr, si_x, height);
1151 cairo_line_to (cr, si_x, height * .66);
1152 cairo_move_to (cr, si_x - dx, height * .66);
1153 cairo_line_to (cr, si_x + dx, height * .66);
1156 } else if (midi_sources != 0 && midi_sinks != 0) {
1157 PBD::warning << string_compose("Programming error: midi routing display: A %1 -> %2 | M %3 -> %4 | T %5 -> %6",
1158 audio_sources, audio_sinks, midi_sources, midi_sinks, sources, sinks) << endmsg;
1163 cairo_set_source_rgb (cr,
1164 UINT_RGBA_R_FLT(audio_port_color),
1165 UINT_RGBA_G_FLT(audio_port_color),
1166 UINT_RGBA_B_FLT(audio_port_color));
1169 assert(audio_sources < 2);
1170 assert(audio_sinks > 1);
1171 /* assume there is only ever one MIDI port */
1172 const float si_x0 = rintf(width * (midi_sources > 0 ? .8f : .5f)) + .5f;
1173 for (uint32_t i = midi_sinks; i < sinks; ++i) {
1174 const float si_x = rintf(width * (.2f + .6f * i / (sinks - 1.f))) + .5f;
1175 cairo_move_to (cr, si_x, height);
1176 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
1179 } else if (audio_sources > 1 && sinks > 1) {
1180 for (uint32_t i = 0 ; i < audio_sources; ++i) {
1181 const float si_x = rintf(width * (.2f + .6f * (i + midi_sinks) / (sinks - 1.f))) + .5f;
1182 const float si_x0 = rintf(width * (.2f + .6f * (i + midi_sources) / (sources - 1.f))) + .5f;
1183 cairo_move_to (cr, si_x, height);
1184 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
1187 } else if (audio_sources == 1 && audio_sinks > 0) {
1190 si_x = rintf(width * .5f) + .5f;
1192 si_x = rintf(width * (.2f + .6f * midi_sinks / (sinks - 1.f))) + .5f;
1195 si_x0 = rintf(width * .5f) + .5f;
1197 si_x0 = rintf(width * (.2f + .6f * midi_sources / (sources - 1.f))) + .5f;
1199 cairo_move_to (cr, si_x, height);
1200 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
1203 } else if (audio_sources != 0 && audio_sinks != 0) {
1204 PBD::warning << string_compose("Programming error: audio routing display: A %1 -> %2 | M %3 -> %4 | T %5 -> %6",
1205 audio_sources, audio_sinks, midi_sources, midi_sinks, sources, sinks) << endmsg;
1213 ProcessorEntry::PluginDisplay::PluginDisplay (boost::shared_ptr<ARDOUR::Plugin> p, uint32_t max_height)
1216 , _max_height (max_height)
1220 set_name ("processor prefader");
1221 _plug->QueueDraw.connect (_qdraw_connection, invalidator (*this),
1222 boost::bind (&Gtk::Widget::queue_draw, this), gui_context ());
1225 ProcessorEntry::PluginDisplay::~PluginDisplay ()
1228 cairo_surface_destroy (_surf);
1233 ProcessorEntry::PluginDisplay::on_size_request (Gtk::Requisition* req)
1236 req->height = _cur_height;
1241 ProcessorEntry::PluginDisplay::update_height_alloc (uint32_t inline_height)
1243 /* work-around scroll-bar + aspect ratio
1244 * show inline-view -> height changes -> scrollbar gets added
1245 * -> width changes -> inline-view, fixed aspect ratio -> height changes
1246 * -> scroll bar is removed [-> width changes ; repeat ]
1248 uint32_t shm = std::min (_max_height, inline_height);
1250 Gtk::Container* pr = get_parent();
1251 for (uint32_t i = 0; i < 4 && pr; ++i) {
1252 // VBox, EventBox, ViewPort, ScrolledWindow
1253 pr = pr->get_parent();
1255 Gtk::ScrolledWindow* sw = dynamic_cast<Gtk::ScrolledWindow*> (pr);
1257 const Gtk::VScrollbar* vsb = sw->get_vscrollbar();
1258 sc = vsb && vsb->is_visible();
1261 if (shm != _cur_height) {
1262 if (_scroll == sc || _cur_height < shm) {
1271 ProcessorEntry::PluginDisplay::render_inline (cairo_t* cr, uint32_t width)
1273 Plugin::Display_Image_Surface* dis = _plug->render_inline_display (width, _max_height);
1278 /* allocate a local image-surface,
1279 * We cannot re-use the data via cairo_image_surface_create_for_data(),
1280 * since pixman keeps a reference to it.
1281 * we'd need to hand over the data and ha cairo_surface_destroy to free it.
1282 * it might be possible to work around via cairo_surface_set_user_data().
1285 || dis->width != cairo_image_surface_get_width (_surf)
1286 || dis->height != cairo_image_surface_get_height (_surf)
1289 cairo_surface_destroy (_surf);
1291 _surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, dis->width, dis->height);
1294 if (cairo_image_surface_get_stride (_surf) == dis->stride) {
1295 memcpy (cairo_image_surface_get_data (_surf), dis->data, dis->stride * dis->height);
1297 unsigned char *src = dis->data;
1298 unsigned char *dst = cairo_image_surface_get_data (_surf);
1299 const int dst_stride = cairo_image_surface_get_stride (_surf);
1300 for (int y = 0; y < dis->height; ++y) {
1301 memcpy (dst, src, dis->width * 4 /*ARGB32*/);
1307 cairo_surface_mark_dirty(_surf);
1308 const double xc = floor ((width - dis->width) * .5);
1309 cairo_set_source_surface(cr, _surf, xc, 0);
1316 ProcessorEntry::PluginDisplay::on_expose_event (GdkEventExpose* ev)
1318 Gtk::Allocation a = get_allocation();
1319 double const width = a.get_width();
1320 double const height = a.get_height();
1322 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
1323 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
1326 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
1327 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
1328 cairo_rectangle (cr, 0, 0, width, height);
1332 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
1333 Gtkmm2ext::rounded_rectangle (cr, .5, -1.5, width - 1, height + 1, 7);
1335 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1337 uint32_t ht = render_inline (cr, width);
1342 if (_cur_height != 1) {
1349 update_height_alloc (ht);
1352 bool failed = false;
1353 std::string name = get_name();
1354 ArdourCanvas::Color fill_color = UIConfiguration::instance().color (string_compose ("%1: fill active", name), &failed);
1356 Gtkmm2ext::rounded_rectangle (cr, .5, -1.5, width - 1, height + 1, 7);
1357 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1358 cairo_set_line_width(cr, 1.0);
1359 ArdourCanvas::set_source_rgb_a (cr, fill_color, 1.0);
1366 ProcessorEntry::LuaPluginDisplay::LuaPluginDisplay (boost::shared_ptr<ARDOUR::LuaProc> p, uint32_t max_height)
1367 : PluginDisplay (p, max_height)
1369 , _lua_render_inline (0)
1371 p->setup_lua_inline_gui (&lua_gui);
1373 lua_State* LG = lua_gui.getState ();
1374 LuaInstance::bind_cairo (LG);
1375 luabridge::LuaRef lua_render = luabridge::getGlobal (LG, "render_inline");
1376 assert (lua_render.isFunction ());
1377 _lua_render_inline = new luabridge::LuaRef (lua_render);
1380 ProcessorEntry::LuaPluginDisplay::~LuaPluginDisplay ()
1382 delete (_lua_render_inline);
1386 ProcessorEntry::LuaPluginDisplay::render_inline (cairo_t *cr, uint32_t width)
1388 Cairo::Context ctx (cr);
1390 luabridge::LuaRef rv = (*_lua_render_inline)((Cairo::Context *)&ctx, width, _max_height);
1391 if (rv.isTable ()) {
1395 } catch (luabridge::LuaException const& e) {
1402 static std::list<Gtk::TargetEntry> drop_targets()
1404 std::list<Gtk::TargetEntry> tmp;
1405 tmp.push_back (Gtk::TargetEntry ("processor")); // from processor-box to processor-box
1406 tmp.push_back (Gtk::TargetEntry ("PluginInfoPtr")); // from plugin-manager
1407 tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr")); // from sidebar
1411 static std::list<Gtk::TargetEntry> drag_targets()
1413 std::list<Gtk::TargetEntry> tmp;
1414 tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr")); // to sidebar (optional preset)
1415 tmp.push_back (Gtk::TargetEntry ("processor")); // to processor-box (copy)
1419 static std::list<Gtk::TargetEntry> drag_targets_noplugin()
1421 std::list<Gtk::TargetEntry> tmp;
1422 tmp.push_back (Gtk::TargetEntry ("processor")); // to processor box (sends, faders re-order)
1426 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
1427 RouteProcessorSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
1428 : _parent_strip (parent)
1429 , _owner_is_mixer (owner_is_mixer)
1430 , ab_direction (true)
1431 , _get_plugin_selector (get_plugin_selector)
1433 , _visible_prefader_processors (0)
1434 , _rr_selection(rsel)
1435 , processor_display (drop_targets())
1436 , _redisplay_pending (false)
1440 /* ProcessorBox actions and bindings created statically by call to
1441 * ProcessorBox::register_actions(), made by ARDOUR_UI so that actions
1442 * are available for context menus.
1445 processor_display.set_data ("ardour-bindings", bindings);
1449 no_processor_redisplay = false;
1451 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
1452 processor_scroller.add (processor_display);
1453 pack_start (processor_scroller, true, true);
1455 processor_display.set_flags (CAN_FOCUS);
1456 processor_display.set_name ("ProcessorList");
1457 processor_display.set_data ("processorbox", this);
1458 processor_display.set_size_request (48, -1);
1459 processor_display.set_spacing (0);
1461 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
1462 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
1464 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
1465 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
1467 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
1468 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
1469 processor_display.DropFromExternal.connect (sigc::mem_fun (*this, &ProcessorBox::plugin_drop));
1471 processor_scroller.show ();
1472 processor_display.show ();
1475 parent->DeliveryChanged.connect (
1476 _mixer_strip_connections, invalidator (*this), boost::bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
1480 ARDOUR_UI_UTILS::set_tooltip (processor_display, _("Right-click to add/remove/edit\nplugins,inserts,sends and more"));
1483 ProcessorBox::~ProcessorBox ()
1485 /* it may appear as if we should delete processor_menu but that is a
1486 * pointer to a widget owned by the UI Manager, and has potentially
1487 * be returned to many other ProcessorBoxes. GTK doesn't really make
1488 * clear the ownership of this widget, which is a menu and thus is
1489 * never packed into any container other than an implict GtkWindow.
1491 * For now, until or if we ever get clarification over the ownership
1492 * story just let it continue to exist. At worst, its a small memory leak.
1497 ProcessorBox::set_route (boost::shared_ptr<Route> r)
1503 _route_connections.drop_connections();
1505 /* new route: any existing block on processor redisplay must be meaningless */
1506 no_processor_redisplay = false;
1509 _route->processors_changed.connect (
1510 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
1513 _route->DropReferences.connect (
1514 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
1517 _route->PropertyChanged.connect (
1518 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
1521 redisplay_processors ();
1525 ProcessorBox::route_going_away ()
1527 /* don't keep updating display as processors are deleted */
1528 no_processor_redisplay = true;
1532 boost::shared_ptr<Processor>
1533 ProcessorBox::find_drop_position (ProcessorEntry* position)
1535 boost::shared_ptr<Processor> p;
1537 p = position->processor ();
1539 /* dropped on the blank entry (which will be before the
1540 fader), so use the first non-blank child as our
1541 `dropped on' processor */
1542 list<ProcessorEntry*> c = processor_display.children ();
1543 list<ProcessorEntry*>::iterator i = c.begin ();
1545 assert (i != c.end ());
1546 p = (*i)->processor ();
1554 ProcessorBox::_drop_plugin_preset (Gtk::SelectionData const &data, Route::ProcessorList &pl)
1556 const void * d = data.get_data();
1557 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
1559 PluginPresetList nfos;
1561 tv->get_object_drag_data (nfos, &source);
1563 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1564 PluginPresetPtr ppp = (*i);
1565 PluginInfoPtr pip = ppp->_pip;
1566 PluginPtr p = pip->load (*_session);
1571 if (ppp->_preset.valid) {
1572 p->load_preset (ppp->_preset);
1575 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
1576 if (Config->get_new_plugins_active ()) {
1577 processor->activate ();
1579 pl.push_back (processor);
1584 ProcessorBox::_drop_plugin (Gtk::SelectionData const &data, Route::ProcessorList &pl)
1586 const void * d = data.get_data();
1587 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>*>(d);
1588 PluginInfoList nfos;
1591 tv->get_object_drag_data (nfos, &source);
1593 for (list<PluginInfoPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1594 PluginPtr p = (*i)->load (*_session);
1598 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
1599 if (Config->get_new_plugins_active ()) {
1600 processor->activate ();
1602 pl.push_back (processor);
1607 ProcessorBox::plugin_drop (Gtk::SelectionData const &data, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
1613 boost::shared_ptr<Processor> p = find_drop_position (position);
1614 Route::ProcessorList pl;
1616 if (data.get_target() == "PluginInfoPtr") {
1617 _drop_plugin (data, pl);
1619 else if (data.get_target() == "PluginPresetPtr") {
1620 _drop_plugin_preset (data, pl);
1626 Route::ProcessorStreams err;
1627 if (_route->add_processors (pl, p, &err)) {
1629 "Processor Drag/Drop failed. Probably because\n\
1630 the I/O configuration of the plugins could\n\
1631 not match the configuration of this track.");
1632 MessageDialog am (msg);
1638 ProcessorBox::object_drop (DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
1640 if (Gdk::ACTION_LINK == context->get_selected_action()) {
1641 list<ProcessorEntry*> children = source->selection ();
1642 assert (children.size() == 1);
1643 ProcessorEntry* other = *children.begin();
1644 assert (other->can_copy_state (position));
1645 boost::shared_ptr<ARDOUR::Processor> otherproc = other->processor();
1646 boost::shared_ptr<ARDOUR::Processor> proc = position->processor();
1647 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (proc);
1648 assert (otherproc && proc && pi);
1650 PBD::ID id = pi->id();
1651 XMLNode& state = otherproc->get_state ();
1652 proc->set_state (state, Stateful::loading_state_version);
1653 boost::dynamic_pointer_cast<PluginInsert>(proc)->update_id (id);
1657 boost::shared_ptr<Processor> p = find_drop_position (position);
1659 list<ProcessorEntry*> children = source->selection ();
1660 list<boost::shared_ptr<Processor> > procs;
1661 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
1662 if ((*i)->processor ()) {
1663 if (boost::dynamic_pointer_cast<UnknownProcessor> ((*i)->processor())) {
1666 procs.push_back ((*i)->processor ());
1670 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
1671 XMLNode& state = (*i)->get_state ();
1673 nlist.push_back (&state);
1674 paste_processor_state (nlist, p);
1678 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
1682 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
1683 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
1685 other->delete_dragged_processors (procs);
1691 ProcessorBox::set_width (Width w)
1699 list<ProcessorEntry*> children = processor_display.children ();
1700 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1701 (*i)->set_enum_width (w);
1708 ProcessorBox::build_possible_aux_menu ()
1710 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
1713 /* No aux sends if there are no busses */
1717 if (_route->is_monitor ()) {
1721 using namespace Menu_Helpers;
1722 Menu* menu = manage (new Menu);
1723 MenuList& items = menu->items();
1725 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
1726 if (!_route->internal_send_for (*r) && *r != _route) {
1727 items.push_back (MenuElem ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
1735 ProcessorBox::show_processor_menu (int arg)
1737 if (processor_menu == 0) {
1738 processor_menu = build_processor_menu ();
1739 processor_menu->signal_unmap().connect (sigc::mem_fun (*this, &ProcessorBox::processor_menu_unmapped));
1742 /* Sort out the plugin submenu */
1744 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newplugin"));
1746 if (plugin_menu_item) {
1747 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
1750 /* And the aux submenu */
1752 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newaux"));
1754 if (aux_menu_item) {
1755 Menu* m = build_possible_aux_menu();
1756 if (m && !m->items().empty()) {
1757 aux_menu_item->set_submenu (*m);
1758 aux_menu_item->set_sensitive (true);
1760 /* stupid gtkmm: we need to pass a null reference here */
1761 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
1762 aux_menu_item->set_sensitive (false);
1766 ActionManager::get_action (X_("ProcessorMenu"), "newinsert")->set_sensitive (!_route->is_monitor ());
1767 ActionManager::get_action (X_("ProcessorMenu"), "newsend")->set_sensitive (!_route->is_monitor ());
1769 ProcessorEntry* single_selection = 0;
1770 if (processor_display.selection().size() == 1) {
1771 single_selection = processor_display.selection().front();
1774 /* And the controls submenu */
1776 Gtk::MenuItem* controls_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/controls"));
1778 if (controls_menu_item) {
1779 if (single_selection) {
1780 Menu* m = single_selection->build_controls_menu ();
1781 if (m && !m->items().empty()) {
1782 controls_menu_item->set_submenu (*m);
1783 controls_menu_item->set_sensitive (true);
1785 gtk_menu_item_set_submenu (controls_menu_item->gobj(), 0);
1786 controls_menu_item->set_sensitive (false);
1789 controls_menu_item->set_sensitive (false);
1793 Gtk::MenuItem* send_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/send_options"));
1794 if (send_menu_item) {
1795 if (single_selection && !_route->is_monitor()) {
1796 Menu* m = single_selection->build_send_options_menu ();
1797 if (m && !m->items().empty()) {
1798 send_menu_item->set_submenu (*m);
1799 send_menu_item->set_sensitive (true);
1801 gtk_menu_item_set_submenu (send_menu_item->gobj(), 0);
1802 send_menu_item->set_sensitive (false);
1805 send_menu_item->set_sensitive (false);
1809 /* Sensitise actions as approprioate */
1812 const bool sensitive = !processor_display.selection().empty() && ! stub_processor_selected ();
1814 paste_action->set_sensitive (!_rr_selection.processors.empty());
1815 cut_action->set_sensitive (sensitive && can_cut ());
1816 copy_action->set_sensitive (sensitive);
1817 delete_action->set_sensitive (sensitive || stub_processor_selected ());
1819 edit_action->set_sensitive (one_processor_can_be_edited ());
1820 edit_generic_action->set_sensitive (one_processor_can_be_edited ());
1822 boost::shared_ptr<PluginInsert> pi;
1823 if (single_selection) {
1824 pi = boost::dynamic_pointer_cast<PluginInsert> (single_selection->processor ());
1827 manage_pins_action->set_sensitive (pi != 0);
1829 /* allow editing with an Ardour-generated UI for plugin inserts with editors */
1830 edit_action->set_sensitive (pi && pi->plugin()->has_editor ());
1832 /* disallow rename for multiple selections, for plugin inserts and for the fader */
1833 rename_action->set_sensitive (single_selection
1835 && !boost::dynamic_pointer_cast<Amp> (single_selection->processor ())
1836 && !boost::dynamic_pointer_cast<UnknownProcessor> (single_selection->processor ()));
1838 processor_menu->popup (1, arg);
1840 /* Add a placeholder gap to the processor list to indicate where a processor would be
1841 inserted were one chosen from the menu.
1844 processor_display.get_pointer (x, y);
1845 _placement = processor_display.add_placeholder (y);
1847 if (_visible_prefader_processors == 0 && _placement > 0) {
1853 ProcessorBox::enter_notify (GdkEventCrossing*)
1855 processor_display.grab_focus ();
1856 _current_processor_box = this;
1861 ProcessorBox::leave_notify (GdkEventCrossing* ev)
1863 if (ev->detail == GDK_NOTIFY_INFERIOR) {
1867 Widget* top = get_toplevel();
1869 if (top->is_toplevel()) {
1870 Window* win = dynamic_cast<Window*> (top);
1871 gtk_window_set_focus (win->gobj(), 0);
1878 ProcessorBox::processor_operation (ProcessorOperation op)
1880 ProcSelection targets;
1882 get_selected_processors (targets);
1884 /* if (targets.empty()) {
1887 processor_display.get_pointer (x, y);
1889 pair<ProcessorEntry *, double> const pointer = processor_display.get_child_at_position (y);
1891 if (pointer.first && pointer.first->processor()) {
1892 targets.push_back (pointer.first->processor ());
1897 if ((op == ProcessorsDelete) && targets.empty()) {
1898 return false; //nothing to delete. return false so the editor-mixer, because the user was probably intending to delete something in the editor
1902 case ProcessorsSelectAll:
1903 processor_display.select_all ();
1906 case ProcessorsSelectNone:
1907 processor_display.select_none ();
1910 case ProcessorsCopy:
1911 copy_processors (targets);
1915 cut_processors (targets);
1918 case ProcessorsPaste:
1919 // some processors are not selectable (e.g fader, meter), target is empty.
1920 if (targets.empty() && _placement >= 0) {
1922 boost::shared_ptr<Processor> proc = _route->before_processor_for_index (_placement);
1924 targets.push_back (proc);
1927 if (targets.empty()) {
1928 paste_processors ();
1930 paste_processors (targets.front());
1934 case ProcessorsDelete:
1935 delete_processors (targets);
1938 case ProcessorsToggleActive:
1939 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
1940 if ((*i)->active()) {
1941 (*i)->deactivate ();
1959 ProcessorWindowProxy*
1960 ProcessorBox::find_window_proxy (boost::shared_ptr<Processor> processor) const
1962 return processor->window_proxy();
1967 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
1969 boost::shared_ptr<Processor> processor;
1971 processor = child->processor ();
1975 bool selected = processor_display.selected (child);
1977 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
1979 if (_session->engine().connected()) {
1980 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
1982 if (!one_processor_can_be_edited ()) {
1986 if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
1987 generic_edit_processor (processor);
1989 edit_processor (processor);
1995 } else if (Keyboard::is_context_menu_event (ev)) {
1997 show_processor_menu (ev->time);
2001 } else if (processor && ev->button == 1 && selected) {
2003 // this is purely informational but necessary for route params UI
2004 ProcessorSelected (processor); // emit
2006 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
2009 _get_plugin_selector()->show_manager ();
2016 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
2018 boost::shared_ptr<Processor> processor;
2020 processor = child->processor ();
2023 if (processor && Keyboard::is_delete_event (ev)) {
2025 Glib::signal_idle().connect (sigc::bind (
2026 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
2027 boost::weak_ptr<Processor>(processor)));
2029 } else if (processor && Keyboard::is_button2_event (ev)
2031 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
2035 /* button2-click with no/appropriate modifiers */
2037 if (processor->active()) {
2038 processor->deactivate ();
2040 processor->activate ();
2048 ProcessorBox::build_processor_menu ()
2050 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/ProcessorMenu") );
2051 processor_menu->set_name ("ArdourContextMenu");
2052 return processor_menu;
2056 ProcessorBox::select_all_processors ()
2058 processor_display.select_all ();
2062 ProcessorBox::deselect_all_processors ()
2064 processor_display.select_none ();
2068 ProcessorBox::choose_plugin ()
2070 _get_plugin_selector()->set_interested_object (*this);
2073 /** @return true if an error occurred, otherwise false */
2075 ProcessorBox::choose_lua ()
2077 LuaScriptInfoPtr spi;
2079 ScriptSelector ss (_("Add Lua DSP Processor"), LuaScriptInfo::DSP);
2080 switch (ss.run ()) {
2081 case Gtk::RESPONSE_ACCEPT:
2091 LuaPluginInfoPtr lpi (new LuaPluginInfo(spi));
2092 p = (lpi->load (*_session));
2095 "Failed to instantiate Lua DSP Processor,\n"
2096 "probably because the script is invalid (no dsp function).");
2097 MessageDialog am (msg);
2102 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
2104 Route::ProcessorStreams err_streams;
2105 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
2107 "Failed to add Lua DSP Processor at the given position,\n"
2108 "probably because the I/O configuration of the plugins\n"
2109 "could not match the configuration of this track.");
2110 MessageDialog am (msg);
2116 /** @return true if an error occurred, otherwise false */
2118 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
2120 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
2122 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
2124 Route::ProcessorStreams err_streams;
2126 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
2127 weird_plugin_dialog (**p, err_streams);
2129 // XXX SHAREDPTR delete plugin here .. do we even need to care?
2130 } else if (plugins.size() == 1 && UIConfiguration::instance().get_open_gui_after_adding_plugin()) {
2131 if (boost::dynamic_pointer_cast<PluginInsert>(processor)->plugin()->has_inline_display() && UIConfiguration::instance().get_prefer_inline_over_gui()) {
2133 } else if (_session->engine().connected () && processor_can_be_edited (processor)) {
2134 if ((*p)->has_editor ()) {
2135 edit_processor (processor);
2137 generic_edit_processor (processor);
2147 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
2149 ArdourDialog dialog (_("Plugin Incompatibility"));
2152 string text = string_compose(_("You attempted to add the plugin \"%1\" in slot %2.\n"),
2153 p.name(), streams.index);
2155 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
2156 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
2158 text += _("\nThis plugin has:\n");
2160 uint32_t const n = p.get_info()->n_inputs.n_midi ();
2161 text += string_compose (ngettext ("\t%1 MIDI input\n", "\t%1 MIDI inputs\n", n), n);
2164 uint32_t const n = p.get_info()->n_inputs.n_audio ();
2165 text += string_compose (ngettext ("\t%1 audio input\n", "\t%1 audio inputs\n", n), n);
2168 text += _("\nbut at the insertion point, there are:\n");
2170 uint32_t const n = streams.count.n_midi ();
2171 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
2174 uint32_t const n = streams.count.n_audio ();
2175 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
2178 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
2179 label.set_text(text);
2181 dialog.get_vbox()->pack_start (label);
2182 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
2184 dialog.set_name (X_("PluginIODialog"));
2185 dialog.set_modal (true);
2192 ProcessorBox::choose_insert ()
2194 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->pannable(), _route->mute_master()));
2195 _route->add_processor_by_index (processor, _placement);
2198 /* Caller must not hold process lock */
2200 ProcessorBox::choose_send ()
2202 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
2203 boost::shared_ptr<Send> send (new Send (*_session, sendpan, _route->mute_master()));
2205 /* make an educated guess at the initial number of outputs for the send */
2206 ChanCount outs = (_session->master_out())
2207 ? _session->master_out()->n_outputs()
2208 : _route->n_outputs();
2210 /* XXX need processor lock on route */
2212 Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock());
2213 send->output()->ensure_io (outs, false, this);
2214 } catch (AudioEngine::PortRegistrationFailure& err) {
2215 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
2219 /* let the user adjust the IO setup before creation.
2221 Note: this dialog is NOT modal - we just leave it to run and it will
2222 return when its Finished signal is emitted - typically when the window
2226 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
2229 /* keep a reference to the send so it doesn't get deleted while
2230 the IOSelectorWindow is doing its stuff
2232 _processor_being_created = send;
2234 ios->selector().Finished.connect (sigc::bind (
2235 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
2236 boost::weak_ptr<Processor>(send), ios));
2241 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
2243 boost::shared_ptr<Processor> processor (weak_processor.lock());
2245 /* drop our temporary reference to the new send */
2246 _processor_being_created.reset ();
2253 case IOSelector::Cancelled:
2254 // processor will go away when all shared_ptrs to it vanish
2257 case IOSelector::Accepted:
2258 _route->add_processor_by_index (processor, _placement);
2262 delete_when_idle (ios);
2266 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
2268 boost::shared_ptr<Processor> processor (weak_processor.lock());
2270 /* drop our temporary reference to the new return */
2271 _processor_being_created.reset ();
2278 case IOSelector::Cancelled:
2279 // processor will go away when all shared_ptrs to it vanish
2282 case IOSelector::Accepted:
2283 _route->add_processor_by_index (processor, _placement);
2287 delete_when_idle (ios);
2291 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
2297 boost::shared_ptr<Route> target = wr.lock();
2303 _session->add_internal_send (target, _placement, _route);
2307 ProcessorBox::route_processors_changed (RouteProcessorChange c)
2309 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
2310 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
2314 redisplay_processors ();
2318 ProcessorBox::redisplay_processors ()
2320 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors);
2323 if (no_processor_redisplay) {
2327 processor_display.clear ();
2329 _visible_prefader_processors = 0;
2332 _route->foreach_processor (sigc::bind (sigc::mem_fun (*this, &ProcessorBox::help_count_visible_prefader_processors),
2333 &_visible_prefader_processors, &fader_seen));
2335 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
2336 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
2337 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_pin_mgr));
2338 setup_entry_positions ();
2341 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
2342 * not already have one.
2345 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
2347 boost::shared_ptr<Processor> p = w.lock ();
2351 if (p->window_proxy()) {
2355 /* not on the list; add it */
2358 #if 0 // is this still needed? Why?
2359 if (_parent_strip) {
2360 if (_parent_strip->mixer_owned()) {
2372 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
2373 string_compose ("%1-%2-%3", loc, _route->id(), p->id()),
2377 const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
2380 wp->set_state (*ui_xml, 0);
2383 void* existing_ui = p->get_ui ();
2386 wp->use_window (*(reinterpret_cast<Gtk::Window*>(existing_ui)));
2389 p->set_window_proxy (wp);
2390 WM::Manager::instance().register_window (wp);
2394 ProcessorBox::maybe_add_processor_pin_mgr (boost::weak_ptr<Processor> w)
2396 boost::shared_ptr<Processor> p = w.lock ();
2397 if (!p || p->pinmgr_proxy ()) {
2401 PluginPinWindowProxy* wp = new PluginPinWindowProxy (
2402 string_compose ("PM-%2-%3", _route->id(), p->id()), w);
2404 const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
2406 wp->set_state (*ui_xml, 0);
2409 void* existing_ui = p->get_ui ();
2412 wp->use_window (*(reinterpret_cast<Gtk::Window*>(existing_ui)));
2415 p->set_pingmgr_proxy (wp);
2416 WM::Manager::instance().register_window (wp);
2419 ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor> p, uint32_t* cnt, bool* amp_seen)
2421 boost::shared_ptr<Processor> processor (p.lock ());
2423 if (processor && ( processor->display_to_user()
2425 || show_all_processors
2430 if (boost::dynamic_pointer_cast<Amp>(processor) &&
2431 boost::dynamic_pointer_cast<Amp>(processor)->gain_control()->parameter().type() == GainAutomation) {
2442 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
2444 boost::shared_ptr<Processor> processor (p.lock ());
2446 if (!processor || ( !processor->display_to_user()
2448 && !show_all_processors
2455 boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
2457 ProcessorEntry* e = 0;
2458 if (plugin_insert) {
2459 e = new PluginInsertProcessorEntry (this, plugin_insert, _width);
2461 e = new ProcessorEntry (this, processor, _width);
2464 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
2465 boost::shared_ptr<PortInsert> ext = boost::dynamic_pointer_cast<PortInsert> (processor);
2466 boost::shared_ptr<UnknownProcessor> stub = boost::dynamic_pointer_cast<UnknownProcessor> (processor);
2468 //faders and meters are not deletable, copy/paste-able, so they shouldn't be selectable
2469 if (!send && !plugin_insert && !ext && !stub)
2470 e->set_selectable(false);
2472 bool mark_send_visible = false;
2473 if (send && _parent_strip) {
2474 /* show controls of new sends by default */
2475 GUIObjectState& st = _parent_strip->gui_object_state ();
2476 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
2478 /* check if state exists, if not it must be a new send */
2479 if (!st.get_node(strip, e->state_id())) {
2480 mark_send_visible = true;
2484 /* Set up this entry's state from the GUIObjectState */
2485 XMLNode* proc = entry_gui_object_state (e);
2487 e->set_control_state (proc);
2490 if (mark_send_visible) {
2491 e->show_all_controls ();
2496 && !plugin_insert->plugin(0)->is_channelstrip()
2500 processor_display.add_child (e, drag_targets());
2502 processor_display.add_child (e, drag_targets_noplugin());
2507 ProcessorBox::reordered ()
2509 compute_processor_sort_keys ();
2510 setup_entry_positions ();
2514 ProcessorBox::setup_entry_positions ()
2516 list<ProcessorEntry*> children = processor_display.children ();
2517 bool pre_fader = true;
2520 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2521 if (boost::dynamic_pointer_cast<Amp>((*i)->processor()) &&
2522 boost::dynamic_pointer_cast<Amp>((*i)->processor())->gain_control()->parameter().type() == GainAutomation) {
2524 (*i)->set_position (ProcessorEntry::Fader, num++);
2527 (*i)->set_position (ProcessorEntry::PreFader, num++);
2529 (*i)->set_position (ProcessorEntry::PostFader, num++);
2536 ProcessorBox::compute_processor_sort_keys ()
2538 list<ProcessorEntry*> children = processor_display.children ();
2539 Route::ProcessorList our_processors;
2541 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2542 if ((*i)->processor()) {
2543 our_processors.push_back ((*i)->processor ());
2547 if (_route->reorder_processors (our_processors)) {
2548 /* Reorder failed, so report this to the user. As far as I can see this must be done
2549 in an idle handler: it seems that the redisplay_processors() that happens below destroys
2550 widgets that were involved in the drag-and-drop on the processor list, which causes problems
2551 when the drag is torn down after this handler function is finished.
2553 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
2558 ProcessorBox::report_failed_reorder ()
2560 /* reorder failed, so redisplay */
2562 redisplay_processors ();
2564 /* now tell them about the problem */
2566 ArdourDialog dialog (_("Plugin Incompatibility"));
2569 label.set_text (_("\
2570 You cannot reorder these plugins/sends/inserts\n\
2571 in that way because the inputs and\n\
2572 outputs will not work correctly."));
2574 dialog.get_vbox()->set_border_width (12);
2575 dialog.get_vbox()->pack_start (label);
2576 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
2578 dialog.set_name (X_("PluginIODialog"));
2579 dialog.set_modal (true);
2586 ProcessorBox::rename_processors ()
2588 ProcSelection to_be_renamed;
2590 get_selected_processors (to_be_renamed);
2592 if (to_be_renamed.empty()) {
2596 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
2597 rename_processor (*i);
2602 ProcessorBox::can_cut () const
2604 vector<boost::shared_ptr<Processor> > sel;
2606 get_selected_processors (sel);
2608 /* cut_processors () does not cut inserts */
2610 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
2612 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
2613 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
2614 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
2623 ProcessorBox::stub_processor_selected () const
2625 vector<boost::shared_ptr<Processor> > sel;
2627 get_selected_processors (sel);
2629 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
2630 if (boost::dynamic_pointer_cast<UnknownProcessor>((*i)) != 0) {
2639 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
2641 if (to_be_removed.empty()) {
2645 XMLNode* node = new XMLNode (X_("cut"));
2646 Route::ProcessorList to_cut;
2648 no_processor_redisplay = true;
2649 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
2650 // Cut only plugins, sends and returns
2651 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
2652 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
2653 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
2655 Window* w = get_processor_ui (*i);
2661 XMLNode& child ((*i)->get_state());
2662 node->add_child_nocopy (child);
2663 to_cut.push_back (*i);
2667 if (_route->remove_processors (to_cut) != 0) {
2669 no_processor_redisplay = false;
2673 _rr_selection.set (node);
2675 no_processor_redisplay = false;
2676 redisplay_processors ();
2680 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
2682 if (to_be_copied.empty()) {
2686 XMLNode* node = new XMLNode (X_("copy"));
2688 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
2689 // Copy only plugins, sends, returns
2690 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
2691 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
2692 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
2693 node->add_child_nocopy ((*i)->get_state());
2697 _rr_selection.set (node);
2701 ProcessorBox::delete_processors (const ProcSelection& targets)
2703 if (targets.empty()) {
2707 no_processor_redisplay = true;
2709 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
2711 Window* w = get_processor_ui (*i);
2717 _route->remove_processor(*i);
2720 no_processor_redisplay = false;
2721 redisplay_processors ();
2725 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
2727 list<boost::shared_ptr<Processor> >::const_iterator x;
2729 no_processor_redisplay = true;
2730 for (x = procs.begin(); x != procs.end(); ++x) {
2732 Window* w = get_processor_ui (*x);
2738 _route->remove_processor(*x);
2741 no_processor_redisplay = false;
2742 redisplay_processors ();
2746 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
2748 boost::shared_ptr<Processor> processor (weak_processor.lock());
2754 /* NOT copied to _mixer.selection() */
2756 no_processor_redisplay = true;
2757 _route->remove_processor (processor);
2758 no_processor_redisplay = false;
2759 redisplay_processors ();
2765 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
2767 ArdourPrompter name_prompter (true);
2769 name_prompter.set_title (_("Rename Processor"));
2770 name_prompter.set_prompt (_("New name:"));
2771 name_prompter.set_initial_text (processor->name());
2772 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
2773 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
2774 name_prompter.show_all ();
2776 switch (name_prompter.run ()) {
2778 case Gtk::RESPONSE_ACCEPT:
2779 name_prompter.get_result (result);
2780 if (result.length()) {
2783 string test = result;
2785 while (tries < 100) {
2786 if (_session->io_name_is_legal (test)) {
2792 test = string_compose ("%1-%2", result, tries);
2796 processor->set_name (result);
2799 ARDOUR_UI::instance()->popup_error
2800 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
2810 ProcessorBox::paste_processors ()
2812 if (_rr_selection.processors.empty()) {
2816 paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
2820 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
2823 if (_rr_selection.processors.empty()) {
2827 paste_processor_state (_rr_selection.processors.get_node().children(), before);
2831 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
2833 XMLNodeConstIterator niter;
2834 list<boost::shared_ptr<Processor> > copies;
2836 if (nlist.empty()) {
2840 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2842 XMLProperty const * type = (*niter)->property ("type");
2843 XMLProperty const * role = (*niter)->property ("role");
2846 boost::shared_ptr<Processor> p;
2848 if (type->value() == "meter" ||
2849 type->value() == "main-outs" ||
2850 type->value() == "amp" ||
2851 type->value() == "intreturn") {
2852 /* do not paste meter, main outs, amp or internal returns */
2855 } else if (type->value() == "intsend") {
2857 /* aux sends are OK, but those used for
2858 * other purposes, are not.
2863 if (role->value() != "Aux") {
2867 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
2868 XMLNode n (**niter);
2869 InternalSend* s = new InternalSend (*_session, sendpan, _route->mute_master(),
2870 _route, boost::shared_ptr<Route>(), Delivery::Aux);
2872 IOProcessor::prepare_for_reset (n, s->name());
2874 if (s->set_state (n, Stateful::loading_state_version)) {
2881 } else if (type->value() == "send") {
2883 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
2884 XMLNode n (**niter);
2886 Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
2888 IOProcessor::prepare_for_reset (n, s->name());
2890 if (s->set_state (n, Stateful::loading_state_version)) {
2897 } else if (type->value() == "return") {
2899 XMLNode n (**niter);
2900 Return* r = new Return (*_session);
2902 IOProcessor::prepare_for_reset (n, r->name());
2904 if (r->set_state (n, Stateful::loading_state_version)) {
2911 } else if (type->value() == "port") {
2913 XMLNode n (**niter);
2914 PortInsert* pi = new PortInsert (*_session, _route->pannable (), _route->mute_master ());
2916 IOProcessor::prepare_for_reset (n, pi->name());
2918 if (pi->set_state (n, Stateful::loading_state_version)) {
2924 /* XXX its a bit limiting to assume that everything else
2927 p.reset (new PluginInsert (*_session));
2928 PBD::ID id = p->id();
2929 p->set_state (**niter, Stateful::current_state_version);
2930 boost::dynamic_pointer_cast<PluginInsert>(p)->update_id (id);
2933 copies.push_back (p);
2937 error << _("plugin insert constructor failed") << endmsg;
2941 if (copies.empty()) {
2945 if (_route->add_processors (copies, p)) {
2948 "Copying the set of processors on the clipboard failed,\n\
2949 probably because the I/O configuration of the plugins\n\
2950 could not match the configuration of this track.");
2951 MessageDialog am (msg);
2957 ProcessorBox::get_selected_processors (ProcSelection& processors) const
2959 const list<ProcessorEntry*> selection = processor_display.selection ();
2960 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
2961 processors.push_back ((*i)->processor ());
2966 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
2968 list<ProcessorEntry*> selection = processor_display.selection ();
2969 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
2970 (this->*method) ((*i)->processor ());
2975 ProcessorBox::all_visible_processors_active (bool state)
2977 _route->all_visible_processors_active (state);
2981 ProcessorBox::ab_plugins ()
2983 _route->ab_plugins (ab_direction);
2984 ab_direction = !ab_direction;
2989 ProcessorBox::clear_processors ()
2992 vector<string> choices;
2994 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
2995 "(this cannot be undone)"), _route->name());
2997 choices.push_back (_("Cancel"));
2998 choices.push_back (_("Yes, remove them all"));
3000 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
3002 if (prompter.run () == 1) {
3003 _route->clear_processors (PreFader);
3004 _route->clear_processors (PostFader);
3009 ProcessorBox::clear_processors (Placement p)
3012 vector<string> choices;
3014 if (p == PreFader) {
3015 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
3016 "(this cannot be undone)"), _route->name());
3018 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
3019 "(this cannot be undone)"), _route->name());
3022 choices.push_back (_("Cancel"));
3023 choices.push_back (_("Yes, remove them all"));
3025 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
3027 if (prompter.run () == 1) {
3028 _route->clear_processors (p);
3033 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
3035 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
3036 if (at && at->freeze_state() == AudioTrack::Frozen) {
3041 boost::dynamic_pointer_cast<Send> (processor) ||
3042 boost::dynamic_pointer_cast<Return> (processor) ||
3043 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
3044 boost::dynamic_pointer_cast<PortInsert> (processor)
3053 ProcessorBox::one_processor_can_be_edited ()
3055 list<ProcessorEntry*> selection = processor_display.selection ();
3056 list<ProcessorEntry*>::iterator i = selection.begin();
3057 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
3061 return (i != selection.end());
3065 ProcessorBox::get_editor_window (boost::shared_ptr<Processor> processor, bool use_custom)
3067 boost::shared_ptr<Send> send;
3068 boost::shared_ptr<InternalSend> internal_send;
3069 boost::shared_ptr<Return> retrn;
3070 boost::shared_ptr<PluginInsert> plugin_insert;
3071 boost::shared_ptr<PortInsert> port_insert;
3074 /* This method may or may not return a Window, but if it does not it
3075 * will modify the parent mixer strip appearance layout to allow
3076 * "editing" the @param processor that was passed in.
3078 * So for example, if the processor is an Amp (gain), the parent strip
3079 * will be forced back into a model where the fader controls the main gain.
3080 * If the processor is a send, then we map the send controls onto the
3083 * Plugins and others will return a window for control.
3086 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
3088 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
3093 if (boost::dynamic_pointer_cast<Amp> (processor) && boost::dynamic_pointer_cast<Amp> (processor)->gain_control()->parameter().type() == GainAutomation) {
3095 if (_parent_strip) {
3096 _parent_strip->revert_to_default_display ();
3099 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
3101 if (!_session->engine().connected()) {
3105 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
3107 gidget = new SendUIWindow (send, _session);
3110 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
3112 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
3113 /* no GUI for these */
3117 if (!_session->engine().connected()) {
3121 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
3123 ReturnUIWindow *return_ui;
3124 Window* w = get_processor_ui (retrn);
3128 return_ui = new ReturnUIWindow (retrn, _session);
3129 return_ui->set_title (retrn->name ());
3130 set_processor_ui (send, return_ui);
3133 return_ui = dynamic_cast<ReturnUIWindow *> (w);
3138 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
3140 PluginUIWindow *plugin_ui;
3142 /* these are both allowed to be null */
3144 Window* w = get_processor_ui (plugin_insert);
3147 plugin_ui = new PluginUIWindow (plugin_insert, false, use_custom);
3148 plugin_ui->set_title (generate_processor_title (plugin_insert));
3149 set_processor_ui (plugin_insert, plugin_ui);
3152 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
3157 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
3159 if (!_session->engine().connected()) {
3160 MessageDialog msg ( _("Not connected to audio engine - no I/O changes are possible"));
3165 PortInsertWindow *io_selector;
3167 Window* w = get_processor_ui (port_insert);
3170 io_selector = new PortInsertWindow (_session, port_insert);
3171 set_processor_ui (port_insert, io_selector);
3174 io_selector = dynamic_cast<PortInsertWindow *> (w);
3177 gidget = io_selector;
3184 ProcessorBox::get_generic_editor_window (boost::shared_ptr<Processor> processor)
3186 boost::shared_ptr<PluginInsert> plugin_insert
3187 = boost::dynamic_pointer_cast<PluginInsert>(processor);
3189 if (!plugin_insert) {
3193 PluginUIWindow* win = new PluginUIWindow (plugin_insert, true, false);
3194 win->set_title (generate_processor_title (plugin_insert));
3200 ProcessorBox::register_actions ()
3202 processor_box_actions = myactions.create_action_group (X_("ProcessorMenu"));
3204 Glib::RefPtr<Action> act;
3207 myactions.register_action (processor_box_actions, X_("newplugin"), _("New Plugin"),
3208 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
3210 act = myactions.register_action (processor_box_actions, X_("newlua"), _("New Lua Proc"),
3211 sigc::ptr_fun (ProcessorBox::rb_choose_lua));
3212 act = myactions.register_action (processor_box_actions, X_("newinsert"), _("New Insert"),
3213 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
3214 ActionManager::engine_sensitive_actions.push_back (act);
3215 act = myactions.register_action (processor_box_actions, X_("newsend"), _("New External Send ..."),
3216 sigc::ptr_fun (ProcessorBox::rb_choose_send));
3217 ActionManager::engine_sensitive_actions.push_back (act);
3219 myactions.register_action (processor_box_actions, X_("newaux"), _("New Aux Send ..."));
3221 myactions.register_action (processor_box_actions, X_("controls"), _("Controls"));
3222 myactions.register_action (processor_box_actions, X_("send_options"), _("Send Options"));
3224 myactions.register_action (processor_box_actions, X_("clear"), _("Clear (all)"),
3225 sigc::ptr_fun (ProcessorBox::rb_clear));
3226 myactions.register_action (processor_box_actions, X_("clear_pre"), _("Clear (pre-fader)"),
3227 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
3228 myactions.register_action (processor_box_actions, X_("clear_post"), _("Clear (post-fader)"),
3229 sigc::ptr_fun (ProcessorBox::rb_clear_post));
3231 /* standard editing stuff */
3233 cut_action = myactions.register_action (processor_box_actions, X_("cut"), _("Cut"),
3234 sigc::ptr_fun (ProcessorBox::rb_cut));
3235 copy_action = myactions.register_action (processor_box_actions, X_("copy"), _("Copy"),
3236 sigc::ptr_fun (ProcessorBox::rb_copy));
3237 delete_action = myactions.register_action (processor_box_actions, X_("delete"), _("Delete"),
3238 sigc::ptr_fun (ProcessorBox::rb_delete));
3240 ActionManager::plugin_selection_sensitive_actions.push_back (cut_action);
3241 ActionManager::plugin_selection_sensitive_actions.push_back (copy_action);
3242 ActionManager::plugin_selection_sensitive_actions.push_back (delete_action);
3244 paste_action = myactions.register_action (processor_box_actions, X_("paste"), _("Paste"),
3245 sigc::ptr_fun (ProcessorBox::rb_paste));
3246 rename_action = myactions.register_action (processor_box_actions, X_("rename"), _("Rename"),
3247 sigc::ptr_fun (ProcessorBox::rb_rename));
3248 myactions.register_action (processor_box_actions, X_("selectall"), _("Select All"),
3249 sigc::ptr_fun (ProcessorBox::rb_select_all));
3250 myactions.register_action (processor_box_actions, X_("deselectall"), _("Deselect All"),
3251 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
3253 /* activation etc. */
3255 myactions.register_action (processor_box_actions, X_("activate_all"), _("Activate All"),
3256 sigc::ptr_fun (ProcessorBox::rb_activate_all));
3257 myactions.register_action (processor_box_actions, X_("deactivate_all"), _("Deactivate All"),
3258 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
3259 myactions.register_action (processor_box_actions, X_("ab_plugins"), _("A/B Plugins"),
3260 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
3262 manage_pins_action = myactions.register_action (
3263 processor_box_actions, X_("manage-pins"), _("Pin Management..."),
3264 sigc::ptr_fun (ProcessorBox::rb_manage_pins));
3267 edit_action = myactions.register_action (
3268 processor_box_actions, X_("edit"), _("Edit..."),
3269 sigc::ptr_fun (ProcessorBox::rb_edit));
3271 edit_generic_action = myactions.register_action (
3272 processor_box_actions, X_("edit-generic"), _("Edit with generic controls..."),
3273 sigc::ptr_fun (ProcessorBox::rb_edit_generic));
3279 ProcessorBox::rb_edit_generic ()
3281 if (_current_processor_box == 0) {
3285 _current_processor_box->for_selected_processors (&ProcessorBox::generic_edit_processor);
3289 ProcessorBox::rb_ab_plugins ()
3291 if (_current_processor_box == 0) {
3295 _current_processor_box->ab_plugins ();
3299 ProcessorBox::rb_manage_pins ()
3301 if (_current_processor_box == 0) {
3305 _current_processor_box->for_selected_processors (&ProcessorBox::manage_pins);
3308 ProcessorBox::rb_choose_plugin ()
3310 if (_current_processor_box == 0) {
3313 _current_processor_box->choose_plugin ();
3317 ProcessorBox::rb_choose_lua ()
3319 if (_current_processor_box == 0) {
3322 _current_processor_box->choose_lua ();
3326 ProcessorBox::rb_choose_insert ()
3328 if (_current_processor_box == 0) {
3331 _current_processor_box->choose_insert ();
3335 ProcessorBox::rb_choose_send ()
3337 if (_current_processor_box == 0) {
3340 _current_processor_box->choose_send ();
3344 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
3346 if (_current_processor_box == 0) {
3350 _current_processor_box->choose_aux (wr);
3354 ProcessorBox::rb_clear ()
3356 if (_current_processor_box == 0) {
3360 _current_processor_box->clear_processors ();
3365 ProcessorBox::rb_clear_pre ()
3367 if (_current_processor_box == 0) {
3371 _current_processor_box->clear_processors (PreFader);
3376 ProcessorBox::rb_clear_post ()
3378 if (_current_processor_box == 0) {
3382 _current_processor_box->clear_processors (PostFader);
3386 ProcessorBox::rb_cut ()
3388 if (_current_processor_box == 0) {
3392 _current_processor_box->processor_operation (ProcessorsCut);
3396 ProcessorBox::rb_delete ()
3398 if (_current_processor_box == 0) {
3402 _current_processor_box->processor_operation (ProcessorsDelete);
3406 ProcessorBox::rb_copy ()
3408 if (_current_processor_box == 0) {
3411 _current_processor_box->processor_operation (ProcessorsCopy);
3415 ProcessorBox::rb_paste ()
3417 if (_current_processor_box == 0) {
3421 _current_processor_box->processor_operation (ProcessorsPaste);
3425 ProcessorBox::rb_rename ()
3427 if (_current_processor_box == 0) {
3430 _current_processor_box->rename_processors ();
3434 ProcessorBox::rb_select_all ()
3436 if (_current_processor_box == 0) {
3440 _current_processor_box->processor_operation (ProcessorsSelectAll);
3444 ProcessorBox::rb_deselect_all ()
3446 if (_current_processor_box == 0) {
3450 _current_processor_box->deselect_all_processors ();
3454 ProcessorBox::rb_activate_all ()
3456 if (_current_processor_box == 0) {
3460 _current_processor_box->all_visible_processors_active (true);
3464 ProcessorBox::rb_deactivate_all ()
3466 if (_current_processor_box == 0) {
3469 _current_processor_box->all_visible_processors_active (false);
3473 ProcessorBox::rb_edit ()
3475 if (_current_processor_box == 0) {
3479 _current_processor_box->for_selected_processors (&ProcessorBox::edit_processor);
3483 ProcessorBox::edit_aux_send (boost::shared_ptr<Processor> processor)
3485 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
3489 if (_parent_strip) {
3490 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
3491 if (_parent_strip->current_delivery() == send) {
3492 _parent_strip->revert_to_default_display ();
3494 _parent_strip->show_send(send);
3501 ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
3506 if (edit_aux_send (processor)) {
3510 ProcessorWindowProxy* proxy = find_window_proxy (processor);
3513 proxy->set_custom_ui_mode (true);
3514 proxy->show_the_right_window ();
3519 ProcessorBox::generic_edit_processor (boost::shared_ptr<Processor> processor)
3524 if (edit_aux_send (processor)) {
3528 ProcessorWindowProxy* proxy = find_window_proxy (processor);
3531 proxy->set_custom_ui_mode (false);
3532 proxy->show_the_right_window ();
3537 ProcessorBox::manage_pins (boost::shared_ptr<Processor> processor)
3542 PluginPinWindowProxy* proxy = processor->pinmgr_proxy ();
3551 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
3553 if (!what_changed.contains (ARDOUR::Properties::name)) {
3557 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
3559 boost::shared_ptr<Processor> processor;
3560 boost::shared_ptr<PluginInsert> plugin_insert;
3561 boost::shared_ptr<Send> send;
3563 list<ProcessorEntry*> children = processor_display.children();
3565 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
3567 processor = (*iter)->processor ();
3573 Window* w = get_processor_ui (processor);
3579 /* rename editor windows for sends and plugins */
3581 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
3582 w->set_title (send->name ());
3583 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
3584 w->set_title (generate_processor_title (plugin_insert));
3590 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
3592 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
3593 string::size_type email_pos;
3595 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
3596 maker = maker.substr (0, email_pos - 1);
3599 if (maker.length() > 32) {
3600 maker = maker.substr (0, 32);
3604 SessionObject* owner = pi->owner();
3607 return string_compose(_("%1: %2 (by %3)"), owner->name(), pi->name(), maker);
3609 return string_compose(_("%1 (by %2)"), pi->name(), maker);
3613 /** @param p Processor.
3614 * @return the UI window for \a p.
3617 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
3619 ProcessorWindowProxy* wp = p->window_proxy();
3626 /** Make a note of the UI window that a processor is using.
3627 * @param p Processor.
3628 * @param w UI window.
3631 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
3633 assert (p->window_proxy());
3635 p->window_proxy()->use_window (*w);
3639 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
3641 boost::shared_ptr<Delivery> d = w.lock ();
3646 list<ProcessorEntry*> children = processor_display.children ();
3647 list<ProcessorEntry*>::const_iterator i = children.begin();
3648 while (i != children.end() && (*i)->processor() != d) {
3652 if (i == children.end()) {
3653 processor_display.set_active (0);
3655 processor_display.set_active (*i);
3659 /** Called to repair the damage of Editor::show_window doing a show_all() */
3661 ProcessorBox::hide_things ()
3663 list<ProcessorEntry*> c = processor_display.children ();
3664 for (list<ProcessorEntry*>::iterator i = c.begin(); i != c.end(); ++i) {
3665 (*i)->hide_things ();
3670 ProcessorBox::processor_menu_unmapped ()
3672 processor_display.remove_placeholder ();
3673 /* make all possibly-desensitized actions sensitive again so that
3674 they be activated by other means (e.g. bindings)
3676 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, true);
3680 ProcessorBox::entry_gui_object_state (ProcessorEntry* entry)
3682 if (!_parent_strip) {
3686 GUIObjectState& st = _parent_strip->gui_object_state ();
3688 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
3690 return st.get_or_add_node (strip, entry->state_id());
3694 ProcessorBox::update_gui_object_state (ProcessorEntry* entry)
3696 XMLNode* proc = entry_gui_object_state (entry);
3701 /* XXX: this is a bit inefficient; we just remove all child nodes and re-add them */
3702 proc->remove_nodes_and_delete (X_("Object"));
3703 entry->add_control_state (proc);
3707 ProcessorBox::is_editor_mixer_strip() const
3709 return _parent_strip && !_parent_strip->mixer_owned();
3712 ProcessorWindowProxy::ProcessorWindowProxy (string const & name, ProcessorBox* box, boost::weak_ptr<Processor> processor)
3713 : WM::ProxyBase (name, string())
3714 , _processor_box (box)
3715 , _processor (processor)
3717 , want_custom (false)
3719 boost::shared_ptr<Processor> p = _processor.lock ();
3723 p->DropReferences.connect (going_away_connection, MISSING_INVALIDATOR, boost::bind (&ProcessorWindowProxy::processor_going_away, this), gui_context());
3726 ProcessorWindowProxy::~ProcessorWindowProxy()
3728 /* processor window proxies do not own the windows they create with
3729 * ::get(), so set _window to null before the normal WindowProxy method
3736 ProcessorWindowProxy::processor_going_away ()
3740 WM::Manager::instance().remove (this);
3741 /* should be no real reason to do this, since the object that would
3742 send DropReferences is about to be deleted, but lets do it anyway.
3744 going_away_connection.disconnect();
3747 ARDOUR::SessionHandlePtr*
3748 ProcessorWindowProxy::session_handle()
3755 ProcessorWindowProxy::get_state ()
3758 node = &ProxyBase::get_state();
3759 node->add_property (X_("custom-ui"), is_custom? X_("yes") : X_("no"));
3764 ProcessorWindowProxy::set_state (const XMLNode& node, int /*version*/)
3766 XMLNodeList children = node.children ();
3767 XMLNodeList::const_iterator i = children.begin ();
3768 while (i != children.end()) {
3769 XMLProperty* prop = (*i)->property (X_("name"));
3770 if ((*i)->name() == X_("Window") && prop && prop->value() == _name) {
3776 if (i != children.end()) {
3778 if ((prop = (*i)->property (X_("custom-ui"))) != 0) {
3779 want_custom = PBD::string_is_affirmative (prop->value ());
3783 return ProxyBase::set_state (node, 0);
3787 ProcessorWindowProxy::get (bool create)
3789 boost::shared_ptr<Processor> p = _processor.lock ();
3794 if (_window && (is_custom != want_custom)) {
3795 /* drop existing window - wrong type */
3804 is_custom = want_custom;
3805 _window = _processor_box->get_editor_window (p, is_custom);
3811 _window->show_all ();
3816 ProcessorWindowProxy::show_the_right_window ()
3818 if (_window && (is_custom != want_custom)) {
3819 /* drop existing window - wrong type */
3824 is_custom = want_custom;
3831 PluginPinWindowProxy::PluginPinWindowProxy(std::string const &name, boost::weak_ptr<ARDOUR::Processor> processor)
3832 : WM::ProxyBase (name, string())
3833 , _processor (processor)
3835 boost::shared_ptr<Processor> p = _processor.lock ();
3839 p->DropReferences.connect (going_away_connection, MISSING_INVALIDATOR, boost::bind (&PluginPinWindowProxy::processor_going_away, this), gui_context());
3842 PluginPinWindowProxy::~PluginPinWindowProxy()
3849 PluginPinWindowProxy::get (bool create)
3851 boost::shared_ptr<Processor> p = _processor.lock ();
3852 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (p);
3861 _window = new PluginPinDialog (pi);
3864 _window->show_all ();
3869 PluginPinWindowProxy::processor_going_away ()
3873 WM::Manager::instance().remove (this);
3874 going_away_connection.disconnect();
3878 ProcessorBox::load_bindings ()
3880 bindings = Bindings::get_bindings (X_("Processor Box"), myactions);