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"
71 #include "mixer_strip.h"
72 #include "plugin_selector.h"
73 #include "plugin_ui.h"
74 #include "port_insert_ui.h"
75 #include "processor_box.h"
76 #include "public_editor.h"
77 #include "return_ui.h"
78 #include "route_processor_selection.h"
79 #include "script_selector.h"
83 #include "new_plugin_preset_dialog.h"
87 #ifdef AUDIOUNIT_SUPPORT
92 bool ProcessorBox::show_all_processors = false;
96 using namespace ARDOUR;
100 using namespace Gtkmm2ext;
102 ProcessorBox* ProcessorBox::_current_processor_box = 0;
103 RefPtr<Action> ProcessorBox::paste_action;
104 RefPtr<Action> ProcessorBox::cut_action;
105 RefPtr<Action> ProcessorBox::copy_action;
106 RefPtr<Action> ProcessorBox::rename_action;
107 RefPtr<Action> ProcessorBox::delete_action;
108 RefPtr<Action> ProcessorBox::edit_action;
109 RefPtr<Action> ProcessorBox::edit_generic_action;
110 RefPtr<ActionGroup> ProcessorBox::processor_box_actions;
111 Gtkmm2ext::ActionMap ProcessorBox::myactions (X_("processor box"));
112 Gtkmm2ext::Bindings* ProcessorBox::bindings = 0;
114 static const uint32_t audio_port_color = 0x4A8A0EFF; // Green
115 static const uint32_t midi_port_color = 0x960909FF; //Red
117 ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processor> p, Width w)
118 : _button (ArdourButton::led_default_elements)
119 , _position (PreFader)
122 , _unknown_processor(false)
127 , _output_icon(false)
132 _button.set_distinct_led_click (true);
133 _button.set_fallthrough_to_parent(true);
134 _button.set_led_left (true);
135 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &ProcessorEntry::led_clicked));
136 _button.set_text (name (_width));
138 if (boost::dynamic_pointer_cast<PeakMeter> (_processor)) {
139 _button.set_elements(ArdourButton::Element(_button.elements() & ~ArdourButton::Indicator));
141 if (boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
142 _button.set_elements(ArdourButton::Element(_button.elements() & ~ArdourButton::Indicator));
143 _unknown_processor = true;
146 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
147 if (pi && pi->plugin() && pi->plugin()->get_info()->type != ARDOUR::Lua) {
148 _plugin_preset_pointer = PluginPresetPtr (new PluginPreset (pi->plugin()->get_info()));
153 _vbox.pack_start (_routing_icon);
154 _vbox.pack_start (_input_icon);
155 _vbox.pack_start (_button, true, true);
157 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
158 if (pi && pi->plugin() && pi->plugin()->has_inline_display()) {
159 _plugin_display = new PluginDisplay (pi->plugin(),
160 std::max (60.f, rintf(112.f * UIConfiguration::instance().get_ui_scale())));
161 _vbox.pack_start (*_plugin_display);
162 _plugin_display->set_no_show_all (true);
163 if (UIConfiguration::instance().get_show_inline_display_by_default ()) {
164 _plugin_display->show ();
167 _vbox.pack_end (_output_icon);
169 _button.set_active (_processor->active());
171 _routing_icon.set_no_show_all(true);
172 _input_icon.set_no_show_all(true);
175 _routing_icon.set_visible(false);
179 _processor->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_active_changed, this), gui_context());
180 _processor->PropertyChanged.connect (name_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_property_changed, this, _1), gui_context());
181 _processor->ConfigurationChanged.connect (config_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_configuration_changed, this, _1, _2), gui_context());
183 set<Evoral::Parameter> p = _processor->what_can_be_automated ();
184 for (set<Evoral::Parameter>::iterator i = p.begin(); i != p.end(); ++i) {
186 std::string label = _processor->describe_parameter (*i);
188 if (boost::dynamic_pointer_cast<Send> (_processor)) {
190 } else if (boost::dynamic_pointer_cast<Return> (_processor)) {
194 Control* c = new Control (_processor->automation_control (*i), label);
196 _controls.push_back (c);
198 if (boost::dynamic_pointer_cast<Amp> (_processor) == 0) {
199 /* Add non-Amp (Fader & Trim) controls to the processor box */
200 _vbox.pack_start (c->box);
204 _input_icon.set_ports(_processor->input_streams());
205 _output_icon.set_ports(_processor->output_streams());
207 _routing_icon.set_sources(_processor->input_streams());
208 _routing_icon.set_sinks(_processor->output_streams());
213 _vbox.set_size_request (-1, _button.size_request().height);
217 ProcessorEntry::~ProcessorEntry ()
219 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
222 delete _plugin_display;
226 ProcessorEntry::action_widget ()
232 ProcessorEntry::widget ()
238 ProcessorEntry::drag_text () const
244 ProcessorEntry::can_copy_state (Gtkmm2ext::DnDVBoxChild* o) const
246 ProcessorEntry *other = dynamic_cast<ProcessorEntry*> (o);
250 boost::shared_ptr<ARDOUR::Processor> otherproc = other->processor();
251 boost::shared_ptr<PluginInsert> my_pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
252 boost::shared_ptr<PluginInsert> ot_pi = boost::dynamic_pointer_cast<PluginInsert> (otherproc);
253 if (boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
256 if (boost::dynamic_pointer_cast<UnknownProcessor> (otherproc)) {
259 if (!my_pi || !ot_pi) {
262 if (my_pi->type() != ot_pi->type()) {
265 boost::shared_ptr<Plugin> my_p = my_pi->plugin();
266 boost::shared_ptr<Plugin> ot_p = ot_pi->plugin();
267 if (!my_p || !ot_p) {
270 if (my_p->unique_id() != ot_p->unique_id()) {
277 ProcessorEntry::drag_data_get (Glib::RefPtr<Gdk::DragContext> const, Gtk::SelectionData &data)
279 if (data.get_target() == "PluginPresetPtr") {
280 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
282 if (!_plugin_preset_pointer || !pi) {
283 data.set (data.get_target(), 8, NULL, 0);
287 boost::shared_ptr<ARDOUR::Plugin> plugin = pi->plugin();
290 PluginManager& manager (PluginManager::instance());
291 bool fav = manager.get_status (_plugin_preset_pointer->_pip) == PluginManager::Favorite;
293 NewPluginPresetDialog d (plugin,
294 string_compose(_("New Favorite Preset for \"%1\""),_plugin_preset_pointer->_pip->name), !fav);
296 _plugin_preset_pointer->_preset.valid = false;
299 case Gtk::RESPONSE_CANCEL:
300 data.set (data.get_target(), 8, NULL, 0);
304 case Gtk::RESPONSE_NO:
307 case Gtk::RESPONSE_ACCEPT:
308 if (d.name().empty()) {
313 plugin->remove_preset (d.name ());
316 Plugin::PresetRecord const r = plugin->save_preset (d.name());
318 if (!r.uri.empty ()) {
319 _plugin_preset_pointer->_preset.uri = r.uri;
320 _plugin_preset_pointer->_preset.label = r.label;
321 _plugin_preset_pointer->_preset.user = r.user;
322 _plugin_preset_pointer->_preset.valid = r.valid;
325 data.set (data.get_target(), 8, (const guchar *) &_plugin_preset_pointer, sizeof (PluginPresetPtr));
332 ProcessorEntry::set_position (Position p, uint32_t num)
337 if (_position_num == 0 || _routing_icon.get_visible()) {
347 ProcessorEntry::set_visual_state (Gtkmm2ext::VisualState s, bool yn)
350 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() | s));
352 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() & ~s));
357 ProcessorEntry::setup_visuals ()
359 if (_unknown_processor) {
360 _button.set_name ("processor stub");
366 if (_plugin_display) { _plugin_display->set_name ("processor prefader"); }
367 _button.set_name ("processor prefader");
371 _button.set_name ("processor fader");
375 if (_plugin_display) { _plugin_display->set_name ("processor postfader"); }
376 _button.set_name ("processor postfader");
382 boost::shared_ptr<Processor>
383 ProcessorEntry::processor () const
386 return boost::shared_ptr<Processor>();
392 ProcessorEntry::set_enum_width (Width w)
395 _button.set_text (name (_width));
399 ProcessorEntry::led_clicked(GdkEventButton *ev)
401 bool ctrl_shift_pressed = false;
402 Keyboard::ModifierMask ctrl_shift_mask = Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier);
404 if (Keyboard::modifier_state_equals (ev->state, ctrl_shift_mask)) {
405 ctrl_shift_pressed = true;
409 if (_button.get_active ()) {
410 if (ctrl_shift_pressed) {
411 _parent->all_visible_processors_active(false);
413 if (_position == Fader) {
414 _processor->deactivate ();
418 _processor->deactivate ();
422 if (ctrl_shift_pressed) {
423 _parent->all_visible_processors_active(true);
425 if (_position == Fader) {
426 _processor->activate ();
430 _processor->activate ();
437 ProcessorEntry::processor_active_changed ()
440 _button.set_active (_processor->active());
445 ProcessorEntry::processor_property_changed (const PropertyChange& what_changed)
447 if (what_changed.contains (ARDOUR::Properties::name)) {
448 _button.set_text (name (_width));
454 ProcessorEntry::processor_configuration_changed (const ChanCount in, const ChanCount out)
456 _input_icon.set_ports(in);
457 _output_icon.set_ports(out);
458 _routing_icon.set_sources(in);
459 _routing_icon.set_sinks(out);
460 _input_icon.queue_draw();
461 _output_icon.queue_draw();
462 _routing_icon.queue_draw();
466 ProcessorEntry::setup_tooltip ()
469 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
471 std::string postfix = "";
473 if ((replicated = pi->get_count()) > 1) {
474 postfix = string_compose(_("\nThis mono plugin has been replicated %1 times."), replicated);
476 if (pi->plugin()->has_editor()) {
477 ARDOUR_UI_UTILS::set_tooltip (_button,
478 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));
480 ARDOUR_UI_UTILS::set_tooltip (_button,
481 string_compose (_("<b>%1</b>\nDouble-click to show generic GUI.%2"), name (Wide), postfix));
485 if(boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
486 ARDOUR_UI::instance()->set_tip (_button,
487 string_compose (_("<b>%1</b>\nThe Plugin is not available on this system\nand has been replaced by a stub."), name (Wide)));
491 ARDOUR_UI_UTILS::set_tooltip (_button, string_compose ("<b>%1</b>", name (Wide)));
495 ProcessorEntry::name (Width w) const
497 boost::shared_ptr<Send> send;
504 if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
505 !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
509 /* grab the send name out of its overall name */
511 string::size_type lbracket, rbracket;
512 lbracket = send->name().find ('[');
513 rbracket = send->name().find (']');
517 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
520 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
525 boost::shared_ptr<ARDOUR::PluginInsert> pi;
527 if ((pi = boost::dynamic_pointer_cast<ARDOUR::PluginInsert> (_processor)) != 0
528 && (replicated = pi->get_count()) > 1)
530 name_display += string_compose(_("(%1x1) "), replicated);
535 name_display += _processor->display_name();
538 name_display += PBD::short_version (_processor->display_name(), 5);
548 ProcessorEntry::show_all_controls ()
550 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
551 (*i)->set_visible (true);
554 _parent->update_gui_object_state (this);
558 ProcessorEntry::hide_all_controls ()
560 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
561 (*i)->set_visible (false);
564 _parent->update_gui_object_state (this);
568 ProcessorEntry::add_control_state (XMLNode* node) const
570 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
571 (*i)->add_state (node);
574 if (_plugin_display) {
575 XMLNode* c = new XMLNode (X_("Object"));
576 c->add_property (X_("id"), X_("InlineDisplay"));
577 c->add_property (X_("visible"), _plugin_display->is_visible ());
578 node->add_child_nocopy (*c);
583 ProcessorEntry::set_control_state (XMLNode const * node)
585 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
586 (*i)->set_state (node);
589 if (_plugin_display) {
590 XMLNode* n = GUIObjectState::get_node (node, X_("InlineDisplay"));
591 XMLProperty* p = n ? n->property (X_("visible")) : NULL;
593 if (string_is_affirmative (p->value ())) {
594 _plugin_display->show();
596 _plugin_display->hide();
603 ProcessorEntry::state_id () const
605 return string_compose ("processor %1", _processor->id().to_s());
609 ProcessorEntry::hide_things ()
611 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
612 (*i)->hide_things ();
618 ProcessorEntry::build_controls_menu ()
620 using namespace Menu_Helpers;
621 Menu* menu = manage (new Menu);
622 MenuList& items = menu->items ();
624 if (_plugin_display) {
625 items.push_back (CheckMenuElem (_("Inline Display")));
626 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
627 c->set_active (_plugin_display->is_visible ());
628 c->signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::toggle_inline_display_visibility));
629 items.push_back (SeparatorElem ());
633 MenuElem (_("Show All Controls"), sigc::mem_fun (*this, &ProcessorEntry::show_all_controls))
637 MenuElem (_("Hide All Controls"), sigc::mem_fun (*this, &ProcessorEntry::hide_all_controls))
640 if (!_controls.empty ()) {
641 items.push_back (SeparatorElem ());
644 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
645 items.push_back (CheckMenuElem ((*i)->name ()));
646 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
647 c->set_active ((*i)->visible ());
648 c->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &ProcessorEntry::toggle_control_visibility), *i));
655 ProcessorEntry::toggle_inline_display_visibility ()
657 if (_plugin_display->is_visible ()) {
658 _plugin_display->hide();
660 _plugin_display->show();
662 _parent->update_gui_object_state (this);
666 ProcessorEntry::toggle_control_visibility (Control* c)
668 c->set_visible (!c->visible ());
669 _parent->update_gui_object_state (this);
673 ProcessorEntry::build_send_options_menu ()
675 using namespace Menu_Helpers;
676 Menu* menu = manage (new Menu);
677 MenuList& items = menu->items ();
679 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (_processor);
682 items.push_back (CheckMenuElem (_("Link panner controls")));
683 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
684 c->set_active (send->panner_shell()->is_linked_to_route());
685 c->signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::toggle_panner_link));
692 ProcessorEntry::toggle_panner_link ()
694 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (_processor);
696 send->panner_shell()->set_linked_to_route(!send->panner_shell()->is_linked_to_route());
700 ProcessorEntry::Control::Control (boost::shared_ptr<AutomationControl> c, string const & n)
702 , _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1)
703 , _slider (&_adjustment, boost::shared_ptr<PBD::Controllable>(), 0, max(13.f, rintf(13.f * UIConfiguration::instance().get_ui_scale())))
704 , _slider_persistant_tooltip (&_slider)
705 , _button (ArdourButton::led_default_elements)
706 , _ignore_ui_adjustment (false)
710 _slider.set_controllable (c);
711 box.set_padding(0, 0, 4, 4);
714 _button.set_text (_name);
715 _button.set_led_left (true);
716 _button.set_name ("processor control button");
720 _button.signal_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked));
721 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked_event));
722 // dup. currently timers are used :(
723 //c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
727 _slider.set_name ("ProcessorControlSlider");
728 _slider.set_text (_name);
733 const ARDOUR::ParameterDescriptor& desc = c->desc();
734 double const lo = c->internal_to_interface(desc.lower);
735 double const up = c->internal_to_interface(desc.upper);
736 double const normal = c->internal_to_interface(desc.normal);
737 double smallstep = desc.smallstep;
738 double largestep = desc.largestep;
740 if (smallstep == 0.0) {
741 smallstep = up / 1000.;
743 smallstep = c->internal_to_interface(desc.lower + smallstep);
746 if (largestep == 0.0) {
747 largestep = up / 40.;
749 largestep = c->internal_to_interface(desc.lower + largestep);
752 _adjustment.set_lower (lo);
753 _adjustment.set_upper (up);
754 _adjustment.set_step_increment (smallstep);
755 _adjustment.set_page_increment (largestep);
756 _slider.set_default_value (normal);
758 _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &Control::slider_adjusted));
759 // dup. currently timers are used :(
760 //c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
763 // yuck, do we really need to do this?
764 // according to c404374 this is only needed for send automation
765 timer_connection = Timers::rapid_connect (sigc::mem_fun (*this, &Control::control_changed));
770 /* We're providing our own PersistentTooltip */
771 set_no_tooltip_whatsoever (_slider);
774 ProcessorEntry::Control::~Control ()
776 timer_connection.disconnect ();
780 ProcessorEntry::Control::set_tooltip ()
782 boost::shared_ptr<AutomationControl> c = _control.lock ();
789 snprintf (tmp, sizeof(tmp), "%s: %s", _name.c_str(), c->get_value() > 0.5 ? _("on") : _("off"));
791 snprintf (tmp, sizeof(tmp), "%s: %.2f", _name.c_str(), c->internal_to_user (c->get_value ()));
794 string sm = Gtkmm2ext::markup_escape_text (tmp);
795 _slider_persistant_tooltip.set_tip (sm);
796 ARDOUR_UI_UTILS::set_tooltip (_button, sm);
800 ProcessorEntry::Control::slider_adjusted ()
802 if (_ignore_ui_adjustment) {
806 boost::shared_ptr<AutomationControl> c = _control.lock ();
812 c->set_value ( c->interface_to_internal(_adjustment.get_value ()) , Controllable::NoGroup);
817 ProcessorEntry::Control::button_clicked ()
819 boost::shared_ptr<AutomationControl> c = _control.lock ();
825 bool const n = _button.get_active ();
827 c->set_value (n ? 0 : 1, Controllable::NoGroup);
828 _button.set_active (!n);
833 ProcessorEntry::Control::button_clicked_event (GdkEventButton *ev)
841 ProcessorEntry::Control::control_changed ()
843 boost::shared_ptr<AutomationControl> c = _control.lock ();
848 _ignore_ui_adjustment = true;
852 _button.set_active (c->get_value() > 0.5);
855 // as long as rapid timers are used, only update the tooltip
856 // if the value has changed.
857 const double nval = c->internal_to_interface (c->get_value ());
858 if (_adjustment.get_value() != nval) {
859 _adjustment.set_value (nval);
864 _ignore_ui_adjustment = false;
868 ProcessorEntry::Control::add_state (XMLNode* node) const
870 XMLNode* c = new XMLNode (X_("Object"));
871 c->add_property (X_("id"), state_id ());
872 c->add_property (X_("visible"), _visible);
873 node->add_child_nocopy (*c);
877 ProcessorEntry::Control::set_state (XMLNode const * node)
879 XMLNode* n = GUIObjectState::get_node (node, state_id ());
881 XMLProperty* p = n->property (X_("visible"));
882 set_visible (p && string_is_affirmative (p->value ()));
889 ProcessorEntry::Control::set_visible (bool v)
900 /** Called when the Editor might have re-shown things that
904 ProcessorEntry::Control::hide_things ()
912 ProcessorEntry::Control::state_id () const
914 boost::shared_ptr<AutomationControl> c = _control.lock ();
917 return string_compose (X_("control %1"), c->id().to_s ());
920 PluginInsertProcessorEntry::PluginInsertProcessorEntry (ProcessorBox* b, boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
921 : ProcessorEntry (b, p, w)
924 p->PluginIoReConfigure.connect (
925 _splitting_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::plugin_insert_splitting_changed, this), gui_context()
928 plugin_insert_splitting_changed ();
932 PluginInsertProcessorEntry::plugin_insert_splitting_changed ()
934 ChanCount in, out; // actual configured i/o
935 _plugin_insert->configured_io (in, out);
937 /* get number of input ports */
938 ChanCount sinks = _plugin_insert->natural_input_streams();
939 if (!_plugin_insert->splitting () && _plugin_insert->get_count() > 1) {
940 /* replicated instances */
941 for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
942 sinks.set(*t, sinks.get(*t) * _plugin_insert->get_count());
946 if (_plugin_insert->natural_output_streams().n_midi() == 0 &&
947 _plugin_insert->output_streams().n_midi() == 1) {
948 in.set(DataType::MIDI, 1);
949 out.set(DataType::MIDI, 1);
950 sinks.set(DataType::MIDI, 1);
953 /* the Input streams available (*valid* outputs from prev. plugin)
954 * this will be <= sinks. Some input-ports of this processor
955 * may be unconnected.
957 _routing_icon.set_sources(in);
959 /* the actual input ports of this processor */
960 _input_icon.set_ports(sinks);
961 _routing_icon.set_sinks(sinks);
963 /* set/override plugin-output ports to actual outputs-streams.
965 * This plugin may have unconnected output-ports (currently only in Mixbus,
966 * e.g channelstrip-EQ at the top of a MIDI-channel before the synth).
968 * The *next* processor below this one will only see the
969 * actual available streams (it cannot know the real outputs
972 * There is currently no API to query the ports of the previous (or next)
975 * (normally - iff configuration succeeds - this is set during
976 * ProcessorEntry::processor_configuration_changed() and should
977 * equal _plugin_insert->output_streams())
979 _output_icon.set_ports(out);
981 if (out != _plugin_insert->output_streams()) {
982 std::cerr << "Processor Wiring: " << processor()->name()
983 << " out-ports: " << _plugin_insert->output_streams() // NB. does not include midi-bypass
984 << " out-connections: " << out
989 _routing_icon.set_splitting(_plugin_insert->splitting ());
991 if (_plugin_insert->splitting () || in != sinks)
993 _routing_icon.set_size_request (-1, std::max (7.f, rintf(7.f * UIConfiguration::instance().get_ui_scale())));
994 _routing_icon.set_visible(true);
997 _routing_icon.set_visible(false);
998 if (_position_num != 0) {
1003 _input_icon.queue_draw();
1004 _output_icon.queue_draw();
1005 _routing_icon.queue_draw();
1009 PluginInsertProcessorEntry::hide_things ()
1011 ProcessorEntry::hide_things ();
1012 plugin_insert_splitting_changed ();
1015 ProcessorEntry::PortIcon::PortIcon(bool input) {
1017 _ports = ARDOUR::ChanCount(ARDOUR::DataType::AUDIO, 1);
1018 set_size_request (-1, std::max (2.f, rintf(2.f * UIConfiguration::instance().get_ui_scale())));
1022 ProcessorEntry::PortIcon::on_expose_event (GdkEventExpose* ev)
1024 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
1026 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
1029 Gtk::Allocation a = get_allocation();
1030 double const width = a.get_width();
1031 double const height = a.get_height();
1033 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
1034 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
1036 cairo_rectangle (cr, 0, 0, width, height);
1039 const double dx = rint(max(2., 2. * UIConfiguration::instance().get_ui_scale()));
1040 if (_ports.n_total() > 1) {
1041 for (uint32_t i = 0; i < _ports.n_total(); ++i) {
1042 if (i < _ports.n_midi()) {
1043 cairo_set_source_rgb (cr,
1044 UINT_RGBA_R_FLT(midi_port_color),
1045 UINT_RGBA_G_FLT(midi_port_color),
1046 UINT_RGBA_B_FLT(midi_port_color));
1048 cairo_set_source_rgb (cr,
1049 UINT_RGBA_R_FLT(audio_port_color),
1050 UINT_RGBA_G_FLT(audio_port_color),
1051 UINT_RGBA_B_FLT(audio_port_color));
1053 const float x = rintf(width * (.2f + .6f * i / (_ports.n_total() - 1.f)));
1054 cairo_rectangle (cr, x-dx * .5, 0, 1+dx, height);
1057 } else if (_ports.n_total() == 1) {
1058 if (_ports.n_midi() == 1) {
1059 cairo_set_source_rgb (cr,
1060 UINT_RGBA_R_FLT(midi_port_color),
1061 UINT_RGBA_G_FLT(midi_port_color),
1062 UINT_RGBA_B_FLT(midi_port_color));
1064 cairo_set_source_rgb (cr,
1065 UINT_RGBA_R_FLT(audio_port_color),
1066 UINT_RGBA_G_FLT(audio_port_color),
1067 UINT_RGBA_B_FLT(audio_port_color));
1069 const float x = rintf(width * .5);
1070 cairo_rectangle (cr, x-dx * .5, 0, 1+dx, height);
1080 ProcessorEntry::RoutingIcon::on_expose_event (GdkEventExpose* ev)
1082 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
1084 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
1087 cairo_set_line_width (cr, max (1.f, UIConfiguration::instance().get_ui_scale()));
1088 cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
1090 Gtk::Allocation a = get_allocation();
1091 double const width = a.get_width();
1092 double const height = a.get_height();
1094 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
1095 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
1097 cairo_rectangle (cr, 0, 0, width, height);
1100 Gdk::Color const fg = get_style()->get_fg (STATE_NORMAL);
1101 cairo_set_source_rgb (cr, fg.get_red_p (), fg.get_green_p (), fg.get_blue_p ());
1103 const uint32_t sources = _sources.n_total();
1104 const uint32_t sinks = _sinks.n_total();
1106 const uint32_t midi_sources = _sources.n_midi();
1107 const uint32_t midi_sinks = _sinks.n_midi();
1108 const uint32_t audio_sources = _sources.n_audio();
1109 const uint32_t audio_sinks = _sinks.n_audio();
1112 cairo_set_source_rgb (cr,
1113 UINT_RGBA_R_FLT(midi_port_color),
1114 UINT_RGBA_G_FLT(midi_port_color),
1115 UINT_RGBA_B_FLT(midi_port_color));
1116 if (midi_sources > 0 && midi_sinks > 0 && sinks > 1 && sources > 1) {
1117 for (uint32_t i = 0 ; i < midi_sources; ++i) {
1118 const float si_x = rintf(width * (.2f + .6f * i / (sinks - 1.f))) + .5f;
1119 const float si_x0 = rintf(width * (.2f + .6f * i / (sources - 1.f))) + .5f;
1120 cairo_move_to (cr, si_x, height);
1121 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
1124 } else if (midi_sources == 1 && midi_sinks == 1 && sinks == 1 && sources == 1) {
1125 const float si_x = rintf(width * .5f) + .5f;
1126 cairo_move_to (cr, si_x, height);
1127 cairo_line_to (cr, si_x, 0);
1129 } else if (midi_sources == 1 && midi_sinks == 1) {
1130 /* unusual cases -- removed synth, midi-track w/audio plugins */
1131 const float si_x = rintf(width * (sinks > 1 ? .2f : .5f)) + .5f;
1132 const float si_x0 = rintf(width * (sources > 1 ? .2f : .5f)) + .5f;
1133 cairo_move_to (cr, si_x, height);
1134 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
1136 } else if (midi_sources == 0 && midi_sinks == 1) {
1137 const double dx = 1 + rint(max(2., 2. * UIConfiguration::instance().get_ui_scale()));
1139 // TODO connect back to track-input of last midi-out if any, otherwise draw "X"
1140 const float si_x = rintf(width * .2f) + .5f;
1141 cairo_move_to (cr, si_x, height);
1142 cairo_line_to (cr, si_x, height * .66);
1143 cairo_move_to (cr, si_x - dx, height * .66);
1144 cairo_line_to (cr, si_x + dx, height * .66);
1147 } else if (midi_sources != 0 && midi_sinks != 0) {
1148 PBD::warning << string_compose("Programming error: midi routing display: A %1 -> %2 | M %3 -> %4 | T %5 -> %6",
1149 audio_sources, audio_sinks, midi_sources, midi_sinks, sources, sinks) << endmsg;
1154 cairo_set_source_rgb (cr,
1155 UINT_RGBA_R_FLT(audio_port_color),
1156 UINT_RGBA_G_FLT(audio_port_color),
1157 UINT_RGBA_B_FLT(audio_port_color));
1160 assert(audio_sources < 2);
1161 assert(audio_sinks > 1);
1162 /* assume there is only ever one MIDI port */
1163 const float si_x0 = rintf(width * (midi_sources > 0 ? .8f : .5f)) + .5f;
1164 for (uint32_t i = midi_sinks; i < sinks; ++i) {
1165 const float si_x = rintf(width * (.2f + .6f * i / (sinks - 1.f))) + .5f;
1166 cairo_move_to (cr, si_x, height);
1167 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
1170 } else if (audio_sources > 1 && sinks > 1) {
1171 for (uint32_t i = 0 ; i < audio_sources; ++i) {
1172 const float si_x = rintf(width * (.2f + .6f * (i + midi_sinks) / (sinks - 1.f))) + .5f;
1173 const float si_x0 = rintf(width * (.2f + .6f * (i + midi_sources) / (sources - 1.f))) + .5f;
1174 cairo_move_to (cr, si_x, height);
1175 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
1178 } else if (audio_sources == 1 && audio_sinks > 0) {
1181 si_x = rintf(width * .5f) + .5f;
1183 si_x = rintf(width * (.2f + .6f * midi_sinks / (sinks - 1.f))) + .5f;
1186 si_x0 = rintf(width * .5f) + .5f;
1188 si_x0 = rintf(width * (.2f + .6f * midi_sources / (sources - 1.f))) + .5f;
1190 cairo_move_to (cr, si_x, height);
1191 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
1194 } else if (audio_sources != 0 && audio_sinks != 0) {
1195 PBD::warning << string_compose("Programming error: audio routing display: A %1 -> %2 | M %3 -> %4 | T %5 -> %6",
1196 audio_sources, audio_sinks, midi_sources, midi_sinks, sources, sinks) << endmsg;
1204 ProcessorEntry::PluginDisplay::PluginDisplay (boost::shared_ptr<ARDOUR::Plugin> p, uint32_t max_height)
1207 , _max_height (max_height)
1211 set_name ("processor prefader");
1212 _plug->QueueDraw.connect (_qdraw_connection, invalidator (*this),
1213 boost::bind (&Gtk::Widget::queue_draw, this), gui_context ());
1216 ProcessorEntry::PluginDisplay::~PluginDisplay ()
1219 cairo_surface_destroy (_surf);
1224 ProcessorEntry::PluginDisplay::on_size_request (Gtk::Requisition* req)
1227 req->height = _cur_height;
1231 ProcessorEntry::PluginDisplay::on_expose_event (GdkEventExpose* ev)
1233 Gtk::Allocation a = get_allocation();
1234 double const width = a.get_width();
1235 double const height = a.get_height();
1237 Plugin::Display_Image_Surface* dis = _plug->render_inline_display (width, _max_height);
1240 if (_cur_height != 1) {
1247 /* work-around scroll-bar + aspect ratio
1248 * show inline-view -> height changes -> scrollbar gets added
1249 * -> width changes -> inline-view, fixed aspect ratio -> height changes
1250 * -> scroll bar is removed [-> width changes ; repeat ]
1252 uint32_t shm = std::min (_max_height, (uint32_t)dis->height);
1254 Gtk::Container* pr = get_parent();
1255 for (uint32_t i = 0; i < 4 && pr; ++i) {
1256 // VBox, EventBox, ViewPort, ScrolledWindow
1257 pr = pr->get_parent();
1259 Gtk::ScrolledWindow* sw = dynamic_cast<Gtk::ScrolledWindow*> (pr);
1261 const Gtk::VScrollbar* vsb = sw->get_vscrollbar();
1262 sc = vsb && vsb->is_visible();
1265 if (shm != _cur_height) {
1266 if (_scroll == sc || _cur_height < shm) {
1274 /* allocate a local image-surface,
1275 * We cannot re-use the data via cairo_image_surface_create_for_data(),
1276 * since pixman keeps a reference to it.
1277 * we'd need to hand over the data and ha cairo_surface_destroy to free it.
1278 * it might be possible to work around via cairo_surface_set_user_data().
1281 || dis->width != cairo_image_surface_get_width (_surf)
1282 || dis->height != cairo_image_surface_get_height (_surf)
1285 cairo_surface_destroy (_surf);
1287 _surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, dis->width, dis->height);
1290 if (cairo_image_surface_get_stride (_surf) == dis->stride) {
1291 memcpy (cairo_image_surface_get_data (_surf), dis->data, dis->stride * dis->height);
1293 unsigned char *src = dis->data;
1294 unsigned char *dst = cairo_image_surface_get_data (_surf);
1295 const int dst_stride = cairo_image_surface_get_stride (_surf);
1296 for (int y = 0; y < dis->height; ++y) {
1297 memcpy (dst, src, dis->width * 4 /*ARGB32*/);
1302 cairo_surface_mark_dirty(_surf);
1304 // all set. Now paint it black.
1305 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
1306 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
1309 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
1310 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
1311 cairo_rectangle (cr, 0, 0, width, height);
1315 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
1316 Gtkmm2ext::rounded_rectangle (cr, .5, -1.5, width - 1, height + 1, 7);
1319 const double xc = floor ((width - dis->width) * .5);
1320 cairo_set_source_surface(cr, _surf, xc, 0);
1324 bool failed = false;
1325 std::string name = get_name();
1326 ArdourCanvas::Color fill_color = UIConfiguration::instance().color (string_compose ("%1: fill active", name), &failed);
1328 Gtkmm2ext::rounded_rectangle (cr, .5, -1.5, width - 1, height + 1, 7);
1329 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1330 cairo_set_line_width(cr, 1.0);
1331 ArdourCanvas::set_source_rgb_a (cr, fill_color, 1.0);
1338 static std::list<Gtk::TargetEntry> drop_targets()
1340 std::list<Gtk::TargetEntry> tmp;
1341 tmp.push_back (Gtk::TargetEntry ("processor")); // from processor-box to processor-box
1342 tmp.push_back (Gtk::TargetEntry ("PluginInfoPtr")); // from plugin-manager
1343 tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr")); // from sidebar
1347 static std::list<Gtk::TargetEntry> drag_targets()
1349 std::list<Gtk::TargetEntry> tmp;
1350 tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr")); // to sidebar (optional preset)
1351 tmp.push_back (Gtk::TargetEntry ("processor")); // to processor-box (copy)
1355 static std::list<Gtk::TargetEntry> drag_targets_noplugin()
1357 std::list<Gtk::TargetEntry> tmp;
1358 tmp.push_back (Gtk::TargetEntry ("processor")); // to processor box (sends, faders re-order)
1362 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
1363 RouteProcessorSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
1364 : _parent_strip (parent)
1365 , _owner_is_mixer (owner_is_mixer)
1366 , ab_direction (true)
1367 , _get_plugin_selector (get_plugin_selector)
1369 , _visible_prefader_processors (0)
1370 , _rr_selection(rsel)
1371 , processor_display (drop_targets())
1372 , _redisplay_pending (false)
1376 /* ProcessorBox actions and bindings created statically by call to
1377 * ProcessorBox::register_actions(), made by ARDOUR_UI so that actions
1378 * are available for context menus.
1381 processor_display.set_data ("ardour-bindings", bindings);
1385 no_processor_redisplay = false;
1387 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
1388 processor_scroller.add (processor_display);
1389 pack_start (processor_scroller, true, true);
1391 processor_display.set_flags (CAN_FOCUS);
1392 processor_display.set_name ("ProcessorList");
1393 processor_display.set_data ("processorbox", this);
1394 processor_display.set_size_request (48, -1);
1395 processor_display.set_spacing (0);
1397 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
1398 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
1400 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
1401 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
1403 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
1404 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
1405 processor_display.DropFromExternal.connect (sigc::mem_fun (*this, &ProcessorBox::plugin_drop));
1407 processor_scroller.show ();
1408 processor_display.show ();
1411 parent->DeliveryChanged.connect (
1412 _mixer_strip_connections, invalidator (*this), boost::bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
1416 ARDOUR_UI_UTILS::set_tooltip (processor_display, _("Right-click to add/remove/edit\nplugins,inserts,sends and more"));
1419 ProcessorBox::~ProcessorBox ()
1421 /* it may appear as if we should delete processor_menu but that is a
1422 * pointer to a widget owned by the UI Manager, and has potentially
1423 * be returned to many other ProcessorBoxes. GTK doesn't really make
1424 * clear the ownership of this widget, which is a menu and thus is
1425 * never packed into any container other than an implict GtkWindow.
1427 * For now, until or if we ever get clarification over the ownership
1428 * story just let it continue to exist. At worst, its a small memory leak.
1433 ProcessorBox::set_route (boost::shared_ptr<Route> r)
1439 _route_connections.drop_connections();
1441 /* new route: any existing block on processor redisplay must be meaningless */
1442 no_processor_redisplay = false;
1445 _route->processors_changed.connect (
1446 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
1449 _route->DropReferences.connect (
1450 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
1453 _route->PropertyChanged.connect (
1454 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
1457 redisplay_processors ();
1461 ProcessorBox::route_going_away ()
1463 /* don't keep updating display as processors are deleted */
1464 no_processor_redisplay = true;
1468 boost::shared_ptr<Processor>
1469 ProcessorBox::find_drop_position (ProcessorEntry* position)
1471 boost::shared_ptr<Processor> p;
1473 p = position->processor ();
1475 /* dropped on the blank entry (which will be before the
1476 fader), so use the first non-blank child as our
1477 `dropped on' processor */
1478 list<ProcessorEntry*> c = processor_display.children ();
1479 list<ProcessorEntry*>::iterator i = c.begin ();
1481 assert (i != c.end ());
1482 p = (*i)->processor ();
1490 ProcessorBox::_drop_plugin_preset (Gtk::SelectionData const &data, Route::ProcessorList &pl)
1492 const void * d = data.get_data();
1493 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
1495 PluginPresetList nfos;
1497 tv->get_object_drag_data (nfos, &source);
1499 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1500 PluginPresetPtr ppp = (*i);
1501 PluginInfoPtr pip = ppp->_pip;
1502 PluginPtr p = pip->load (*_session);
1507 if (ppp->_preset.valid) {
1508 p->load_preset (ppp->_preset);
1511 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
1512 if (Config->get_new_plugins_active ()) {
1513 processor->activate ();
1515 pl.push_back (processor);
1520 ProcessorBox::_drop_plugin (Gtk::SelectionData const &data, Route::ProcessorList &pl)
1522 const void * d = data.get_data();
1523 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>*>(d);
1524 PluginInfoList nfos;
1527 tv->get_object_drag_data (nfos, &source);
1529 for (list<PluginInfoPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1530 PluginPtr p = (*i)->load (*_session);
1534 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
1535 if (Config->get_new_plugins_active ()) {
1536 processor->activate ();
1538 pl.push_back (processor);
1543 ProcessorBox::plugin_drop (Gtk::SelectionData const &data, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
1549 boost::shared_ptr<Processor> p = find_drop_position (position);
1550 Route::ProcessorList pl;
1552 if (data.get_target() == "PluginInfoPtr") {
1553 _drop_plugin (data, pl);
1555 else if (data.get_target() == "PluginPresetPtr") {
1556 _drop_plugin_preset (data, pl);
1562 Route::ProcessorStreams err;
1563 if (_route->add_processors (pl, p, &err)) {
1565 "Processor Drag/Drop failed. Probably because\n\
1566 the I/O configuration of the plugins could\n\
1567 not match the configuration of this track.");
1568 MessageDialog am (msg);
1574 ProcessorBox::object_drop (DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
1576 if (Gdk::ACTION_LINK == context->get_selected_action()) {
1577 list<ProcessorEntry*> children = source->selection ();
1578 assert (children.size() == 1);
1579 ProcessorEntry* other = *children.begin();
1580 assert (other->can_copy_state (position));
1581 boost::shared_ptr<ARDOUR::Processor> otherproc = other->processor();
1582 boost::shared_ptr<ARDOUR::Processor> proc = position->processor();
1583 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (proc);
1584 assert (otherproc && proc && pi);
1586 PBD::ID id = pi->id();
1587 XMLNode& state = otherproc->get_state ();
1588 proc->set_state (state, Stateful::loading_state_version);
1589 boost::dynamic_pointer_cast<PluginInsert>(proc)->update_id (id);
1593 boost::shared_ptr<Processor> p = find_drop_position (position);
1595 list<ProcessorEntry*> children = source->selection ();
1596 list<boost::shared_ptr<Processor> > procs;
1597 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
1598 if ((*i)->processor ()) {
1599 if (boost::dynamic_pointer_cast<UnknownProcessor> ((*i)->processor())) {
1602 procs.push_back ((*i)->processor ());
1606 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
1607 XMLNode& state = (*i)->get_state ();
1609 nlist.push_back (&state);
1610 paste_processor_state (nlist, p);
1614 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
1618 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
1619 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
1621 other->delete_dragged_processors (procs);
1627 ProcessorBox::set_width (Width w)
1635 list<ProcessorEntry*> children = processor_display.children ();
1636 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1637 (*i)->set_enum_width (w);
1644 ProcessorBox::build_possible_aux_menu ()
1646 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
1649 /* No aux sends if there are no busses */
1653 if (_route->is_monitor ()) {
1657 using namespace Menu_Helpers;
1658 Menu* menu = manage (new Menu);
1659 MenuList& items = menu->items();
1661 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
1662 if (!_route->internal_send_for (*r) && *r != _route) {
1663 items.push_back (MenuElem ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
1671 ProcessorBox::show_processor_menu (int arg)
1673 if (processor_menu == 0) {
1674 processor_menu = build_processor_menu ();
1675 processor_menu->signal_unmap().connect (sigc::mem_fun (*this, &ProcessorBox::processor_menu_unmapped));
1678 /* Sort out the plugin submenu */
1680 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newplugin"));
1682 if (plugin_menu_item) {
1683 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
1686 /* And the aux submenu */
1688 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newaux"));
1690 if (aux_menu_item) {
1691 Menu* m = build_possible_aux_menu();
1692 if (m && !m->items().empty()) {
1693 aux_menu_item->set_submenu (*m);
1694 aux_menu_item->set_sensitive (true);
1696 /* stupid gtkmm: we need to pass a null reference here */
1697 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
1698 aux_menu_item->set_sensitive (false);
1702 ActionManager::get_action (X_("ProcessorMenu"), "newinsert")->set_sensitive (!_route->is_monitor ());
1703 ActionManager::get_action (X_("ProcessorMenu"), "newsend")->set_sensitive (!_route->is_monitor ());
1705 ProcessorEntry* single_selection = 0;
1706 if (processor_display.selection().size() == 1) {
1707 single_selection = processor_display.selection().front();
1710 /* And the controls submenu */
1712 Gtk::MenuItem* controls_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/controls"));
1714 if (controls_menu_item) {
1715 if (single_selection) {
1716 Menu* m = single_selection->build_controls_menu ();
1717 if (m && !m->items().empty()) {
1718 controls_menu_item->set_submenu (*m);
1719 controls_menu_item->set_sensitive (true);
1721 gtk_menu_item_set_submenu (controls_menu_item->gobj(), 0);
1722 controls_menu_item->set_sensitive (false);
1725 controls_menu_item->set_sensitive (false);
1729 Gtk::MenuItem* send_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/send_options"));
1730 if (send_menu_item) {
1731 if (single_selection && !_route->is_monitor()) {
1732 Menu* m = single_selection->build_send_options_menu ();
1733 if (m && !m->items().empty()) {
1734 send_menu_item->set_submenu (*m);
1735 send_menu_item->set_sensitive (true);
1737 gtk_menu_item_set_submenu (send_menu_item->gobj(), 0);
1738 send_menu_item->set_sensitive (false);
1741 send_menu_item->set_sensitive (false);
1745 /* Sensitise actions as approprioate */
1748 const bool sensitive = !processor_display.selection().empty() && ! stub_processor_selected ();
1750 paste_action->set_sensitive (!_rr_selection.processors.empty());
1751 cut_action->set_sensitive (sensitive && can_cut ());
1752 copy_action->set_sensitive (sensitive);
1753 delete_action->set_sensitive (sensitive || stub_processor_selected ());
1755 edit_action->set_sensitive (one_processor_can_be_edited ());
1756 edit_generic_action->set_sensitive (one_processor_can_be_edited ());
1758 boost::shared_ptr<PluginInsert> pi;
1759 if (single_selection) {
1760 pi = boost::dynamic_pointer_cast<PluginInsert> (single_selection->processor ());
1763 /* allow editing with an Ardour-generated UI for plugin inserts with editors */
1764 edit_action->set_sensitive (pi && pi->plugin()->has_editor ());
1766 /* disallow rename for multiple selections, for plugin inserts and for the fader */
1767 rename_action->set_sensitive (single_selection
1769 && !boost::dynamic_pointer_cast<Amp> (single_selection->processor ())
1770 && !boost::dynamic_pointer_cast<UnknownProcessor> (single_selection->processor ()));
1772 processor_menu->popup (1, arg);
1774 /* Add a placeholder gap to the processor list to indicate where a processor would be
1775 inserted were one chosen from the menu.
1778 processor_display.get_pointer (x, y);
1779 _placement = processor_display.add_placeholder (y);
1781 if (_visible_prefader_processors == 0 && _placement > 0) {
1787 ProcessorBox::enter_notify (GdkEventCrossing*)
1789 processor_display.grab_focus ();
1790 _current_processor_box = this;
1795 ProcessorBox::leave_notify (GdkEventCrossing* ev)
1797 if (ev->detail == GDK_NOTIFY_INFERIOR) {
1801 Widget* top = get_toplevel();
1803 if (top->is_toplevel()) {
1804 Window* win = dynamic_cast<Window*> (top);
1805 gtk_window_set_focus (win->gobj(), 0);
1812 ProcessorBox::processor_operation (ProcessorOperation op)
1814 ProcSelection targets;
1816 get_selected_processors (targets);
1818 /* if (targets.empty()) {
1821 processor_display.get_pointer (x, y);
1823 pair<ProcessorEntry *, double> const pointer = processor_display.get_child_at_position (y);
1825 if (pointer.first && pointer.first->processor()) {
1826 targets.push_back (pointer.first->processor ());
1831 if ((op == ProcessorsDelete) && targets.empty()) {
1832 return false; //nothing to delete. return false so the editor-mixer, because the user was probably intending to delete something in the editor
1836 case ProcessorsSelectAll:
1837 processor_display.select_all ();
1840 case ProcessorsSelectNone:
1841 processor_display.select_none ();
1844 case ProcessorsCopy:
1845 copy_processors (targets);
1849 cut_processors (targets);
1852 case ProcessorsPaste:
1853 // some processors are not selectable (e.g fader, meter), target is empty.
1854 if (targets.empty() && _placement >= 0) {
1856 boost::shared_ptr<Processor> proc = _route->before_processor_for_index (_placement);
1858 targets.push_back (proc);
1861 if (targets.empty()) {
1862 paste_processors ();
1864 paste_processors (targets.front());
1868 case ProcessorsDelete:
1869 delete_processors (targets);
1872 case ProcessorsToggleActive:
1873 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
1874 if ((*i)->active()) {
1875 (*i)->deactivate ();
1893 ProcessorWindowProxy*
1894 ProcessorBox::find_window_proxy (boost::shared_ptr<Processor> processor) const
1896 return processor->window_proxy();
1901 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
1903 boost::shared_ptr<Processor> processor;
1905 processor = child->processor ();
1909 bool selected = processor_display.selected (child);
1911 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
1913 if (_session->engine().connected()) {
1914 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
1916 if (!one_processor_can_be_edited ()) {
1920 if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
1921 generic_edit_processor (processor);
1923 edit_processor (processor);
1929 } else if (Keyboard::is_context_menu_event (ev)) {
1931 show_processor_menu (ev->time);
1935 } else if (processor && ev->button == 1 && selected) {
1937 // this is purely informational but necessary for route params UI
1938 ProcessorSelected (processor); // emit
1940 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
1943 _get_plugin_selector()->show_manager ();
1950 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
1952 boost::shared_ptr<Processor> processor;
1954 processor = child->processor ();
1957 if (processor && Keyboard::is_delete_event (ev)) {
1959 Glib::signal_idle().connect (sigc::bind (
1960 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
1961 boost::weak_ptr<Processor>(processor)));
1963 } else if (processor && Keyboard::is_button2_event (ev)
1965 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
1969 /* button2-click with no/appropriate modifiers */
1971 if (processor->active()) {
1972 processor->deactivate ();
1974 processor->activate ();
1982 ProcessorBox::build_processor_menu ()
1984 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/ProcessorMenu") );
1985 processor_menu->set_name ("ArdourContextMenu");
1986 return processor_menu;
1990 ProcessorBox::select_all_processors ()
1992 processor_display.select_all ();
1996 ProcessorBox::deselect_all_processors ()
1998 processor_display.select_none ();
2002 ProcessorBox::choose_plugin ()
2004 _get_plugin_selector()->set_interested_object (*this);
2007 /** @return true if an error occurred, otherwise false */
2009 ProcessorBox::choose_lua ()
2011 LuaScriptInfoPtr spi;
2013 ScriptSelector ss (_("Add Lua DSP Processor"), LuaScriptInfo::DSP);
2014 switch (ss.run ()) {
2015 case Gtk::RESPONSE_ACCEPT:
2024 LuaPluginInfoPtr lpi (new LuaPluginInfo(spi));
2025 p = (lpi->load (*_session));
2028 "Failed to instantiate Lua DSP Processor,\n"
2029 "probably because the script is invalid (no dsp function).");
2030 MessageDialog am (msg);
2035 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
2037 Route::ProcessorStreams err_streams;
2038 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
2040 "Failed to add Lua DSP Processor at the given position,\n"
2041 "probably because the I/O configuration of the plugins\n"
2042 "could not match the configuration of this track.");
2043 MessageDialog am (msg);
2049 /** @return true if an error occurred, otherwise false */
2051 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
2053 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
2055 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
2057 Route::ProcessorStreams err_streams;
2059 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
2060 weird_plugin_dialog (**p, err_streams);
2062 // XXX SHAREDPTR delete plugin here .. do we even need to care?
2063 } else if (plugins.size() == 1 && UIConfiguration::instance().get_open_gui_after_adding_plugin()) {
2064 if (boost::dynamic_pointer_cast<PluginInsert>(processor)->plugin()->has_inline_display() && UIConfiguration::instance().get_prefer_inline_over_gui()) {
2066 } else if (_session->engine().connected () && processor_can_be_edited (processor)) {
2067 if ((*p)->has_editor ()) {
2068 edit_processor (processor);
2070 generic_edit_processor (processor);
2080 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
2082 ArdourDialog dialog (_("Plugin Incompatibility"));
2085 string text = string_compose(_("You attempted to add the plugin \"%1\" in slot %2.\n"),
2086 p.name(), streams.index);
2088 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
2089 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
2091 text += _("\nThis plugin has:\n");
2093 uint32_t const n = p.get_info()->n_inputs.n_midi ();
2094 text += string_compose (ngettext ("\t%1 MIDI input\n", "\t%1 MIDI inputs\n", n), n);
2097 uint32_t const n = p.get_info()->n_inputs.n_audio ();
2098 text += string_compose (ngettext ("\t%1 audio input\n", "\t%1 audio inputs\n", n), n);
2101 text += _("\nbut at the insertion point, there are:\n");
2103 uint32_t const n = streams.count.n_midi ();
2104 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
2107 uint32_t const n = streams.count.n_audio ();
2108 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
2111 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
2112 label.set_text(text);
2114 dialog.get_vbox()->pack_start (label);
2115 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
2117 dialog.set_name (X_("PluginIODialog"));
2118 dialog.set_modal (true);
2125 ProcessorBox::choose_insert ()
2127 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->pannable(), _route->mute_master()));
2128 _route->add_processor_by_index (processor, _placement);
2131 /* Caller must not hold process lock */
2133 ProcessorBox::choose_send ()
2135 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
2136 boost::shared_ptr<Send> send (new Send (*_session, sendpan, _route->mute_master()));
2138 /* make an educated guess at the initial number of outputs for the send */
2139 ChanCount outs = (_session->master_out())
2140 ? _session->master_out()->n_outputs()
2141 : _route->n_outputs();
2143 /* XXX need processor lock on route */
2145 Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock());
2146 send->output()->ensure_io (outs, false, this);
2147 } catch (AudioEngine::PortRegistrationFailure& err) {
2148 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
2152 /* let the user adjust the IO setup before creation.
2154 Note: this dialog is NOT modal - we just leave it to run and it will
2155 return when its Finished signal is emitted - typically when the window
2159 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
2162 /* keep a reference to the send so it doesn't get deleted while
2163 the IOSelectorWindow is doing its stuff
2165 _processor_being_created = send;
2167 ios->selector().Finished.connect (sigc::bind (
2168 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
2169 boost::weak_ptr<Processor>(send), ios));
2174 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
2176 boost::shared_ptr<Processor> processor (weak_processor.lock());
2178 /* drop our temporary reference to the new send */
2179 _processor_being_created.reset ();
2186 case IOSelector::Cancelled:
2187 // processor will go away when all shared_ptrs to it vanish
2190 case IOSelector::Accepted:
2191 _route->add_processor_by_index (processor, _placement);
2195 delete_when_idle (ios);
2199 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
2201 boost::shared_ptr<Processor> processor (weak_processor.lock());
2203 /* drop our temporary reference to the new return */
2204 _processor_being_created.reset ();
2211 case IOSelector::Cancelled:
2212 // processor will go away when all shared_ptrs to it vanish
2215 case IOSelector::Accepted:
2216 _route->add_processor_by_index (processor, _placement);
2220 delete_when_idle (ios);
2224 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
2230 boost::shared_ptr<Route> target = wr.lock();
2236 _session->add_internal_send (target, _placement, _route);
2240 ProcessorBox::route_processors_changed (RouteProcessorChange c)
2242 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
2243 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
2247 redisplay_processors ();
2251 ProcessorBox::redisplay_processors ()
2253 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors);
2256 if (no_processor_redisplay) {
2260 processor_display.clear ();
2262 _visible_prefader_processors = 0;
2265 _route->foreach_processor (sigc::bind (sigc::mem_fun (*this, &ProcessorBox::help_count_visible_prefader_processors),
2266 &_visible_prefader_processors, &fader_seen));
2268 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
2269 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
2270 setup_entry_positions ();
2273 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
2274 * not already have one.
2277 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
2279 boost::shared_ptr<Processor> p = w.lock ();
2283 if (p->window_proxy()) {
2287 /* not on the list; add it */
2290 #if 0 // is this still needed? Why?
2291 if (_parent_strip) {
2292 if (_parent_strip->mixer_owned()) {
2304 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
2305 string_compose ("%1-%2-%3", loc, _route->id(), p->id()),
2309 const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
2312 wp->set_state (*ui_xml, 0);
2315 void* existing_ui = p->get_ui ();
2318 wp->use_window (*(reinterpret_cast<Gtk::Window*>(existing_ui)));
2321 p->set_window_proxy (wp);
2322 WM::Manager::instance().register_window (wp);
2326 ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor> p, uint32_t* cnt, bool* amp_seen)
2328 boost::shared_ptr<Processor> processor (p.lock ());
2330 if (processor && ( processor->display_to_user()
2332 || show_all_processors
2337 if (boost::dynamic_pointer_cast<Amp>(processor) &&
2338 boost::dynamic_pointer_cast<Amp>(processor)->gain_control()->parameter().type() == GainAutomation) {
2349 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
2351 boost::shared_ptr<Processor> processor (p.lock ());
2353 if (!processor || ( !processor->display_to_user()
2355 && !show_all_processors
2362 boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
2364 ProcessorEntry* e = 0;
2365 if (plugin_insert) {
2366 e = new PluginInsertProcessorEntry (this, plugin_insert, _width);
2368 e = new ProcessorEntry (this, processor, _width);
2371 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
2372 boost::shared_ptr<PortInsert> ext = boost::dynamic_pointer_cast<PortInsert> (processor);
2373 boost::shared_ptr<UnknownProcessor> stub = boost::dynamic_pointer_cast<UnknownProcessor> (processor);
2375 //faders and meters are not deletable, copy/paste-able, so they shouldn't be selectable
2376 if (!send && !plugin_insert && !ext && !stub)
2377 e->set_selectable(false);
2379 bool mark_send_visible = false;
2380 if (send && _parent_strip) {
2381 /* show controls of new sends by default */
2382 GUIObjectState& st = _parent_strip->gui_object_state ();
2383 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
2385 /* check if state exists, if not it must be a new send */
2386 if (!st.get_node(strip, e->state_id())) {
2387 mark_send_visible = true;
2391 /* Set up this entry's state from the GUIObjectState */
2392 XMLNode* proc = entry_gui_object_state (e);
2394 e->set_control_state (proc);
2397 if (mark_send_visible) {
2398 e->show_all_controls ();
2403 && !plugin_insert->plugin(0)->is_channelstrip()
2407 processor_display.add_child (e, drag_targets());
2409 processor_display.add_child (e, drag_targets_noplugin());
2414 ProcessorBox::reordered ()
2416 compute_processor_sort_keys ();
2417 setup_entry_positions ();
2421 ProcessorBox::setup_entry_positions ()
2423 list<ProcessorEntry*> children = processor_display.children ();
2424 bool pre_fader = true;
2427 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2428 if (boost::dynamic_pointer_cast<Amp>((*i)->processor()) &&
2429 boost::dynamic_pointer_cast<Amp>((*i)->processor())->gain_control()->parameter().type() == GainAutomation) {
2431 (*i)->set_position (ProcessorEntry::Fader, num++);
2434 (*i)->set_position (ProcessorEntry::PreFader, num++);
2436 (*i)->set_position (ProcessorEntry::PostFader, num++);
2443 ProcessorBox::compute_processor_sort_keys ()
2445 list<ProcessorEntry*> children = processor_display.children ();
2446 Route::ProcessorList our_processors;
2448 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2449 if ((*i)->processor()) {
2450 our_processors.push_back ((*i)->processor ());
2454 if (_route->reorder_processors (our_processors)) {
2455 /* Reorder failed, so report this to the user. As far as I can see this must be done
2456 in an idle handler: it seems that the redisplay_processors() that happens below destroys
2457 widgets that were involved in the drag-and-drop on the processor list, which causes problems
2458 when the drag is torn down after this handler function is finished.
2460 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
2465 ProcessorBox::report_failed_reorder ()
2467 /* reorder failed, so redisplay */
2469 redisplay_processors ();
2471 /* now tell them about the problem */
2473 ArdourDialog dialog (_("Plugin Incompatibility"));
2476 label.set_text (_("\
2477 You cannot reorder these plugins/sends/inserts\n\
2478 in that way because the inputs and\n\
2479 outputs will not work correctly."));
2481 dialog.get_vbox()->set_border_width (12);
2482 dialog.get_vbox()->pack_start (label);
2483 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
2485 dialog.set_name (X_("PluginIODialog"));
2486 dialog.set_modal (true);
2493 ProcessorBox::rename_processors ()
2495 ProcSelection to_be_renamed;
2497 get_selected_processors (to_be_renamed);
2499 if (to_be_renamed.empty()) {
2503 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
2504 rename_processor (*i);
2509 ProcessorBox::can_cut () const
2511 vector<boost::shared_ptr<Processor> > sel;
2513 get_selected_processors (sel);
2515 /* cut_processors () does not cut inserts */
2517 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
2519 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
2520 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
2521 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
2530 ProcessorBox::stub_processor_selected () const
2532 vector<boost::shared_ptr<Processor> > sel;
2534 get_selected_processors (sel);
2536 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
2537 if (boost::dynamic_pointer_cast<UnknownProcessor>((*i)) != 0) {
2546 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
2548 if (to_be_removed.empty()) {
2552 XMLNode* node = new XMLNode (X_("cut"));
2553 Route::ProcessorList to_cut;
2555 no_processor_redisplay = true;
2556 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
2557 // Cut only plugins, sends and returns
2558 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
2559 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
2560 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
2562 Window* w = get_processor_ui (*i);
2568 XMLNode& child ((*i)->get_state());
2569 node->add_child_nocopy (child);
2570 to_cut.push_back (*i);
2574 if (_route->remove_processors (to_cut) != 0) {
2576 no_processor_redisplay = false;
2580 _rr_selection.set (node);
2582 no_processor_redisplay = false;
2583 redisplay_processors ();
2587 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
2589 if (to_be_copied.empty()) {
2593 XMLNode* node = new XMLNode (X_("copy"));
2595 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
2596 // Copy only plugins, sends, returns
2597 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
2598 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
2599 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
2600 node->add_child_nocopy ((*i)->get_state());
2604 _rr_selection.set (node);
2608 ProcessorBox::delete_processors (const ProcSelection& targets)
2610 if (targets.empty()) {
2614 no_processor_redisplay = true;
2616 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
2618 Window* w = get_processor_ui (*i);
2624 _route->remove_processor(*i);
2627 no_processor_redisplay = false;
2628 redisplay_processors ();
2632 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
2634 list<boost::shared_ptr<Processor> >::const_iterator x;
2636 no_processor_redisplay = true;
2637 for (x = procs.begin(); x != procs.end(); ++x) {
2639 Window* w = get_processor_ui (*x);
2645 _route->remove_processor(*x);
2648 no_processor_redisplay = false;
2649 redisplay_processors ();
2653 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
2655 boost::shared_ptr<Processor> processor (weak_processor.lock());
2661 /* NOT copied to _mixer.selection() */
2663 no_processor_redisplay = true;
2664 _route->remove_processor (processor);
2665 no_processor_redisplay = false;
2666 redisplay_processors ();
2672 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
2674 ArdourPrompter name_prompter (true);
2676 name_prompter.set_title (_("Rename Processor"));
2677 name_prompter.set_prompt (_("New name:"));
2678 name_prompter.set_initial_text (processor->name());
2679 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
2680 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
2681 name_prompter.show_all ();
2683 switch (name_prompter.run ()) {
2685 case Gtk::RESPONSE_ACCEPT:
2686 name_prompter.get_result (result);
2687 if (result.length()) {
2690 string test = result;
2692 while (tries < 100) {
2693 if (_session->io_name_is_legal (test)) {
2699 test = string_compose ("%1-%2", result, tries);
2703 processor->set_name (result);
2706 ARDOUR_UI::instance()->popup_error
2707 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
2717 ProcessorBox::paste_processors ()
2719 if (_rr_selection.processors.empty()) {
2723 paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
2727 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
2730 if (_rr_selection.processors.empty()) {
2734 paste_processor_state (_rr_selection.processors.get_node().children(), before);
2738 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
2740 XMLNodeConstIterator niter;
2741 list<boost::shared_ptr<Processor> > copies;
2743 if (nlist.empty()) {
2747 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2749 XMLProperty const * type = (*niter)->property ("type");
2750 XMLProperty const * role = (*niter)->property ("role");
2753 boost::shared_ptr<Processor> p;
2755 if (type->value() == "meter" ||
2756 type->value() == "main-outs" ||
2757 type->value() == "amp" ||
2758 type->value() == "intreturn") {
2759 /* do not paste meter, main outs, amp or internal returns */
2762 } else if (type->value() == "intsend") {
2764 /* aux sends are OK, but those used for
2765 * other purposes, are not.
2770 if (role->value() != "Aux") {
2774 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
2775 XMLNode n (**niter);
2776 InternalSend* s = new InternalSend (*_session, sendpan, _route->mute_master(),
2777 _route, boost::shared_ptr<Route>(), Delivery::Aux);
2779 IOProcessor::prepare_for_reset (n, s->name());
2781 if (s->set_state (n, Stateful::loading_state_version)) {
2788 } else if (type->value() == "send") {
2790 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
2791 XMLNode n (**niter);
2793 Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
2795 IOProcessor::prepare_for_reset (n, s->name());
2797 if (s->set_state (n, Stateful::loading_state_version)) {
2804 } else if (type->value() == "return") {
2806 XMLNode n (**niter);
2807 Return* r = new Return (*_session);
2809 IOProcessor::prepare_for_reset (n, r->name());
2811 if (r->set_state (n, Stateful::loading_state_version)) {
2818 } else if (type->value() == "port") {
2820 XMLNode n (**niter);
2821 PortInsert* pi = new PortInsert (*_session, _route->pannable (), _route->mute_master ());
2823 IOProcessor::prepare_for_reset (n, pi->name());
2825 if (pi->set_state (n, Stateful::loading_state_version)) {
2831 /* XXX its a bit limiting to assume that everything else
2834 p.reset (new PluginInsert (*_session));
2835 PBD::ID id = p->id();
2836 p->set_state (**niter, Stateful::current_state_version);
2837 boost::dynamic_pointer_cast<PluginInsert>(p)->update_id (id);
2840 copies.push_back (p);
2844 error << _("plugin insert constructor failed") << endmsg;
2848 if (copies.empty()) {
2852 if (_route->add_processors (copies, p)) {
2855 "Copying the set of processors on the clipboard failed,\n\
2856 probably because the I/O configuration of the plugins\n\
2857 could not match the configuration of this track.");
2858 MessageDialog am (msg);
2864 ProcessorBox::get_selected_processors (ProcSelection& processors) const
2866 const list<ProcessorEntry*> selection = processor_display.selection ();
2867 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
2868 processors.push_back ((*i)->processor ());
2873 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
2875 list<ProcessorEntry*> selection = processor_display.selection ();
2876 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
2877 (this->*method) ((*i)->processor ());
2882 ProcessorBox::all_visible_processors_active (bool state)
2884 _route->all_visible_processors_active (state);
2888 ProcessorBox::ab_plugins ()
2890 _route->ab_plugins (ab_direction);
2891 ab_direction = !ab_direction;
2896 ProcessorBox::clear_processors ()
2899 vector<string> choices;
2901 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
2902 "(this cannot be undone)"), _route->name());
2904 choices.push_back (_("Cancel"));
2905 choices.push_back (_("Yes, remove them all"));
2907 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
2909 if (prompter.run () == 1) {
2910 _route->clear_processors (PreFader);
2911 _route->clear_processors (PostFader);
2916 ProcessorBox::clear_processors (Placement p)
2919 vector<string> choices;
2921 if (p == PreFader) {
2922 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
2923 "(this cannot be undone)"), _route->name());
2925 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
2926 "(this cannot be undone)"), _route->name());
2929 choices.push_back (_("Cancel"));
2930 choices.push_back (_("Yes, remove them all"));
2932 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
2934 if (prompter.run () == 1) {
2935 _route->clear_processors (p);
2940 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
2942 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
2943 if (at && at->freeze_state() == AudioTrack::Frozen) {
2948 boost::dynamic_pointer_cast<Send> (processor) ||
2949 boost::dynamic_pointer_cast<Return> (processor) ||
2950 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
2951 boost::dynamic_pointer_cast<PortInsert> (processor)
2960 ProcessorBox::one_processor_can_be_edited ()
2962 list<ProcessorEntry*> selection = processor_display.selection ();
2963 list<ProcessorEntry*>::iterator i = selection.begin();
2964 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
2968 return (i != selection.end());
2972 ProcessorBox::get_editor_window (boost::shared_ptr<Processor> processor, bool use_custom)
2974 boost::shared_ptr<Send> send;
2975 boost::shared_ptr<InternalSend> internal_send;
2976 boost::shared_ptr<Return> retrn;
2977 boost::shared_ptr<PluginInsert> plugin_insert;
2978 boost::shared_ptr<PortInsert> port_insert;
2981 /* This method may or may not return a Window, but if it does not it
2982 * will modify the parent mixer strip appearance layout to allow
2983 * "editing" the @param processor that was passed in.
2985 * So for example, if the processor is an Amp (gain), the parent strip
2986 * will be forced back into a model where the fader controls the main gain.
2987 * If the processor is a send, then we map the send controls onto the
2990 * Plugins and others will return a window for control.
2993 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
2995 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
3000 if (boost::dynamic_pointer_cast<Amp> (processor) && boost::dynamic_pointer_cast<Amp> (processor)->gain_control()->parameter().type() == GainAutomation) {
3002 if (_parent_strip) {
3003 _parent_strip->revert_to_default_display ();
3006 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
3008 if (!_session->engine().connected()) {
3012 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
3014 gidget = new SendUIWindow (send, _session);
3017 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
3019 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
3020 /* no GUI for these */
3024 if (!_session->engine().connected()) {
3028 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
3030 ReturnUIWindow *return_ui;
3031 Window* w = get_processor_ui (retrn);
3035 return_ui = new ReturnUIWindow (retrn, _session);
3036 return_ui->set_title (retrn->name ());
3037 set_processor_ui (send, return_ui);
3040 return_ui = dynamic_cast<ReturnUIWindow *> (w);
3045 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
3047 PluginUIWindow *plugin_ui;
3049 /* these are both allowed to be null */
3051 Window* w = get_processor_ui (plugin_insert);
3054 plugin_ui = new PluginUIWindow (plugin_insert, false, use_custom);
3055 plugin_ui->set_title (generate_processor_title (plugin_insert));
3056 set_processor_ui (plugin_insert, plugin_ui);
3059 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
3064 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
3066 if (!_session->engine().connected()) {
3067 MessageDialog msg ( _("Not connected to audio engine - no I/O changes are possible"));
3072 PortInsertWindow *io_selector;
3074 Window* w = get_processor_ui (port_insert);
3077 io_selector = new PortInsertWindow (_session, port_insert);
3078 set_processor_ui (port_insert, io_selector);
3081 io_selector = dynamic_cast<PortInsertWindow *> (w);
3084 gidget = io_selector;
3091 ProcessorBox::get_generic_editor_window (boost::shared_ptr<Processor> processor)
3093 boost::shared_ptr<PluginInsert> plugin_insert
3094 = boost::dynamic_pointer_cast<PluginInsert>(processor);
3096 if (!plugin_insert) {
3100 PluginUIWindow* win = new PluginUIWindow (plugin_insert, true, false);
3101 win->set_title (generate_processor_title (plugin_insert));
3107 ProcessorBox::register_actions ()
3109 processor_box_actions = myactions.create_action_group (X_("ProcessorMenu"));
3111 Glib::RefPtr<Action> act;
3114 myactions.register_action (processor_box_actions, X_("newplugin"), _("New Plugin"),
3115 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
3117 act = myactions.register_action (processor_box_actions, X_("newlua"), _("New Lua Proc"),
3118 sigc::ptr_fun (ProcessorBox::rb_choose_lua));
3119 act = myactions.register_action (processor_box_actions, X_("newinsert"), _("New Insert"),
3120 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
3121 ActionManager::engine_sensitive_actions.push_back (act);
3122 act = myactions.register_action (processor_box_actions, X_("newsend"), _("New External Send ..."),
3123 sigc::ptr_fun (ProcessorBox::rb_choose_send));
3124 ActionManager::engine_sensitive_actions.push_back (act);
3126 myactions.register_action (processor_box_actions, X_("newaux"), _("New Aux Send ..."));
3128 myactions.register_action (processor_box_actions, X_("controls"), _("Controls"));
3129 myactions.register_action (processor_box_actions, X_("send_options"), _("Send Options"));
3131 myactions.register_action (processor_box_actions, X_("clear"), _("Clear (all)"),
3132 sigc::ptr_fun (ProcessorBox::rb_clear));
3133 myactions.register_action (processor_box_actions, X_("clear_pre"), _("Clear (pre-fader)"),
3134 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
3135 myactions.register_action (processor_box_actions, X_("clear_post"), _("Clear (post-fader)"),
3136 sigc::ptr_fun (ProcessorBox::rb_clear_post));
3138 /* standard editing stuff */
3140 cut_action = myactions.register_action (processor_box_actions, X_("cut"), _("Cut"),
3141 sigc::ptr_fun (ProcessorBox::rb_cut));
3142 copy_action = myactions.register_action (processor_box_actions, X_("copy"), _("Copy"),
3143 sigc::ptr_fun (ProcessorBox::rb_copy));
3144 delete_action = myactions.register_action (processor_box_actions, X_("delete"), _("Delete"),
3145 sigc::ptr_fun (ProcessorBox::rb_delete));
3147 ActionManager::plugin_selection_sensitive_actions.push_back (cut_action);
3148 ActionManager::plugin_selection_sensitive_actions.push_back (copy_action);
3149 ActionManager::plugin_selection_sensitive_actions.push_back (delete_action);
3151 paste_action = myactions.register_action (processor_box_actions, X_("paste"), _("Paste"),
3152 sigc::ptr_fun (ProcessorBox::rb_paste));
3153 rename_action = myactions.register_action (processor_box_actions, X_("rename"), _("Rename"),
3154 sigc::ptr_fun (ProcessorBox::rb_rename));
3155 myactions.register_action (processor_box_actions, X_("selectall"), _("Select All"),
3156 sigc::ptr_fun (ProcessorBox::rb_select_all));
3157 myactions.register_action (processor_box_actions, X_("deselectall"), _("Deselect All"),
3158 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
3160 /* activation etc. */
3162 myactions.register_action (processor_box_actions, X_("activate_all"), _("Activate All"),
3163 sigc::ptr_fun (ProcessorBox::rb_activate_all));
3164 myactions.register_action (processor_box_actions, X_("deactivate_all"), _("Deactivate All"),
3165 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
3166 myactions.register_action (processor_box_actions, X_("ab_plugins"), _("A/B Plugins"),
3167 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
3170 edit_action = myactions.register_action (
3171 processor_box_actions, X_("edit"), _("Edit..."),
3172 sigc::ptr_fun (ProcessorBox::rb_edit));
3174 edit_generic_action = myactions.register_action (
3175 processor_box_actions, X_("edit-generic"), _("Edit with generic controls..."),
3176 sigc::ptr_fun (ProcessorBox::rb_edit_generic));
3182 ProcessorBox::rb_edit_generic ()
3184 if (_current_processor_box == 0) {
3188 _current_processor_box->for_selected_processors (&ProcessorBox::generic_edit_processor);
3192 ProcessorBox::rb_ab_plugins ()
3194 if (_current_processor_box == 0) {
3198 _current_processor_box->ab_plugins ();
3202 ProcessorBox::rb_choose_plugin ()
3204 if (_current_processor_box == 0) {
3207 _current_processor_box->choose_plugin ();
3211 ProcessorBox::rb_choose_lua ()
3213 if (_current_processor_box == 0) {
3216 _current_processor_box->choose_lua ();
3220 ProcessorBox::rb_choose_insert ()
3222 if (_current_processor_box == 0) {
3225 _current_processor_box->choose_insert ();
3229 ProcessorBox::rb_choose_send ()
3231 if (_current_processor_box == 0) {
3234 _current_processor_box->choose_send ();
3238 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
3240 if (_current_processor_box == 0) {
3244 _current_processor_box->choose_aux (wr);
3248 ProcessorBox::rb_clear ()
3250 if (_current_processor_box == 0) {
3254 _current_processor_box->clear_processors ();
3259 ProcessorBox::rb_clear_pre ()
3261 if (_current_processor_box == 0) {
3265 _current_processor_box->clear_processors (PreFader);
3270 ProcessorBox::rb_clear_post ()
3272 if (_current_processor_box == 0) {
3276 _current_processor_box->clear_processors (PostFader);
3280 ProcessorBox::rb_cut ()
3282 if (_current_processor_box == 0) {
3286 _current_processor_box->processor_operation (ProcessorsCut);
3290 ProcessorBox::rb_delete ()
3292 if (_current_processor_box == 0) {
3296 _current_processor_box->processor_operation (ProcessorsDelete);
3300 ProcessorBox::rb_copy ()
3302 if (_current_processor_box == 0) {
3305 _current_processor_box->processor_operation (ProcessorsCopy);
3309 ProcessorBox::rb_paste ()
3311 if (_current_processor_box == 0) {
3315 _current_processor_box->processor_operation (ProcessorsPaste);
3319 ProcessorBox::rb_rename ()
3321 if (_current_processor_box == 0) {
3324 _current_processor_box->rename_processors ();
3328 ProcessorBox::rb_select_all ()
3330 if (_current_processor_box == 0) {
3334 _current_processor_box->processor_operation (ProcessorsSelectAll);
3338 ProcessorBox::rb_deselect_all ()
3340 if (_current_processor_box == 0) {
3344 _current_processor_box->deselect_all_processors ();
3348 ProcessorBox::rb_activate_all ()
3350 if (_current_processor_box == 0) {
3354 _current_processor_box->all_visible_processors_active (true);
3358 ProcessorBox::rb_deactivate_all ()
3360 if (_current_processor_box == 0) {
3363 _current_processor_box->all_visible_processors_active (false);
3367 ProcessorBox::rb_edit ()
3369 if (_current_processor_box == 0) {
3373 _current_processor_box->for_selected_processors (&ProcessorBox::edit_processor);
3377 ProcessorBox::edit_aux_send (boost::shared_ptr<Processor> processor)
3379 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
3383 if (_parent_strip) {
3384 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
3385 if (_parent_strip->current_delivery() == send) {
3386 _parent_strip->revert_to_default_display ();
3388 _parent_strip->show_send(send);
3395 ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
3400 if (edit_aux_send (processor)) {
3404 ProcessorWindowProxy* proxy = find_window_proxy (processor);
3407 proxy->set_custom_ui_mode (true);
3408 proxy->show_the_right_window ();
3413 ProcessorBox::generic_edit_processor (boost::shared_ptr<Processor> processor)
3418 if (edit_aux_send (processor)) {
3422 ProcessorWindowProxy* proxy = find_window_proxy (processor);
3425 proxy->set_custom_ui_mode (false);
3426 proxy->show_the_right_window ();
3431 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
3433 if (!what_changed.contains (ARDOUR::Properties::name)) {
3437 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
3439 boost::shared_ptr<Processor> processor;
3440 boost::shared_ptr<PluginInsert> plugin_insert;
3441 boost::shared_ptr<Send> send;
3443 list<ProcessorEntry*> children = processor_display.children();
3445 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
3447 processor = (*iter)->processor ();
3453 Window* w = get_processor_ui (processor);
3459 /* rename editor windows for sends and plugins */
3461 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
3462 w->set_title (send->name ());
3463 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
3464 w->set_title (generate_processor_title (plugin_insert));
3470 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
3472 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
3473 string::size_type email_pos;
3475 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
3476 maker = maker.substr (0, email_pos - 1);
3479 if (maker.length() > 32) {
3480 maker = maker.substr (0, 32);
3484 SessionObject* owner = pi->owner();
3487 return string_compose(_("%1: %2 (by %3)"), owner->name(), pi->name(), maker);
3489 return string_compose(_("%1 (by %2)"), pi->name(), maker);
3493 /** @param p Processor.
3494 * @return the UI window for \a p.
3497 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
3499 ProcessorWindowProxy* wp = p->window_proxy();
3506 /** Make a note of the UI window that a processor is using.
3507 * @param p Processor.
3508 * @param w UI window.
3511 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
3513 assert (p->window_proxy());
3515 p->window_proxy()->use_window (*w);
3519 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
3521 boost::shared_ptr<Delivery> d = w.lock ();
3526 list<ProcessorEntry*> children = processor_display.children ();
3527 list<ProcessorEntry*>::const_iterator i = children.begin();
3528 while (i != children.end() && (*i)->processor() != d) {
3532 if (i == children.end()) {
3533 processor_display.set_active (0);
3535 processor_display.set_active (*i);
3539 /** Called to repair the damage of Editor::show_window doing a show_all() */
3541 ProcessorBox::hide_things ()
3543 list<ProcessorEntry*> c = processor_display.children ();
3544 for (list<ProcessorEntry*>::iterator i = c.begin(); i != c.end(); ++i) {
3545 (*i)->hide_things ();
3550 ProcessorBox::processor_menu_unmapped ()
3552 processor_display.remove_placeholder ();
3553 /* make all possibly-desensitized actions sensitive again so that
3554 they be activated by other means (e.g. bindings)
3556 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, true);
3560 ProcessorBox::entry_gui_object_state (ProcessorEntry* entry)
3562 if (!_parent_strip) {
3566 GUIObjectState& st = _parent_strip->gui_object_state ();
3568 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
3570 return st.get_or_add_node (strip, entry->state_id());
3574 ProcessorBox::update_gui_object_state (ProcessorEntry* entry)
3576 XMLNode* proc = entry_gui_object_state (entry);
3581 /* XXX: this is a bit inefficient; we just remove all child nodes and re-add them */
3582 proc->remove_nodes_and_delete (X_("Object"));
3583 entry->add_control_state (proc);
3587 ProcessorBox::is_editor_mixer_strip() const
3589 return _parent_strip && !_parent_strip->mixer_owned();
3592 ProcessorWindowProxy::ProcessorWindowProxy (string const & name, ProcessorBox* box, boost::weak_ptr<Processor> processor)
3593 : WM::ProxyBase (name, string())
3594 , _processor_box (box)
3595 , _processor (processor)
3597 , want_custom (false)
3599 boost::shared_ptr<Processor> p = _processor.lock ();
3603 p->DropReferences.connect (going_away_connection, MISSING_INVALIDATOR, boost::bind (&ProcessorWindowProxy::processor_going_away, this), gui_context());
3606 ProcessorWindowProxy::~ProcessorWindowProxy()
3608 /* processor window proxies do not own the windows they create with
3609 * ::get(), so set _window to null before the normal WindowProxy method
3616 ProcessorWindowProxy::processor_going_away ()
3620 WM::Manager::instance().remove (this);
3621 /* should be no real reason to do this, since the object that would
3622 send DropReferences is about to be deleted, but lets do it anyway.
3624 going_away_connection.disconnect();
3627 ARDOUR::SessionHandlePtr*
3628 ProcessorWindowProxy::session_handle()
3635 ProcessorWindowProxy::get_state ()
3638 node = &ProxyBase::get_state();
3639 node->add_property (X_("custom-ui"), is_custom? X_("yes") : X_("no"));
3644 ProcessorWindowProxy::set_state (const XMLNode& node, int /*version*/)
3646 XMLNodeList children = node.children ();
3647 XMLNodeList::const_iterator i = children.begin ();
3648 while (i != children.end()) {
3649 XMLProperty* prop = (*i)->property (X_("name"));
3650 if ((*i)->name() == X_("Window") && prop && prop->value() == _name) {
3656 if (i != children.end()) {
3658 if ((prop = (*i)->property (X_("custom-ui"))) != 0) {
3659 want_custom = PBD::string_is_affirmative (prop->value ());
3663 return ProxyBase::set_state (node, 0);
3667 ProcessorWindowProxy::get (bool create)
3669 boost::shared_ptr<Processor> p = _processor.lock ();
3674 if (_window && (is_custom != want_custom)) {
3675 /* drop existing window - wrong type */
3684 is_custom = want_custom;
3685 _window = _processor_box->get_editor_window (p, is_custom);
3696 ProcessorWindowProxy::show_the_right_window ()
3698 if (_window && (is_custom != want_custom)) {
3699 /* drop existing window - wrong type */
3704 is_custom = want_custom;
3711 ProcessorBox::load_bindings ()
3713 bindings = Bindings::get_bindings (X_("processor box"), myactions);