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 "canvas/utils.h"
32 #include <glibmm/miscutils.h>
33 #include <glibmm/fileutils.h>
35 #include <gtkmm/messagedialog.h>
37 #include <gtkmm2ext/gtk_ui.h>
38 #include <gtkmm2ext/utils.h>
39 #include <gtkmm2ext/choice.h>
40 #include <gtkmm2ext/utils.h>
41 #include <gtkmm2ext/doi.h>
42 #include <gtkmm2ext/rgb_macros.h>
44 #include "ardour/amp.h"
45 #include "ardour/audio_track.h"
46 #include "ardour/audioengine.h"
47 #include "ardour/internal_return.h"
48 #include "ardour/internal_send.h"
49 #include "ardour/luaproc.h"
50 #include "ardour/luascripting.h"
51 #include "ardour/meter.h"
52 #include "ardour/panner_shell.h"
53 #include "ardour/plugin_insert.h"
54 #include "ardour/pannable.h"
55 #include "ardour/port_insert.h"
56 #include "ardour/profile.h"
57 #include "ardour/return.h"
58 #include "ardour/route.h"
59 #include "ardour/send.h"
60 #include "ardour/session.h"
61 #include "ardour/types.h"
63 #include "LuaBridge/LuaBridge.h"
66 #include "ardour_dialog.h"
67 #include "ardour_ui.h"
68 #include "gui_thread.h"
69 #include "io_selector.h"
71 #include "luainstance.h"
73 #include "mixer_strip.h"
74 #include "plugin_pin_dialog.h"
75 #include "plugin_selector.h"
76 #include "plugin_ui.h"
77 #include "port_insert_ui.h"
78 #include "processor_box.h"
79 #include "public_editor.h"
80 #include "return_ui.h"
81 #include "route_processor_selection.h"
82 #include "script_selector.h"
86 #include "new_plugin_preset_dialog.h"
90 #ifdef AUDIOUNIT_SUPPORT
95 bool ProcessorBox::show_all_processors = false;
99 using namespace ARDOUR;
102 using namespace Glib;
103 using namespace Gtkmm2ext;
105 ProcessorBox* ProcessorBox::_current_processor_box = 0;
106 RefPtr<Action> ProcessorBox::paste_action;
107 RefPtr<Action> ProcessorBox::cut_action;
108 RefPtr<Action> ProcessorBox::copy_action;
109 RefPtr<Action> ProcessorBox::rename_action;
110 RefPtr<Action> ProcessorBox::delete_action;
111 RefPtr<Action> ProcessorBox::backspace_action;
112 RefPtr<Action> ProcessorBox::manage_pins_action;
113 RefPtr<Action> ProcessorBox::edit_action;
114 RefPtr<Action> ProcessorBox::edit_generic_action;
115 RefPtr<ActionGroup> ProcessorBox::processor_box_actions;
116 Gtkmm2ext::ActionMap ProcessorBox::myactions (X_("processor box"));
117 Gtkmm2ext::Bindings* ProcessorBox::bindings = 0;
120 // TODO consolidate with PluginPinDialog::set_color
121 static void set_routing_color (cairo_t* cr, bool midi)
123 static const uint32_t audio_port_color = 0x4A8A0EFF; // Green
124 static const uint32_t midi_port_color = 0x960909FF; //Red
127 cairo_set_source_rgb (cr,
128 UINT_RGBA_R_FLT(midi_port_color),
129 UINT_RGBA_G_FLT(midi_port_color),
130 UINT_RGBA_B_FLT(midi_port_color));
132 cairo_set_source_rgb (cr,
133 UINT_RGBA_R_FLT(audio_port_color),
134 UINT_RGBA_G_FLT(audio_port_color),
135 UINT_RGBA_B_FLT(audio_port_color));
139 ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processor> p, Width w)
140 : _button (ArdourButton::led_default_elements)
141 , _position (PreFader)
145 , _unknown_processor(false)
151 , output_routing_icon(false)
156 _button.set_distinct_led_click (true);
157 _button.set_fallthrough_to_parent(true);
158 _button.set_led_left (true);
159 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &ProcessorEntry::led_clicked));
160 _button.set_text (name (_width));
162 if (boost::dynamic_pointer_cast<PeakMeter> (_processor)) {
163 _button.set_elements(ArdourButton::Element(_button.elements() & ~ArdourButton::Indicator));
165 if (boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
166 _button.set_elements(ArdourButton::Element(_button.elements() & ~ArdourButton::Indicator));
167 _unknown_processor = true;
170 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
171 if (pi && pi->plugin()) {
172 _plugin_preset_pointer = PluginPresetPtr (new PluginPreset (pi->plugin()->get_info()));
177 _vbox.pack_start (routing_icon);
178 _vbox.pack_start (input_icon);
179 _vbox.pack_start (_button, true, true);
181 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
182 if (pi && pi->plugin() && pi->plugin()->has_inline_display()) {
183 if (pi->plugin()->get_info()->type != ARDOUR::Lua) {
184 _plugin_display = new PluginDisplay (*this, pi->plugin(),
185 std::max (60.f, rintf(112.f * UIConfiguration::instance().get_ui_scale())));
187 assert (boost::dynamic_pointer_cast<LuaProc>(pi->plugin()));
188 _plugin_display = new LuaPluginDisplay (*this, boost::dynamic_pointer_cast<LuaProc>(pi->plugin()),
189 std::max (60.f, rintf(112.f * UIConfiguration::instance().get_ui_scale())));
191 _vbox.pack_start (*_plugin_display);
192 _plugin_display->set_no_show_all (true);
193 if (UIConfiguration::instance().get_show_inline_display_by_default ()) {
194 _plugin_display->show ();
197 _vbox.pack_end (output_routing_icon);
198 _vbox.pack_end (output_icon);
200 _button.set_active (_processor->enabled ());
202 input_icon.set_no_show_all(true);
203 routing_icon.set_no_show_all(true);
204 output_icon.set_no_show_all(true);
205 output_routing_icon.set_no_show_all(true);
211 output_routing_icon.hide();
213 _processor->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_active_changed, this), gui_context());
214 _processor->PropertyChanged.connect (name_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_property_changed, this, _1), gui_context());
215 _processor->ConfigurationChanged.connect (config_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_configuration_changed, this, _1, _2), gui_context());
217 set<Evoral::Parameter> p = _processor->what_can_be_automated ();
218 for (set<Evoral::Parameter>::iterator i = p.begin(); i != p.end(); ++i) {
220 std::string label = _processor->describe_parameter (*i);
222 if (boost::dynamic_pointer_cast<Send> (_processor)) {
224 } else if (boost::dynamic_pointer_cast<Return> (_processor)) {
228 Control* c = new Control (_processor->automation_control (*i), label);
230 _controls.push_back (c);
232 if (boost::dynamic_pointer_cast<Amp> (_processor) == 0) {
233 /* Add non-Amp (Fader & Trim) controls to the processor box */
234 _vbox.pack_start (c->box);
241 _vbox.set_size_request (-1, _button.size_request().height);
245 ProcessorEntry::~ProcessorEntry ()
247 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
250 delete _plugin_display;
254 ProcessorEntry::action_widget ()
260 ProcessorEntry::widget ()
266 ProcessorEntry::drag_text () const
272 ProcessorEntry::can_copy_state (Gtkmm2ext::DnDVBoxChild* o) const
274 ProcessorEntry *other = dynamic_cast<ProcessorEntry*> (o);
278 boost::shared_ptr<ARDOUR::Processor> otherproc = other->processor();
279 boost::shared_ptr<PluginInsert> my_pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
280 boost::shared_ptr<PluginInsert> ot_pi = boost::dynamic_pointer_cast<PluginInsert> (otherproc);
281 if (boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
284 if (boost::dynamic_pointer_cast<UnknownProcessor> (otherproc)) {
287 if (!my_pi || !ot_pi) {
290 if (my_pi->type() != ot_pi->type()) {
293 boost::shared_ptr<Plugin> my_p = my_pi->plugin();
294 boost::shared_ptr<Plugin> ot_p = ot_pi->plugin();
295 if (!my_p || !ot_p) {
298 if (my_p->unique_id() != ot_p->unique_id()) {
305 ProcessorEntry::drag_data_get (Glib::RefPtr<Gdk::DragContext> const, Gtk::SelectionData &data)
307 if (data.get_target() == "PluginPresetPtr") {
308 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
310 if (!_plugin_preset_pointer || !pi) {
311 data.set (data.get_target(), 8, NULL, 0);
315 boost::shared_ptr<ARDOUR::Plugin> plugin = pi->plugin();
318 PluginManager& manager (PluginManager::instance());
319 bool fav = manager.get_status (_plugin_preset_pointer->_pip) == PluginManager::Favorite;
321 NewPluginPresetDialog d (plugin,
322 string_compose(_("New Favorite Preset for \"%1\""),_plugin_preset_pointer->_pip->name), !fav);
324 _plugin_preset_pointer->_preset.valid = false;
327 case Gtk::RESPONSE_CANCEL:
328 data.set (data.get_target(), 8, NULL, 0);
332 case Gtk::RESPONSE_NO:
335 case Gtk::RESPONSE_ACCEPT:
336 if (d.name().empty()) {
341 plugin->remove_preset (d.name ());
344 Plugin::PresetRecord const r = plugin->save_preset (d.name());
346 if (!r.uri.empty ()) {
347 _plugin_preset_pointer->_preset.uri = r.uri;
348 _plugin_preset_pointer->_preset.label = r.label;
349 _plugin_preset_pointer->_preset.user = r.user;
350 _plugin_preset_pointer->_preset.valid = r.valid;
353 data.set (data.get_target(), 8, (const guchar *) &_plugin_preset_pointer, sizeof (PluginPresetPtr));
360 ProcessorEntry::set_position (Position p, uint32_t num)
368 ProcessorEntry::set_visual_state (Gtkmm2ext::VisualState s, bool yn)
371 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() | s));
373 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() & ~s));
378 ProcessorEntry::setup_visuals ()
380 if (_unknown_processor) {
381 _button.set_name ("processor stub");
384 boost::shared_ptr<Send> send;
385 if ((send = boost::dynamic_pointer_cast<Send> (_processor))) {
386 if (send->remove_on_disconnect ()) {
387 _button.set_name ("processor sidechain");
392 boost::shared_ptr<InternalSend> aux;
393 if ((aux = boost::dynamic_pointer_cast<InternalSend> (_processor))) {
394 if (aux->allow_feedback ()) {
395 _button.set_name ("processor auxfeedback");
402 if (_plugin_display) { _plugin_display->set_name ("processor prefader"); }
403 _button.set_name ("processor prefader");
407 _button.set_name ("processor fader");
411 if (_plugin_display) { _plugin_display->set_name ("processor postfader"); }
412 _button.set_name ("processor postfader");
418 boost::shared_ptr<Processor>
419 ProcessorEntry::processor () const
422 return boost::shared_ptr<Processor>();
428 ProcessorEntry::set_enum_width (Width w)
431 _button.set_text (name (_width));
435 ProcessorEntry::led_clicked(GdkEventButton *ev)
437 bool ctrl_shift_pressed = false;
438 Keyboard::ModifierMask ctrl_shift_mask = Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier);
440 if (Keyboard::modifier_state_equals (ev->state, ctrl_shift_mask)) {
441 ctrl_shift_pressed = true;
445 if (_button.get_active ()) {
446 if (ctrl_shift_pressed) {
447 _parent->all_visible_processors_active(false);
449 if (_position == Fader) {
450 _processor->enable (false);
454 _processor->enable (false);
458 if (ctrl_shift_pressed) {
459 _parent->all_visible_processors_active(true);
461 if (_position == Fader) {
462 _processor->enable (true);
466 _processor->enable (true);
473 ProcessorEntry::processor_active_changed ()
476 _button.set_active (_processor->enabled ());
481 ProcessorEntry::processor_property_changed (const PropertyChange& what_changed)
483 if (what_changed.contains (ARDOUR::Properties::name)) {
484 _button.set_text (name (_width));
490 ProcessorEntry::processor_configuration_changed (const ChanCount in, const ChanCount out)
492 _parent->setup_routing_feeds ();
493 input_icon.queue_draw();
494 output_icon.queue_draw();
495 routing_icon.queue_draw();
496 output_routing_icon.queue_draw();
500 ProcessorEntry::setup_tooltip ()
503 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
505 std::string postfix = "";
508 if (pi->plugin()->has_inline_display()) {
509 postfix += string_compose(_("\n%1+double-click to toggle inline-display"), Keyboard::tertiary_modifier_name ());
512 if ((replicated = pi->get_count()) > 1) {
513 postfix += string_compose(_("\nThis mono plugin has been replicated %1 times."), replicated);
516 if (pi->plugin()->has_editor()) {
517 ARDOUR_UI_UTILS::set_tooltip (_button,
518 string_compose (_("<b>%1</b>\nDouble-click to show GUI.\n%2+double-click to show generic GUI.%3"), name (Wide), Keyboard::secondary_modifier_name (), postfix));
520 ARDOUR_UI_UTILS::set_tooltip (_button,
521 string_compose (_("<b>%1</b>\nDouble-click to show generic GUI.%2"), name (Wide), postfix));
525 if(boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
526 ARDOUR_UI::instance()->set_tip (_button,
527 string_compose (_("<b>%1</b>\nThe Plugin is not available on this system\nand has been replaced by a stub."), name (Wide)));
530 boost::shared_ptr<Send> send;
531 if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
532 !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
533 if (send->remove_on_disconnect ()) {
534 ARDOUR_UI_UTILS::set_tooltip (_button, string_compose ("<b>> %1</b>\nThis (sidechain) send will be removed when disconnected.", _processor->name()));
536 ARDOUR_UI_UTILS::set_tooltip (_button, string_compose ("<b>> %1</b>", _processor->name()));
541 ARDOUR_UI_UTILS::set_tooltip (_button, string_compose ("<b>%1</b>", name (Wide)));
545 ProcessorEntry::name (Width w) const
547 boost::shared_ptr<Send> send;
554 if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
555 !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
558 std::string send_name;
559 bool pretty_ok = true;
561 if (send->remove_on_disconnect ()) {
562 // assume it's a sidechain, find pretty name of connected port(s)
563 PortSet& ps (send->output ()->ports ());
564 for (PortSet::iterator i = ps.begin (); i != ps.end () && pretty_ok; ++i) {
565 vector<string> connections;
566 if (i->get_connections (connections)) {
567 vector<string>::const_iterator ci;
568 for (ci = connections.begin(); ci != connections.end(); ++ci) {
569 std::string pn = AudioEngine::instance()->get_pretty_name_by_name (*ci);
573 if (send_name.empty ()) {
575 } else if (send_name != pn) {
576 // pretty names don't match
589 /* grab the send name out of its overall name */
590 if (send_name.empty()) {
591 send_name = send->name();
592 string::size_type lbracket, rbracket;
593 lbracket = send_name.find ('[');
594 rbracket = send_name.find (']');
595 send_name = send_name.substr (lbracket+1, lbracket-rbracket-1);
600 name_display += send_name;
603 name_display += PBD::short_version (send_name, 5);
608 boost::shared_ptr<ARDOUR::PluginInsert> pi;
610 if ((pi = boost::dynamic_pointer_cast<ARDOUR::PluginInsert> (_processor)) != 0
611 && (replicated = pi->get_count()) > 1)
613 name_display += string_compose(_("(%1x1) "), replicated);
618 name_display += _processor->display_name();
621 name_display += PBD::short_version (_processor->display_name(), 5);
631 ProcessorEntry::show_all_controls ()
633 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
634 (*i)->set_visible (true);
637 _parent->update_gui_object_state (this);
641 ProcessorEntry::hide_all_controls ()
643 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
644 (*i)->set_visible (false);
647 _parent->update_gui_object_state (this);
651 ProcessorEntry::add_control_state (XMLNode* node) const
653 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
654 (*i)->add_state (node);
657 if (_plugin_display) {
658 XMLNode* c = new XMLNode (X_("Object"));
659 c->set_property (X_("id"), X_("InlineDisplay"));
660 c->set_property (X_("visible"), _plugin_display->is_visible ());
661 node->add_child_nocopy (*c);
666 ProcessorEntry::set_control_state (XMLNode const * node)
668 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
669 (*i)->set_state (node);
672 if (_plugin_display) {
673 XMLNode* n = GUIObjectState::get_node (node, X_("InlineDisplay"));
677 if (n->get_property (X_("visible"), visible)) {
679 _plugin_display->show ();
681 _plugin_display->hide ();
688 ProcessorEntry::state_id () const
690 return string_compose ("processor %1", _processor->id().to_s());
694 ProcessorEntry::hide_things ()
696 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
697 (*i)->hide_things ();
703 ProcessorEntry::build_controls_menu ()
705 using namespace Menu_Helpers;
706 Menu* menu = manage (new Menu);
707 MenuList& items = menu->items ();
709 if (_plugin_display) {
710 items.push_back (CheckMenuElem (_("Inline Display")));
711 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
712 c->set_active (_plugin_display->is_visible ());
713 c->signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::toggle_inline_display_visibility));
714 items.push_back (SeparatorElem ());
718 MenuElem (_("Show All Controls"), sigc::mem_fun (*this, &ProcessorEntry::show_all_controls))
722 MenuElem (_("Hide All Controls"), sigc::mem_fun (*this, &ProcessorEntry::hide_all_controls))
725 if (!_controls.empty ()) {
726 items.push_back (SeparatorElem ());
729 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
730 items.push_back (CheckMenuElem ((*i)->name ()));
731 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
732 c->set_active ((*i)->visible ());
733 c->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &ProcessorEntry::toggle_control_visibility), *i));
740 ProcessorEntry::toggle_inline_display_visibility ()
742 if (_plugin_display->is_visible ()) {
743 _plugin_display->hide();
745 _plugin_display->show();
747 _parent->update_gui_object_state (this);
751 ProcessorEntry::toggle_control_visibility (Control* c)
753 c->set_visible (!c->visible ());
754 _parent->update_gui_object_state (this);
758 ProcessorEntry::build_send_options_menu ()
760 using namespace Menu_Helpers;
761 Menu* menu = manage (new Menu);
762 MenuList& items = menu->items ();
764 if (!ARDOUR::Profile->get_mixbus()) {
765 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (_processor);
767 items.push_back (CheckMenuElem (_("Link panner controls")));
768 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
769 c->set_active (send->panner_shell()->is_linked_to_route());
770 c->signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::toggle_panner_link));
774 boost::shared_ptr<InternalSend> aux = boost::dynamic_pointer_cast<InternalSend> (_processor);
776 items.push_back (CheckMenuElem (_("Allow Feedback Loop")));
777 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
778 c->set_active (aux->allow_feedback());
779 c->signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::toggle_allow_feedback));
785 ProcessorEntry::toggle_panner_link ()
787 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (_processor);
789 send->panner_shell()->set_linked_to_route(!send->panner_shell()->is_linked_to_route());
794 ProcessorEntry::toggle_allow_feedback ()
796 boost::shared_ptr<InternalSend> aux = boost::dynamic_pointer_cast<InternalSend> (_processor);
798 aux->set_allow_feedback (!aux->allow_feedback ());
802 ProcessorEntry::Control::Control (boost::shared_ptr<AutomationControl> c, string const & n)
804 , _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1)
805 , _slider (&_adjustment, boost::shared_ptr<PBD::Controllable>(), 0, max(13.f, rintf(13.f * UIConfiguration::instance().get_ui_scale())))
806 , _slider_persistant_tooltip (&_slider)
807 , _button (ArdourButton::led_default_elements)
808 , _ignore_ui_adjustment (false)
812 _slider.set_controllable (c);
813 box.set_padding(0, 0, 4, 4);
816 _button.set_text (_name);
817 _button.set_led_left (true);
818 _button.set_name ("processor control button");
822 _button.signal_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked));
823 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked_event));
824 // dup. currently timers are used :(
825 //c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
829 _slider.set_name ("ProcessorControlSlider");
830 _slider.set_text (_name);
835 const ARDOUR::ParameterDescriptor& desc = c->desc();
836 double const lo = c->internal_to_interface(desc.lower);
837 double const up = c->internal_to_interface(desc.upper);
838 double const normal = c->internal_to_interface(desc.normal);
839 double smallstep = desc.smallstep;
840 double largestep = desc.largestep;
842 if (smallstep == 0.0) {
843 smallstep = up / 1000.;
845 smallstep = c->internal_to_interface(desc.lower + smallstep);
848 if (largestep == 0.0) {
849 largestep = up / 40.;
851 largestep = c->internal_to_interface(desc.lower + largestep);
854 _adjustment.set_lower (lo);
855 _adjustment.set_upper (up);
856 _adjustment.set_step_increment (smallstep);
857 _adjustment.set_page_increment (largestep);
858 _slider.set_default_value (normal);
860 _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &Control::slider_adjusted));
861 // dup. currently timers are used :(
862 //c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
865 // yuck, do we really need to do this?
866 // according to c404374 this is only needed for send automation
867 timer_connection = Timers::rapid_connect (sigc::mem_fun (*this, &Control::control_changed));
872 /* We're providing our own PersistentTooltip */
873 set_no_tooltip_whatsoever (_slider);
876 ProcessorEntry::Control::~Control ()
878 timer_connection.disconnect ();
882 ProcessorEntry::Control::set_tooltip ()
884 boost::shared_ptr<AutomationControl> c = _control.lock ();
891 snprintf (tmp, sizeof(tmp), "%s: %s", _name.c_str(), c->get_value() > 0.5 ? _("on") : _("off"));
893 snprintf (tmp, sizeof(tmp), "%s: %.2f", _name.c_str(), c->internal_to_user (c->get_value ()));
896 string sm = Gtkmm2ext::markup_escape_text (tmp);
897 _slider_persistant_tooltip.set_tip (sm);
898 ARDOUR_UI_UTILS::set_tooltip (_button, sm);
902 ProcessorEntry::Control::slider_adjusted ()
904 if (_ignore_ui_adjustment) {
908 boost::shared_ptr<AutomationControl> c = _control.lock ();
914 c->set_value ( c->interface_to_internal(_adjustment.get_value ()) , Controllable::NoGroup);
919 ProcessorEntry::Control::button_clicked ()
921 boost::shared_ptr<AutomationControl> c = _control.lock ();
927 bool const n = _button.get_active ();
929 c->set_value (n ? 0 : 1, Controllable::NoGroup);
930 _button.set_active (!n);
935 ProcessorEntry::Control::button_clicked_event (GdkEventButton *ev)
943 ProcessorEntry::Control::control_changed ()
945 boost::shared_ptr<AutomationControl> c = _control.lock ();
950 _ignore_ui_adjustment = true;
954 _button.set_active (c->get_value() > 0.5);
957 // as long as rapid timers are used, only update the tooltip
958 // if the value has changed.
959 const double nval = c->internal_to_interface (c->get_value ());
960 if (_adjustment.get_value() != nval) {
961 _adjustment.set_value (nval);
966 _ignore_ui_adjustment = false;
970 ProcessorEntry::Control::add_state (XMLNode* node) const
972 XMLNode* c = new XMLNode (X_("Object"));
973 c->set_property (X_("id"), state_id ());
974 c->set_property (X_("visible"), _visible);
975 node->add_child_nocopy (*c);
979 ProcessorEntry::Control::set_state (XMLNode const * node)
981 XMLNode* n = GUIObjectState::get_node (node, state_id ());
984 if (n->get_property (X_("visible"), visible)) {
985 set_visible (visible);
993 ProcessorEntry::Control::set_visible (bool v)
1004 /** Called when the Editor might have re-shown things that
1008 ProcessorEntry::Control::hide_things ()
1016 ProcessorEntry::Control::state_id () const
1018 boost::shared_ptr<AutomationControl> c = _control.lock ();
1021 return string_compose (X_("control %1"), c->id().to_s ());
1024 PluginInsertProcessorEntry::PluginInsertProcessorEntry (ProcessorBox* b, boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
1025 : ProcessorEntry (b, p, w)
1026 , _plugin_insert (p)
1028 p->PluginIoReConfigure.connect (
1029 _iomap_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::iomap_changed, this), gui_context()
1031 p->PluginMapChanged.connect (
1032 _iomap_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::iomap_changed, this), gui_context()
1034 p->PluginConfigChanged.connect (
1035 _iomap_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::iomap_changed, this), gui_context()
1040 PluginInsertProcessorEntry::iomap_changed ()
1042 _parent->setup_routing_feeds ();
1043 routing_icon.queue_draw();
1044 output_routing_icon.queue_draw();
1048 PluginInsertProcessorEntry::hide_things ()
1050 ProcessorEntry::hide_things ();
1053 ProcessorEntry::PortIcon::PortIcon(bool input) {
1055 _ports = ARDOUR::ChanCount(ARDOUR::DataType::AUDIO, 1);
1056 set_size_request (-1, std::max (2.f, rintf(2.f * UIConfiguration::instance().get_ui_scale())));
1060 ProcessorEntry::PortIcon::on_expose_event (GdkEventExpose* ev)
1062 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
1064 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
1067 Gtk::Allocation a = get_allocation();
1068 double const width = a.get_width();
1069 double const height = a.get_height();
1071 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
1072 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
1074 cairo_rectangle (cr, 0, 0, width, height);
1077 const double dx = rint(max(2., 2. * UIConfiguration::instance().get_ui_scale()));
1078 for (uint32_t i = 0; i < _ports.n_total(); ++i) {
1079 set_routing_color (cr, i < _ports.n_midi());
1080 const double x = ProcessorEntry::RoutingIcon::pin_x_pos (i, width, _ports.n_total(), 0 , false);
1081 cairo_rectangle (cr, x - .5 - dx * .5, 0, 1 + dx, height);
1089 ProcessorEntry::RoutingIcon::RoutingIcon (bool input)
1093 set_terminal (false);
1097 ProcessorEntry::RoutingIcon::set_terminal (bool b) {
1099 int h = std::max (8.f, rintf(8.f * sqrt (UIConfiguration::instance().get_ui_scale())));
1101 h += std::max (4.f, rintf(4.f * sqrt (UIConfiguration::instance().get_ui_scale())));
1103 set_size_request (-1, h);
1107 ProcessorEntry::RoutingIcon::set (
1108 const ARDOUR::ChanCount& in,
1109 const ARDOUR::ChanCount& out,
1110 const ARDOUR::ChanCount& sinks,
1111 const ARDOUR::ChanCount& sources,
1112 const ARDOUR::ChanMapping& in_map,
1113 const ARDOUR::ChanMapping& out_map,
1114 const ARDOUR::ChanMapping& thru_map)
1122 _thru_map = thru_map;
1126 ProcessorEntry::RoutingIcon::in_identity () const {
1127 if (_thru_map.n_total () > 0) {
1130 if (!_in_map.is_monotonic () || !_in_map.is_identity ()) {
1133 if (_in_map.n_total () != _sinks.n_total () || _in.n_total () != _sinks.n_total ()) {
1140 ProcessorEntry::RoutingIcon::out_identity () const {
1141 if (_thru_map.n_total () > 0) {
1142 // TODO skip if trhu is not connected to any of next's inputs
1145 if (!_out_map.is_monotonic () || !_out_map.is_identity ()) {
1148 if (_out_map.n_total () != _sources.n_total () || _out.n_total () != _sources.n_total ()) {
1155 ProcessorEntry::RoutingIcon::can_coalesce () const {
1156 if (_thru_map.n_total () > 0) {
1159 if (_fed_by && _f_out != _f_sources) {
1162 if (_fed_by && !_f_out_map.is_identity () && !_in_map.is_identity ()) {
1165 if (_input && _sinks == _in && (!_fed_by || _f_out == _in)) {
1172 ProcessorEntry::RoutingIcon::set_fed_by (
1173 const ARDOUR::ChanCount& out,
1174 const ARDOUR::ChanCount& sources,
1175 const ARDOUR::ChanMapping& out_map,
1176 const ARDOUR::ChanMapping& thru_map)
1179 _f_sources = sources;
1180 _f_out_map = out_map;
1181 _f_thru_map = thru_map;
1186 ProcessorEntry::RoutingIcon::set_feeding (
1187 const ARDOUR::ChanCount& in,
1188 const ARDOUR::ChanCount& sinks,
1189 const ARDOUR::ChanMapping& in_map,
1190 const ARDOUR::ChanMapping& thru_map)
1195 _i_thru_map = thru_map;
1200 ProcessorEntry::RoutingIcon::pin_x_pos (uint32_t i, double width, uint32_t n_total, uint32_t n_midi, bool midi)
1202 if (!midi) { i += n_midi; }
1205 return rint (width * .5) +.5;
1207 return rint (width * (.15 + .7 * i / (n_total - 1))) + .5;
1211 ProcessorEntry::RoutingIcon::draw_gnd (cairo_t* cr, double x0, double y0, double height, bool midi)
1213 const double dx = 1 + rint (max(2., 2. * UIConfiguration::instance().get_ui_scale()));
1214 const double y1 = rint (height * .66) + .5;
1217 cairo_translate (cr, x0, y0);
1218 cairo_move_to (cr, 0, height);
1219 cairo_line_to (cr, 0, y1);
1220 cairo_move_to (cr, 0 - dx, y1);
1221 cairo_line_to (cr, 0 + dx, y1);
1223 set_routing_color (cr, midi);
1224 cairo_set_line_width (cr, 1.0);
1230 ProcessorEntry::RoutingIcon::draw_sidechain (cairo_t* cr, double x0, double y0, double height, bool midi)
1232 const double dx = 1 + rint (max(2., 2. * UIConfiguration::instance().get_ui_scale()));
1233 const double y1 = rint (height * .5) - .5;
1236 cairo_translate (cr, x0, y0);
1237 cairo_move_to (cr, 0 - dx, height);
1238 cairo_line_to (cr, 0, y1);
1239 cairo_line_to (cr, 0 + dx, height);
1240 cairo_close_path (cr);
1242 set_routing_color (cr, midi);
1248 ProcessorEntry::RoutingIcon::draw_thru_src (cairo_t* cr, double x0, double y0, double height, bool midi)
1250 const double rad = 1;
1251 const double y1 = height - rad - 1.5;
1253 cairo_arc (cr, x0, y0 + y1, rad, 0, 2. * M_PI);
1254 cairo_move_to (cr, x0, y0 + height - 1.5);
1255 cairo_line_to (cr, x0, y0 + height);
1256 set_routing_color (cr, midi);
1257 cairo_set_line_width (cr, 1.0);
1262 ProcessorEntry::RoutingIcon::draw_thru_sink (cairo_t* cr, double x0, double y0, double height, bool midi)
1264 const double rad = 1;
1265 const double y1 = rad + 1;
1267 cairo_arc (cr, x0, y0 + y1, rad, 0, 2. * M_PI);
1268 cairo_move_to (cr, x0, y0);
1269 cairo_line_to (cr, x0, y0 + 1);
1270 set_routing_color (cr, midi);
1271 cairo_set_line_width (cr, 1.0);
1276 ProcessorEntry::RoutingIcon::draw_connection (cairo_t* cr, double x0, double x1, double y0, double y1, bool midi, bool dashed)
1278 double bz = abs (y1 - y0);
1280 cairo_move_to (cr, x0, y0);
1281 cairo_curve_to (cr, x0, y0 + bz, x1, y1 - bz, x1, y1);
1282 cairo_set_line_width (cr, 1.0);
1283 cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
1284 cairo_set_source_rgb (cr, 1, 0, 0);
1286 const double dashes[] = { 2, 3 };
1287 cairo_set_dash (cr, dashes, 2, 0);
1289 set_routing_color (cr, midi);
1292 cairo_set_dash (cr, 0, 0, 0);
1297 ProcessorEntry::RoutingIcon::on_expose_event (GdkEventExpose* ev)
1299 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
1301 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
1304 cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
1306 Gtk::Allocation a = get_allocation();
1307 double const width = a.get_width();
1308 double const height = a.get_height();
1310 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
1311 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
1313 cairo_rectangle (cr, 0, 0, width, height);
1317 if (can_coalesce ()) {
1318 expose_coalesced_input_map (cr, width, height);
1320 expose_input_map (cr, width, height);
1323 expose_output_map (cr, width, height);
1331 ProcessorEntry::RoutingIcon::expose_coalesced_input_map (cairo_t* cr, const double width, const double height)
1333 const uint32_t pc_in = _sinks.n_total();
1334 const uint32_t pc_in_midi = _sinks.n_midi();
1336 for (uint32_t i = 0; i < pc_in; ++i) {
1337 const bool is_midi = i < pc_in_midi;
1339 uint32_t pn = is_midi ? i : i - pc_in_midi;
1340 DataType dt = is_midi ? DataType::MIDI : DataType::AUDIO;
1341 uint32_t idx = _in_map.get (dt, pn, &valid_in);
1343 double x = pin_x_pos (i, width, pc_in, 0, is_midi);
1344 draw_gnd (cr, x, 0, height, is_midi);
1347 if (idx >= _in.get (dt)) {
1348 // side-chain, probably
1349 double x = pin_x_pos (i, width, pc_in, 0, is_midi);
1350 draw_sidechain (cr, x, 0, height, is_midi);
1354 double c_x1 = pin_x_pos (i, width, pc_in, 0, false);
1358 uint32_t src = _f_out_map.get_src (dt, idx, &valid_src);
1360 double x = pin_x_pos (i, width, pc_in, 0, false);
1362 _f_thru_map.get (dt, idx, &valid_thru);
1364 draw_thru_src (cr, x, 0, height, is_midi);
1366 draw_gnd (cr, x, 0, height, is_midi);
1370 c_x0 = pin_x_pos (src, width, _f_sources.n_total(), _f_sources.n_midi(), is_midi);
1372 c_x0 = pin_x_pos (idx, width, _in.n_total(), _in.n_midi(), is_midi);
1374 draw_connection (cr, c_x0, c_x1, 0, height, is_midi);
1379 ProcessorEntry::RoutingIcon::expose_input_map (cairo_t* cr, const double width, const double height)
1381 const uint32_t n_in = _in.n_total();
1382 const uint32_t n_in_midi = _in.n_midi();
1383 const uint32_t pc_in = _sinks.n_total();
1384 const uint32_t pc_in_midi = _sinks.n_midi();
1386 // draw inputs to this
1387 for (uint32_t i = 0; i < pc_in; ++i) {
1388 const bool is_midi = i < pc_in_midi;
1390 uint32_t pn = is_midi ? i : i - pc_in_midi;
1391 DataType dt = is_midi ? DataType::MIDI : DataType::AUDIO;
1392 uint32_t idx = _in_map.get (dt, pn, &valid_in);
1393 // check if it's fed
1394 bool valid_src = true;
1395 if (valid_in && idx < _in.get (dt) && _fed_by) {
1398 _f_out_map.get_src (dt, idx, &valid_out);
1399 _f_thru_map.get (dt, idx, &valid_thru);
1400 if (!valid_out && !valid_thru) {
1404 if (!valid_in || !valid_src) {
1405 double x = pin_x_pos (i, width, pc_in, 0, is_midi);
1406 draw_gnd (cr, x, 0, height, is_midi);
1409 if (idx >= _in.get (dt)) {
1410 // side-chain, probably
1411 double x = pin_x_pos (i, width, pc_in, 0, is_midi);
1412 draw_sidechain (cr, x, 0, height, is_midi);
1415 double c_x1 = pin_x_pos (i, width, pc_in, 0, false);
1416 double c_x0 = pin_x_pos (idx, width, n_in, n_in_midi, is_midi);
1417 draw_connection (cr, c_x0, c_x1, 0, height, is_midi);
1420 // draw reverse thru
1421 for (uint32_t i = 0; i < n_in; ++i) {
1422 const bool is_midi = i < n_in_midi;
1424 uint32_t pn = is_midi ? i : i - n_in_midi;
1425 DataType dt = is_midi ? DataType::MIDI : DataType::AUDIO;
1426 _thru_map.get_src (dt, pn, &valid_thru);
1430 double x = pin_x_pos (i, width, n_in, 0, is_midi);
1431 draw_thru_sink (cr, x, 0, height, is_midi);
1436 ProcessorEntry::RoutingIcon::expose_output_map (cairo_t* cr, const double width, const double height)
1438 int dh = std::max (4.f, rintf(4.f * UIConfiguration::instance().get_ui_scale()));
1439 double ht = _terminal ? height - dh : height;
1441 // draw outputs of this
1442 const uint32_t pc_out = _sources.n_total();
1443 const uint32_t pc_out_midi = _sources.n_midi();
1444 const uint32_t n_out = _out.n_total();
1445 const uint32_t n_out_midi = _out.n_midi();
1447 for (uint32_t i = 0; i < pc_out; ++i) {
1448 const bool is_midi = i < pc_out_midi;
1450 uint32_t pn = is_midi ? i : i - pc_out_midi;
1451 DataType dt = is_midi ? DataType::MIDI : DataType::AUDIO;
1452 uint32_t idx = _out_map.get (dt, pn, &valid_out);
1456 // skip connections that are not used in the next's input
1458 bool valid_thru, valid_sink;
1459 _i_in_map.get_src (dt, idx, &valid_sink);
1460 _i_thru_map.get_src (dt, idx, &valid_thru);
1461 if (!valid_thru && !valid_sink) {
1462 if (!is_midi || i != 0) { // special case midi-bypass
1467 double c_x0 = pin_x_pos (i, width, pc_out, 0, false);
1468 double c_x1 = pin_x_pos (idx, width, n_out, n_out_midi, is_midi);
1469 draw_connection (cr, c_x0, c_x1, 0, ht, is_midi);
1472 for (uint32_t i = 0; i < n_out; ++i) {
1473 const bool is_midi = i < n_out_midi;
1474 uint32_t pn = is_midi ? i : i - n_out_midi;
1475 DataType dt = is_midi ? DataType::MIDI : DataType::AUDIO;
1476 double x = pin_x_pos (i, width, n_out, 0, is_midi);
1479 bool valid_thru_f = false;
1480 // skip connections that are not used in the next's input
1483 _i_in_map.get_src (dt, pn, &valid_sink);
1484 _i_thru_map.get_src (dt, pn, &valid_thru_f);
1485 if (!valid_thru_f && !valid_sink) {
1486 if (!is_midi || i != 0) { // special case midi-bypass
1493 _out_map.get_src (dt, pn, &valid_src);
1496 uint32_t idx = _thru_map.get (dt, pn, &valid_thru);
1498 if (idx >= _in.get (dt)) {
1499 draw_sidechain (cr, x, 0, height, is_midi);
1501 draw_thru_src (cr, x, 0, height, is_midi);
1503 } else if (valid_thru_f){
1504 // gnd is part of input, unless it's a thru input
1505 // (also only true if !coalesced into one small display)
1506 draw_gnd (cr, x, 0, height, is_midi);
1510 // terminal node, add arrows
1512 _out_map.get_src (dt, pn, &valid_src);
1515 uint32_t idx = _thru_map.get (dt, pn, &valid_thru);
1517 if (idx >= _in.get (dt)) {
1518 draw_sidechain (cr, x, 0, height - dh, is_midi);
1520 draw_thru_src (cr, x, 0, height - dh, is_midi);
1523 draw_gnd (cr, x, 0, height - dh, is_midi);
1527 set_routing_color (cr, is_midi);
1528 cairo_set_line_width (cr, 1.0);
1529 cairo_move_to (cr, x, height - dh);
1530 cairo_line_to (cr, x, height - 2);
1533 const double ar = dh - 1;
1534 cairo_move_to (cr, x - ar, height - ar);
1535 cairo_line_to (cr, x , height - .5);
1536 cairo_line_to (cr, x + ar, height - ar);
1537 cairo_line_to (cr, x , height - ar * .5);
1538 cairo_close_path (cr);
1539 cairo_fill_preserve (cr);
1545 ProcessorEntry::PluginDisplay::PluginDisplay (ProcessorEntry& e, boost::shared_ptr<ARDOUR::Plugin> p, uint32_t max_height)
1549 , _max_height (max_height)
1553 set_name ("processor prefader");
1554 add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
1555 _plug->DropReferences.connect (_death_connection, invalidator (*this), boost::bind (&PluginDisplay::plugin_going_away, this), gui_context());
1556 _plug->QueueDraw.connect (_qdraw_connection, invalidator (*this),
1557 boost::bind (&Gtk::Widget::queue_draw, this), gui_context ());
1559 std::string postfix = string_compose(_("\n%1+double-click to toggle inline-display"), Keyboard::tertiary_modifier_name ());
1561 if (_plug->has_editor()) {
1562 ARDOUR_UI_UTILS::set_tooltip (*this,
1563 string_compose (_("<b>%1</b>\nDouble-click to show GUI.\n%2+double-click to show generic GUI.%3"), e.name (Wide), Keyboard::primary_modifier_name (), postfix));
1565 ARDOUR_UI_UTILS::set_tooltip (*this,
1566 string_compose (_("<b>%1</b>\nDouble-click to show generic GUI.%2"), e.name (Wide), postfix));
1570 ProcessorEntry::PluginDisplay::~PluginDisplay ()
1573 cairo_surface_destroy (_surf);
1578 ProcessorEntry::PluginDisplay::on_button_press_event (GdkEventButton *ev)
1580 assert (_entry.processor ());
1582 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_entry.processor());
1583 // duplicated code :(
1584 // consider some tweaks to pass this up to the DnDVBox somehow:
1585 // select processor, then call (private)
1586 //_entry._parent->processor_button_press_event (ev, &_entry);
1587 if (pi && pi->plugin() && pi->plugin()->has_inline_display()
1588 && Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)
1590 && ev->type == GDK_2BUTTON_PRESS) {
1591 _entry.toggle_inline_display_visibility ();
1594 else if (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS)) {
1595 if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
1596 _entry._parent->generic_edit_processor (_entry.processor ());
1598 _entry._parent->edit_processor (_entry.processor ());
1606 ProcessorEntry::PluginDisplay::on_button_release_event (GdkEventButton *ev)
1612 ProcessorEntry::PluginDisplay::on_size_request (Requisition* req)
1615 req->height = _cur_height;
1620 ProcessorEntry::PluginDisplay::update_height_alloc (uint32_t inline_height)
1622 /* work-around scroll-bar + aspect ratio
1623 * show inline-view -> height changes -> scrollbar gets added
1624 * -> width changes -> inline-view, fixed aspect ratio -> height changes
1625 * -> scroll bar is removed [-> width changes ; repeat ]
1627 uint32_t shm = std::min (_max_height, inline_height);
1629 Gtk::Container* pr = get_parent();
1630 for (uint32_t i = 0; i < 4 && pr; ++i) {
1631 // VBox, EventBox, ViewPort, ScrolledWindow
1632 pr = pr->get_parent();
1634 Gtk::ScrolledWindow* sw = dynamic_cast<Gtk::ScrolledWindow*> (pr);
1636 const Gtk::VScrollbar* vsb = sw->get_vscrollbar();
1637 sc = vsb && vsb->is_visible();
1640 if (shm != _cur_height) {
1641 if (_scroll == sc || _cur_height < shm) {
1650 ProcessorEntry::PluginDisplay::render_inline (cairo_t* cr, uint32_t width)
1652 Plugin::Display_Image_Surface* dis = _plug->render_inline_display (width, _max_height);
1657 /* allocate a local image-surface,
1658 * We cannot re-use the data via cairo_image_surface_create_for_data(),
1659 * since pixman keeps a reference to it.
1660 * we'd need to hand over the data and ha cairo_surface_destroy to free it.
1661 * it might be possible to work around via cairo_surface_set_user_data().
1664 || dis->width != cairo_image_surface_get_width (_surf)
1665 || dis->height != cairo_image_surface_get_height (_surf)
1668 cairo_surface_destroy (_surf);
1670 _surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, dis->width, dis->height);
1673 if (cairo_image_surface_get_stride (_surf) == dis->stride) {
1674 memcpy (cairo_image_surface_get_data (_surf), dis->data, dis->stride * dis->height);
1676 unsigned char *src = dis->data;
1677 unsigned char *dst = cairo_image_surface_get_data (_surf);
1678 const int dst_stride = cairo_image_surface_get_stride (_surf);
1679 for (int y = 0; y < dis->height; ++y) {
1680 memcpy (dst, src, dis->width * 4 /*ARGB32*/);
1686 cairo_surface_flush(_surf);
1687 cairo_surface_mark_dirty(_surf);
1688 const double xc = floor ((width - dis->width) * .5);
1689 cairo_set_source_surface(cr, _surf, xc, 0);
1696 ProcessorEntry::PluginDisplay::on_expose_event (GdkEventExpose* ev)
1698 Gtk::Allocation a = get_allocation();
1699 double const width = a.get_width();
1700 double const height = a.get_height();
1702 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
1703 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
1706 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
1707 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
1708 cairo_rectangle (cr, 0, 0, width, height);
1712 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
1713 Gtkmm2ext::rounded_rectangle (cr, .5, -1.5, width - 1, height + 1, 7);
1715 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1717 uint32_t ht = render_inline (cr, width);
1722 if (_cur_height != 1) {
1729 update_height_alloc (ht);
1732 bool failed = false;
1733 std::string name = get_name();
1734 ArdourCanvas::Color fill_color = UIConfiguration::instance().color (string_compose ("%1: fill active", name), &failed);
1736 Gtkmm2ext::rounded_rectangle (cr, .5, -1.5, width - 1, height + 1, 7);
1737 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1738 cairo_set_line_width(cr, 1.0);
1739 ArdourCanvas::set_source_rgb_a (cr, fill_color, 1.0);
1746 ProcessorEntry::LuaPluginDisplay::LuaPluginDisplay (ProcessorEntry& e, boost::shared_ptr<ARDOUR::LuaProc> p, uint32_t max_height)
1747 : PluginDisplay (e, p, max_height)
1749 , _lua_render_inline (0)
1751 p->setup_lua_inline_gui (&lua_gui);
1753 lua_State* LG = lua_gui.getState ();
1754 LuaInstance::bind_cairo (LG);
1755 luabridge::LuaRef lua_render = luabridge::getGlobal (LG, "render_inline");
1756 assert (lua_render.isFunction ());
1757 _lua_render_inline = new luabridge::LuaRef (lua_render);
1760 ProcessorEntry::LuaPluginDisplay::~LuaPluginDisplay ()
1762 delete (_lua_render_inline);
1766 ProcessorEntry::LuaPluginDisplay::render_inline (cairo_t *cr, uint32_t width)
1768 Cairo::Context ctx (cr);
1770 luabridge::LuaRef rv = (*_lua_render_inline)((Cairo::Context *)&ctx, width, _max_height);
1771 lua_gui.collect_garbage_step ();
1772 if (rv.isTable ()) {
1776 } catch (luabridge::LuaException const& e) {
1778 cerr << "LuaException:" << e.what () << endl;
1785 static std::list<Gtk::TargetEntry> drop_targets()
1787 std::list<Gtk::TargetEntry> tmp;
1788 tmp.push_back (Gtk::TargetEntry ("processor")); // from processor-box to processor-box
1789 tmp.push_back (Gtk::TargetEntry ("PluginInfoPtr")); // from plugin-manager
1790 tmp.push_back (Gtk::TargetEntry ("PluginFavoritePtr")); // from sidebar
1794 static std::list<Gtk::TargetEntry> drag_targets()
1796 std::list<Gtk::TargetEntry> tmp;
1797 tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr")); // to sidebar (optional preset)
1798 tmp.push_back (Gtk::TargetEntry ("processor")); // to processor-box (copy)
1802 static std::list<Gtk::TargetEntry> drag_targets_noplugin()
1804 std::list<Gtk::TargetEntry> tmp;
1805 tmp.push_back (Gtk::TargetEntry ("processor")); // to processor box (sends, faders re-order)
1809 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
1810 RouteProcessorSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
1811 : _parent_strip (parent)
1812 , _owner_is_mixer (owner_is_mixer)
1813 , ab_direction (true)
1814 , _get_plugin_selector (get_plugin_selector)
1816 , _visible_prefader_processors (0)
1817 , _rr_selection(rsel)
1818 , processor_display (drop_targets())
1819 , _redisplay_pending (false)
1823 /* ProcessorBox actions and bindings created statically by call to
1824 * ProcessorBox::register_actions(), made by ARDOUR_UI so that actions
1825 * are available for context menus.
1828 processor_display.set_data ("ardour-bindings", bindings);
1832 no_processor_redisplay = false;
1834 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
1835 processor_scroller.add (processor_display);
1836 pack_start (processor_scroller, true, true);
1838 processor_display.set_flags (CAN_FOCUS);
1839 processor_display.set_name ("ProcessorList");
1840 processor_display.set_data ("processorbox", this);
1841 processor_display.set_size_request (48, -1);
1842 processor_display.set_spacing (0);
1844 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
1845 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
1847 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
1848 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
1850 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
1851 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
1852 processor_display.DropFromExternal.connect (sigc::mem_fun (*this, &ProcessorBox::plugin_drop));
1854 processor_scroller.show ();
1855 processor_display.show ();
1858 parent->DeliveryChanged.connect (
1859 _mixer_strip_connections, invalidator (*this), boost::bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
1863 ARDOUR_UI_UTILS::set_tooltip (processor_display, _("Right-click to add/remove/edit\nplugins,inserts,sends and more"));
1866 ProcessorBox::~ProcessorBox ()
1868 /* it may appear as if we should delete processor_menu but that is a
1869 * pointer to a widget owned by the UI Manager, and has potentially
1870 * be returned to many other ProcessorBoxes. GTK doesn't really make
1871 * clear the ownership of this widget, which is a menu and thus is
1872 * never packed into any container other than an implict GtkWindow.
1874 * For now, until or if we ever get clarification over the ownership
1875 * story just let it continue to exist. At worst, its a small memory leak.
1880 ProcessorBox::set_route (boost::shared_ptr<Route> r)
1886 _route_connections.drop_connections();
1888 /* new route: any existing block on processor redisplay must be meaningless */
1889 no_processor_redisplay = false;
1892 _route->processors_changed.connect (
1893 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
1896 _route->DropReferences.connect (
1897 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
1900 _route->PropertyChanged.connect (
1901 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
1904 redisplay_processors ();
1908 ProcessorBox::route_going_away ()
1910 /* don't keep updating display as processors are deleted */
1911 no_processor_redisplay = true;
1915 boost::shared_ptr<Processor>
1916 ProcessorBox::find_drop_position (ProcessorEntry* position)
1918 boost::shared_ptr<Processor> p;
1920 p = position->processor ();
1922 /* dropped on the blank entry (which will be before the
1923 fader), so use the first non-blank child as our
1924 `dropped on' processor */
1925 list<ProcessorEntry*> c = processor_display.children ();
1926 list<ProcessorEntry*>::iterator i = c.begin ();
1928 assert (i != c.end ());
1929 p = (*i)->processor ();
1937 ProcessorBox::_drop_plugin_preset (Gtk::SelectionData const &data, Route::ProcessorList &pl)
1939 const void * d = data.get_data();
1940 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
1942 PluginPresetList nfos;
1944 tv->get_object_drag_data (nfos, &source);
1946 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1947 PluginPresetPtr ppp = (*i);
1948 PluginInfoPtr pip = ppp->_pip;
1949 PluginPtr p = pip->load (*_session);
1954 if (ppp->_preset.valid) {
1955 p->load_preset (ppp->_preset);
1958 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
1959 if (Config->get_new_plugins_active ()) {
1960 processor->enable (true);
1962 pl.push_back (processor);
1967 ProcessorBox::_drop_plugin (Gtk::SelectionData const &data, Route::ProcessorList &pl)
1969 const void * d = data.get_data();
1970 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>*>(d);
1971 PluginInfoList nfos;
1974 tv->get_object_drag_data (nfos, &source);
1976 for (list<PluginInfoPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1977 PluginPtr p = (*i)->load (*_session);
1981 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
1982 if (Config->get_new_plugins_active ()) {
1983 processor->enable (true);
1985 pl.push_back (processor);
1990 ProcessorBox::plugin_drop (Gtk::SelectionData const &data, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
1996 boost::shared_ptr<Processor> p = find_drop_position (position);
1997 Route::ProcessorList pl;
1999 if (data.get_target() == "PluginInfoPtr") {
2000 _drop_plugin (data, pl);
2002 else if (data.get_target() == "PluginFavoritePtr") {
2003 _drop_plugin_preset (data, pl);
2009 Route::ProcessorStreams err;
2010 if (_route->add_processors (pl, p, &err)) {
2012 "Processor Drag/Drop failed. Probably because\n\
2013 the I/O configuration of the plugins could\n\
2014 not match the configuration of this track.");
2015 MessageDialog am (msg);
2021 ProcessorBox::object_drop (DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
2023 if (Gdk::ACTION_LINK == context->get_selected_action()) {
2024 list<ProcessorEntry*> children = source->selection ();
2025 assert (children.size() == 1);
2026 ProcessorEntry* other = *children.begin();
2027 assert (other->can_copy_state (position));
2028 boost::shared_ptr<ARDOUR::Processor> otherproc = other->processor();
2029 boost::shared_ptr<ARDOUR::Processor> proc = position->processor();
2030 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (proc);
2031 assert (otherproc && proc && pi);
2033 PBD::ID id = pi->id();
2034 XMLNode& state = otherproc->get_state ();
2035 /* strip side-chain state (processor inside processor must be a side-chain)
2036 * otherwise we'll end up with duplicate ports-names.
2037 * (this needs a better solution which retains connections)
2039 state.remove_nodes ("Processor");
2040 proc->set_state (state, Stateful::loading_state_version);
2041 boost::dynamic_pointer_cast<PluginInsert>(proc)->update_id (id);
2045 boost::shared_ptr<Processor> p = find_drop_position (position);
2047 list<ProcessorEntry*> children = source->selection ();
2048 list<boost::shared_ptr<Processor> > procs;
2049 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
2050 if ((*i)->processor ()) {
2051 if (boost::dynamic_pointer_cast<UnknownProcessor> ((*i)->processor())) {
2054 procs.push_back ((*i)->processor ());
2058 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
2059 XMLNode& state = (*i)->get_state ();
2061 nlist.push_back (&state);
2062 paste_processor_state (nlist, p);
2066 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
2070 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
2071 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
2073 other->delete_dragged_processors (procs);
2079 ProcessorBox::set_width (Width w)
2087 list<ProcessorEntry*> children = processor_display.children ();
2088 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2089 (*i)->set_enum_width (w);
2096 ProcessorBox::build_possible_aux_menu ()
2098 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
2101 /* No aux sends if there are no busses */
2105 if (_route->is_monitor ()) {
2109 using namespace Menu_Helpers;
2110 Menu* menu = manage (new Menu);
2111 MenuList& items = menu->items();
2113 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
2114 if (!_route->internal_send_for (*r) && *r != _route) {
2115 items.push_back (MenuElem ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
2123 ProcessorBox::show_processor_menu (int arg)
2125 if (processor_menu == 0) {
2126 processor_menu = build_processor_menu ();
2127 processor_menu->signal_unmap().connect (sigc::mem_fun (*this, &ProcessorBox::processor_menu_unmapped));
2130 /* Sort out the plugin submenu */
2132 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newplugin"));
2134 if (plugin_menu_item) {
2135 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
2138 /* And the aux submenu */
2140 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newaux"));
2142 if (aux_menu_item) {
2143 Menu* m = build_possible_aux_menu();
2144 if (m && !m->items().empty()) {
2145 aux_menu_item->set_submenu (*m);
2146 aux_menu_item->set_sensitive (true);
2148 /* stupid gtkmm: we need to pass a null reference here */
2149 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
2150 aux_menu_item->set_sensitive (false);
2154 ActionManager::get_action (X_("ProcessorMenu"), "newinsert")->set_sensitive (!_route->is_monitor ());
2155 ActionManager::get_action (X_("ProcessorMenu"), "newsend")->set_sensitive (!_route->is_monitor ());
2157 ProcessorEntry* single_selection = 0;
2158 if (processor_display.selection().size() == 1) {
2159 single_selection = processor_display.selection().front();
2162 /* And the controls submenu */
2164 Gtk::MenuItem* controls_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/controls"));
2166 if (controls_menu_item) {
2167 if (single_selection) {
2168 Menu* m = single_selection->build_controls_menu ();
2169 if (m && !m->items().empty()) {
2170 controls_menu_item->set_submenu (*m);
2171 controls_menu_item->set_sensitive (true);
2173 gtk_menu_item_set_submenu (controls_menu_item->gobj(), 0);
2174 controls_menu_item->set_sensitive (false);
2177 controls_menu_item->set_sensitive (false);
2182 Gtk::MenuItem* send_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/send_options"));
2183 if (send_menu_item) {
2184 if (single_selection && !_route->is_monitor()) {
2185 Menu* m = single_selection->build_send_options_menu ();
2186 if (m && !m->items().empty()) {
2187 send_menu_item->set_submenu (*m);
2188 send_menu_item->set_sensitive (true);
2190 gtk_menu_item_set_submenu (send_menu_item->gobj(), 0);
2191 send_menu_item->set_sensitive (false);
2194 send_menu_item->set_sensitive (false);
2198 /* Sensitise actions as approprioate */
2201 const bool sensitive = !processor_display.selection().empty() && ! stub_processor_selected ();
2203 paste_action->set_sensitive (!_rr_selection.processors.empty());
2204 cut_action->set_sensitive (sensitive && can_cut ());
2205 copy_action->set_sensitive (sensitive);
2206 delete_action->set_sensitive (sensitive || stub_processor_selected ());
2207 backspace_action->set_sensitive (sensitive || stub_processor_selected ());
2209 edit_action->set_sensitive (one_processor_can_be_edited ());
2210 edit_generic_action->set_sensitive (one_processor_can_be_edited ());
2212 boost::shared_ptr<PluginInsert> pi;
2213 if (single_selection) {
2214 pi = boost::dynamic_pointer_cast<PluginInsert> (single_selection->processor ());
2217 manage_pins_action->set_sensitive (pi != 0);
2219 /* allow editing with an Ardour-generated UI for plugin inserts with editors */
2220 edit_action->set_sensitive (pi && pi->plugin()->has_editor ());
2222 /* disallow rename for multiple selections, for plugin inserts and for the fader */
2223 rename_action->set_sensitive (single_selection
2225 && !boost::dynamic_pointer_cast<Amp> (single_selection->processor ())
2226 && !boost::dynamic_pointer_cast<UnknownProcessor> (single_selection->processor ()));
2228 processor_menu->popup (1, arg);
2230 /* Add a placeholder gap to the processor list to indicate where a processor would be
2231 inserted were one chosen from the menu.
2234 processor_display.get_pointer (x, y);
2235 _placement = processor_display.add_placeholder (y);
2237 if (_visible_prefader_processors == 0 && _placement > 0) {
2243 ProcessorBox::enter_notify (GdkEventCrossing*)
2245 processor_display.grab_focus ();
2246 _current_processor_box = this;
2251 ProcessorBox::leave_notify (GdkEventCrossing* ev)
2253 if (ev->detail == GDK_NOTIFY_INFERIOR) {
2257 Widget* top = get_toplevel();
2259 if (top->is_toplevel()) {
2260 Window* win = dynamic_cast<Window*> (top);
2261 gtk_window_set_focus (win->gobj(), 0);
2268 ProcessorBox::processor_operation (ProcessorOperation op)
2270 ProcSelection targets;
2272 get_selected_processors (targets);
2274 /* if (targets.empty()) {
2277 processor_display.get_pointer (x, y);
2279 pair<ProcessorEntry *, double> const pointer = processor_display.get_child_at_position (y);
2281 if (pointer.first && pointer.first->processor()) {
2282 targets.push_back (pointer.first->processor ());
2287 if ((op == ProcessorsDelete) && targets.empty()) {
2288 return false; //nothing to delete. return false so the editor-mixer, because the user was probably intending to delete something in the editor
2292 case ProcessorsSelectAll:
2293 processor_display.select_all ();
2296 case ProcessorsSelectNone:
2297 processor_display.select_none ();
2300 case ProcessorsCopy:
2301 copy_processors (targets);
2305 cut_processors (targets);
2308 case ProcessorsPaste:
2309 // some processors are not selectable (e.g fader, meter), target is empty.
2310 if (targets.empty() && _placement >= 0) {
2312 boost::shared_ptr<Processor> proc = _route->before_processor_for_index (_placement);
2314 targets.push_back (proc);
2317 if (targets.empty()) {
2318 paste_processors ();
2320 paste_processors (targets.front());
2324 case ProcessorsDelete:
2325 delete_processors (targets);
2328 case ProcessorsToggleActive:
2329 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
2330 if (!(*i)->display_to_user ()) {
2331 assert (0); // these should not be selectable to begin with.
2334 if (!boost::dynamic_pointer_cast<PluginInsert> (*i)) {
2338 if (boost::dynamic_pointer_cast<PluginInsert> (*i)->is_channelstrip()) {
2342 (*i)->enable (!(*i)->enabled ());
2357 ProcessorWindowProxy*
2358 ProcessorBox::find_window_proxy (boost::shared_ptr<Processor> processor) const
2360 return processor->window_proxy();
2365 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
2367 boost::shared_ptr<Processor> processor;
2369 processor = child->processor ();
2373 bool selected = processor_display.selected (child);
2375 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (processor);
2376 if (pi && pi->plugin() && pi->plugin()->has_inline_display()
2377 && Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)
2379 && ev->type == GDK_2BUTTON_PRESS) {
2380 child->toggle_inline_display_visibility ();
2384 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
2386 if (_session->engine().connected()) {
2387 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
2389 if (!one_processor_can_be_edited ()) {
2393 if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
2394 generic_edit_processor (processor);
2396 edit_processor (processor);
2402 } else if (Keyboard::is_context_menu_event (ev)) {
2404 show_processor_menu (ev->time);
2408 } else if (processor && ev->button == 1 && selected) {
2410 // this is purely informational but necessary for route params UI
2411 ProcessorSelected (processor); // emit
2413 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
2416 _get_plugin_selector()->show_manager ();
2423 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
2425 boost::shared_ptr<Processor> processor;
2427 processor = child->processor ();
2430 if (processor && Keyboard::is_delete_event (ev)) {
2432 Glib::signal_idle().connect (sigc::bind (
2433 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
2434 boost::weak_ptr<Processor>(processor)));
2436 } else if (processor && Keyboard::is_button2_event (ev)
2438 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
2442 /* button2-click with no/appropriate modifiers */
2443 processor->enable (!processor->enabled ());
2450 ProcessorBox::build_processor_menu ()
2452 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/ProcessorMenu") );
2453 processor_menu->set_name ("ArdourContextMenu");
2454 return processor_menu;
2458 ProcessorBox::select_all_processors ()
2460 processor_display.select_all ();
2464 ProcessorBox::deselect_all_processors ()
2466 processor_display.select_none ();
2470 ProcessorBox::choose_plugin ()
2472 _get_plugin_selector()->set_interested_object (*this);
2475 /** @return true if an error occurred, otherwise false */
2477 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
2479 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
2481 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
2483 Route::ProcessorStreams err_streams;
2485 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
2486 weird_plugin_dialog (**p, err_streams);
2488 // XXX SHAREDPTR delete plugin here .. do we even need to care?
2489 } else if (plugins.size() == 1 && UIConfiguration::instance().get_open_gui_after_adding_plugin()) {
2490 if (boost::dynamic_pointer_cast<PluginInsert>(processor)->plugin()->has_inline_display() && UIConfiguration::instance().get_prefer_inline_over_gui()) {
2492 } else if (_session->engine().connected () && processor_can_be_edited (processor)) {
2493 if ((*p)->has_editor ()) {
2494 edit_processor (processor);
2495 } else if (boost::dynamic_pointer_cast<PluginInsert>(processor)->plugin()->parameter_count() > 0) {
2496 generic_edit_processor (processor);
2506 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
2508 /* XXX this needs to be re-worked!
2510 * With new pin-management "streams" is no longer correct.
2511 * p.get_info () is also incorrect for variable i/o plugins (always -1,-1).
2513 * Since pin-management was added, this dialog will only show in a very rare
2514 * condition (non-replicated variable i/o configuration failed).
2516 * TODO: simplify the message after the string-freeze is lifted.
2518 ArdourDialog dialog (_("Plugin Incompatibility"));
2521 string text = string_compose(_("You attempted to add the plugin \"%1\" in slot %2.\n"),
2522 p.name(), streams.index);
2524 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
2525 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
2527 text += _("\nThis plugin has:\n");
2529 uint32_t const n = p.get_info()->n_inputs.n_midi ();
2530 text += string_compose (ngettext ("\t%1 MIDI input\n", "\t%1 MIDI inputs\n", n), n);
2533 uint32_t const n = p.get_info()->n_inputs.n_audio ();
2534 text += string_compose (ngettext ("\t%1 audio input\n", "\t%1 audio inputs\n", n), n);
2537 text += _("\nbut at the insertion point, there are:\n");
2539 uint32_t const n = streams.count.n_midi ();
2540 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
2543 uint32_t const n = streams.count.n_audio ();
2544 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
2547 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
2548 label.set_text(text);
2550 dialog.get_vbox()->pack_start (label);
2551 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
2553 dialog.set_name (X_("PluginIODialog"));
2554 dialog.set_modal (true);
2561 ProcessorBox::choose_insert ()
2563 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->pannable(), _route->mute_master()));
2564 _route->add_processor_by_index (processor, _placement);
2567 /* Caller must not hold process lock */
2569 ProcessorBox::choose_send ()
2571 boost::shared_ptr<Send> send (new Send (*_session, _route->pannable (), _route->mute_master()));
2573 /* make an educated guess at the initial number of outputs for the send */
2574 ChanCount outs = (_route->n_outputs().n_audio() && _session->master_out())
2575 ? _session->master_out()->n_outputs()
2576 : _route->n_outputs();
2578 /* XXX need processor lock on route */
2580 Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock());
2581 send->output()->ensure_io (outs, false, this);
2582 } catch (AudioEngine::PortRegistrationFailure& err) {
2583 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
2587 /* let the user adjust the IO setup before creation.
2589 Note: this dialog is NOT modal - we just leave it to run and it will
2590 return when its Finished signal is emitted - typically when the window
2594 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
2597 /* keep a reference to the send so it doesn't get deleted while
2598 the IOSelectorWindow is doing its stuff
2600 _processor_being_created = send;
2602 ios->selector().Finished.connect (sigc::bind (
2603 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
2604 boost::weak_ptr<Processor>(send), ios));
2609 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
2611 boost::shared_ptr<Processor> processor (weak_processor.lock());
2613 /* drop our temporary reference to the new send */
2614 _processor_being_created.reset ();
2621 case IOSelector::Cancelled:
2622 // processor will go away when all shared_ptrs to it vanish
2625 case IOSelector::Accepted:
2626 _route->add_processor_by_index (processor, _placement);
2630 delete_when_idle (ios);
2634 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
2636 boost::shared_ptr<Processor> processor (weak_processor.lock());
2638 /* drop our temporary reference to the new return */
2639 _processor_being_created.reset ();
2646 case IOSelector::Cancelled:
2647 // processor will go away when all shared_ptrs to it vanish
2650 case IOSelector::Accepted:
2651 _route->add_processor_by_index (processor, _placement);
2655 delete_when_idle (ios);
2659 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
2665 boost::shared_ptr<Route> target = wr.lock();
2671 _session->add_internal_send (target, _placement, _route);
2675 ProcessorBox::route_processors_changed (RouteProcessorChange c)
2677 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
2678 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
2682 redisplay_processors ();
2686 ProcessorBox::redisplay_processors ()
2688 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors);
2691 if (no_processor_redisplay) {
2695 processor_display.clear ();
2697 _visible_prefader_processors = 0;
2700 _route->foreach_processor (sigc::bind (sigc::mem_fun (*this, &ProcessorBox::help_count_visible_prefader_processors),
2701 &_visible_prefader_processors, &fader_seen));
2703 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
2704 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
2705 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_pin_mgr));
2707 setup_entry_positions ();
2710 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
2711 * not already have one.
2714 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
2716 boost::shared_ptr<Processor> p = w.lock ();
2720 if (p->window_proxy()) {
2724 /* not on the list; add it */
2727 #if 0 // is this still needed? Why?
2728 if (_parent_strip) {
2729 if (_parent_strip->mixer_owned()) {
2741 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
2742 string_compose ("%1-%2-%3", loc, _route->id(), p->id()),
2746 const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
2749 wp->set_state (*ui_xml, 0);
2752 void* existing_ui = p->get_ui ();
2755 wp->use_window (*(reinterpret_cast<Gtk::Window*>(existing_ui)));
2758 p->set_window_proxy (wp);
2759 WM::Manager::instance().register_window (wp);
2763 ProcessorBox::maybe_add_processor_pin_mgr (boost::weak_ptr<Processor> w)
2765 boost::shared_ptr<Processor> p = w.lock ();
2766 if (!p || p->pinmgr_proxy ()) {
2770 PluginPinWindowProxy* wp = new PluginPinWindowProxy (
2771 string_compose ("PM-%2-%3", _route->id(), p->id()), w);
2772 wp->set_session (_session);
2774 const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
2776 wp->set_state (*ui_xml, 0);
2779 p->set_pingmgr_proxy (wp);
2780 WM::Manager::instance().register_window (wp);
2783 ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor> p, uint32_t* cnt, bool* amp_seen)
2785 boost::shared_ptr<Processor> processor (p.lock ());
2787 if (processor && ( processor->display_to_user()
2789 || show_all_processors
2794 if (boost::dynamic_pointer_cast<Amp>(processor) &&
2795 boost::dynamic_pointer_cast<Amp>(processor)->gain_control()->parameter().type() == GainAutomation) {
2806 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
2808 boost::shared_ptr<Processor> processor (p.lock ());
2810 if (!processor || ( !processor->display_to_user()
2812 && !show_all_processors
2819 boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
2821 ProcessorEntry* e = 0;
2822 if (plugin_insert) {
2823 e = new PluginInsertProcessorEntry (this, plugin_insert, _width);
2825 e = new ProcessorEntry (this, processor, _width);
2828 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
2829 boost::shared_ptr<PortInsert> ext = boost::dynamic_pointer_cast<PortInsert> (processor);
2830 boost::shared_ptr<UnknownProcessor> stub = boost::dynamic_pointer_cast<UnknownProcessor> (processor);
2832 //faders and meters are not deletable, copy/paste-able, so they shouldn't be selectable
2833 if (!send && !plugin_insert && !ext && !stub)
2834 e->set_selectable(false);
2836 bool mark_send_visible = false;
2837 if (send && _parent_strip) {
2838 /* show controls of new sends by default */
2839 GUIObjectState& st = _parent_strip->gui_object_state ();
2840 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
2842 /* check if state exists, if not it must be a new send */
2843 if (!st.get_node(strip, e->state_id())) {
2844 mark_send_visible = true;
2848 /* Set up this entry's state from the GUIObjectState */
2849 XMLNode* proc = entry_gui_object_state (e);
2851 e->set_control_state (proc);
2854 if (mark_send_visible) {
2855 e->show_all_controls ();
2860 && !plugin_insert->plugin(0)->is_channelstrip()
2864 processor_display.add_child (e, drag_targets());
2866 processor_display.add_child (e, drag_targets_noplugin());
2871 ProcessorBox::reordered ()
2873 compute_processor_sort_keys ();
2874 setup_entry_positions ();
2878 ProcessorBox::setup_routing_feeds ()
2880 list<ProcessorEntry*> children = processor_display.children ();
2881 /* first set the i/o maps for every processor */
2882 list<ProcessorEntry*>::iterator prev = children.begin();
2884 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2885 boost::shared_ptr<ARDOUR::Processor> p = (*i)->processor();
2886 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (p);
2888 list<ProcessorEntry*>::iterator next = i;
2892 ChanCount sinks = pi->natural_input_streams ();
2893 ChanCount sources = pi->natural_output_streams ();
2894 uint32_t count = pi->get_count ();
2896 pi->configured_io (in, out);
2898 ChanCount midi_thru;
2899 ChanCount midi_bypass;
2900 ChanMapping input_map (pi->input_map ());
2901 if (pi->has_midi_thru ()) {
2902 midi_thru.set(DataType::MIDI, 1);
2903 input_map.set (DataType::MIDI, 0, 0);
2905 if (pi->has_midi_bypass ()) {
2906 midi_bypass.set(DataType::MIDI, 1);
2909 (*i)->input_icon.set_ports (sinks * count + midi_thru);
2910 (*i)->output_icon.set_ports (sources * count + midi_bypass);
2912 (*i)->routing_icon.set (
2914 sinks * count + midi_thru,
2915 sources * count + midi_bypass,
2920 if (next != children.end()) {
2921 (*next)->routing_icon.set_fed_by (out, sources * count + midi_bypass,
2922 pi->output_map (), pi->thru_map ());
2926 (*prev)->routing_icon.set_feeding (in, sinks * count + midi_thru,
2927 pi->input_map (), pi->thru_map ());
2931 (*i)->input_icon.set_ports (p->input_streams());
2932 (*i)->output_icon.set_ports (p->output_streams());
2933 ChanMapping inmap (p->input_streams ());
2934 ChanMapping outmap (p->output_streams ());
2935 ChanMapping thrumap;
2936 (*i)->routing_icon.set (
2938 p->output_streams(),
2940 p->output_streams(),
2941 inmap, outmap, thrumap);
2943 if (next != children.end()) {
2944 (*next)->routing_icon.set_fed_by (
2945 p->output_streams(),
2946 p->output_streams(),
2950 (*prev)->routing_icon.set_feeding (
2952 p->output_streams(),
2957 if (i == children.begin()) {
2958 (*i)->routing_icon.unset_fed_by ();
2961 (*i)->input_icon.hide();
2964 /* now set which icons need to be displayed */
2965 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
2966 (*i)->output_routing_icon.copy_state ((*i)->routing_icon);
2968 if ((*i)->routing_icon.in_identity ()) {
2969 (*i)->routing_icon.hide();
2970 if (i == children.begin()) {
2971 (*i)->input_icon.show();
2974 (*i)->routing_icon.show();
2975 (*i)->routing_icon.queue_draw();
2976 (*i)->input_icon.show();
2979 list<ProcessorEntry*>::iterator next = i;
2980 if (++next == children.end()) {
2981 // last processor in the chain
2982 (*i)->output_routing_icon.set_terminal(true);
2983 (*i)->output_routing_icon.unset_feeding ();
2984 if ((*i)->routing_icon.out_identity ()) {
2985 (*i)->output_routing_icon.hide();
2987 (*i)->output_routing_icon.show();
2988 (*i)->output_routing_icon.queue_draw();
2991 (*i)->output_routing_icon.set_terminal(false);
2992 if ( !(*i)->routing_icon.out_identity ()
2993 && !(*next)->routing_icon.in_identity ()
2994 && (*next)->routing_icon.can_coalesce ()) {
2995 (*i)->output_routing_icon.hide();
2996 } else if (!(*i)->routing_icon.out_identity ()) {
2997 (*i)->output_routing_icon.show();
2998 (*i)->output_routing_icon.queue_draw();
2999 (*next)->input_icon.show();
3001 (*i)->output_routing_icon.hide();
3008 ProcessorBox::setup_entry_positions ()
3010 list<ProcessorEntry*> children = processor_display.children ();
3011 bool pre_fader = true;
3014 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
3015 if (boost::dynamic_pointer_cast<Amp>((*i)->processor()) &&
3016 boost::dynamic_pointer_cast<Amp>((*i)->processor())->gain_control()->parameter().type() == GainAutomation) {
3018 (*i)->set_position (ProcessorEntry::Fader, num++);
3021 (*i)->set_position (ProcessorEntry::PreFader, num++);
3023 (*i)->set_position (ProcessorEntry::PostFader, num++);
3027 setup_routing_feeds ();
3031 ProcessorBox::compute_processor_sort_keys ()
3033 list<ProcessorEntry*> children = processor_display.children ();
3034 Route::ProcessorList our_processors;
3036 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
3037 if ((*i)->processor()) {
3038 our_processors.push_back ((*i)->processor ());
3042 if (_route->reorder_processors (our_processors)) {
3043 /* Reorder failed, so report this to the user. As far as I can see this must be done
3044 in an idle handler: it seems that the redisplay_processors() that happens below destroys
3045 widgets that were involved in the drag-and-drop on the processor list, which causes problems
3046 when the drag is torn down after this handler function is finished.
3048 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
3053 ProcessorBox::report_failed_reorder ()
3055 /* reorder failed, so redisplay */
3057 redisplay_processors ();
3059 /* now tell them about the problem */
3061 ArdourDialog dialog (_("Plugin Incompatibility"));
3064 label.set_text (_("\
3065 You cannot reorder these plugins/sends/inserts\n\
3066 in that way because the inputs and\n\
3067 outputs will not work correctly."));
3069 dialog.get_vbox()->set_border_width (12);
3070 dialog.get_vbox()->pack_start (label);
3071 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
3073 dialog.set_name (X_("PluginIODialog"));
3074 dialog.set_modal (true);
3081 ProcessorBox::rename_processors ()
3083 ProcSelection to_be_renamed;
3085 get_selected_processors (to_be_renamed);
3087 if (to_be_renamed.empty()) {
3091 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
3092 rename_processor (*i);
3097 ProcessorBox::can_cut () const
3099 vector<boost::shared_ptr<Processor> > sel;
3101 get_selected_processors (sel);
3103 /* cut_processors () does not cut inserts */
3105 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
3107 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
3108 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
3109 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
3118 ProcessorBox::stub_processor_selected () const
3120 vector<boost::shared_ptr<Processor> > sel;
3122 get_selected_processors (sel);
3124 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
3125 if (boost::dynamic_pointer_cast<UnknownProcessor>((*i)) != 0) {
3134 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
3136 if (to_be_removed.empty()) {
3140 XMLNode* node = new XMLNode (X_("cut"));
3141 Route::ProcessorList to_cut;
3143 no_processor_redisplay = true;
3144 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
3145 // Cut only plugins, sends and returns
3146 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
3147 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
3148 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
3150 Window* w = get_processor_ui (*i);
3156 XMLNode& child ((*i)->get_state());
3157 node->add_child_nocopy (child);
3158 to_cut.push_back (*i);
3162 if (_route->remove_processors (to_cut) != 0) {
3164 no_processor_redisplay = false;
3168 _rr_selection.set (node);
3170 no_processor_redisplay = false;
3171 redisplay_processors ();
3175 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
3177 if (to_be_copied.empty()) {
3181 XMLNode* node = new XMLNode (X_("copy"));
3183 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
3184 // Copy only plugins, sends, returns
3185 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
3186 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
3187 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
3188 node->add_child_nocopy ((*i)->get_state());
3192 _rr_selection.set (node);
3196 ProcessorBox::delete_processors (const ProcSelection& targets)
3198 if (targets.empty()) {
3202 no_processor_redisplay = true;
3204 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
3206 Window* w = get_processor_ui (*i);
3212 _route->remove_processor(*i);
3215 no_processor_redisplay = false;
3216 redisplay_processors ();
3220 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
3222 list<boost::shared_ptr<Processor> >::const_iterator x;
3224 no_processor_redisplay = true;
3225 for (x = procs.begin(); x != procs.end(); ++x) {
3227 Window* w = get_processor_ui (*x);
3233 _route->remove_processor(*x);
3236 no_processor_redisplay = false;
3237 redisplay_processors ();
3241 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
3243 boost::shared_ptr<Processor> processor (weak_processor.lock());
3249 /* NOT copied to _mixer.selection() */
3251 no_processor_redisplay = true;
3252 _route->remove_processor (processor);
3253 no_processor_redisplay = false;
3254 redisplay_processors ();
3260 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
3262 ArdourPrompter name_prompter (true);
3264 name_prompter.set_title (_("Rename Processor"));
3265 name_prompter.set_prompt (_("New name:"));
3266 name_prompter.set_initial_text (processor->name());
3267 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
3268 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
3269 name_prompter.show_all ();
3271 switch (name_prompter.run ()) {
3273 case Gtk::RESPONSE_ACCEPT:
3274 name_prompter.get_result (result);
3275 if (result.length()) {
3278 string test = result;
3280 while (tries < 100) {
3281 if (_session->io_name_is_legal (test)) {
3287 test = string_compose ("%1-%2", result, tries);
3291 processor->set_name (result);
3294 ARDOUR_UI::instance()->popup_error
3295 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
3305 ProcessorBox::paste_processors ()
3307 if (_rr_selection.processors.empty()) {
3311 paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
3315 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
3318 if (_rr_selection.processors.empty()) {
3322 paste_processor_state (_rr_selection.processors.get_node().children(), before);
3326 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
3328 XMLNodeConstIterator niter;
3329 list<boost::shared_ptr<Processor> > copies;
3331 if (nlist.empty()) {
3335 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
3337 XMLProperty const * type = (*niter)->property ("type");
3338 XMLProperty const * role = (*niter)->property ("role");
3341 boost::shared_ptr<Processor> p;
3343 if (type->value() == "meter" ||
3344 type->value() == "main-outs" ||
3345 type->value() == "amp" ||
3346 type->value() == "intreturn") {
3347 /* do not paste meter, main outs, amp or internal returns */
3350 } else if (type->value() == "intsend") {
3352 /* aux sends are OK, but those used for
3353 * other purposes, are not.
3358 if (role->value() != "Aux") {
3362 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
3363 XMLNode n (**niter);
3364 InternalSend* s = new InternalSend (*_session, sendpan, _route->mute_master(),
3365 _route, boost::shared_ptr<Route>(), Delivery::Aux);
3367 IOProcessor::prepare_for_reset (n, s->name());
3369 if (s->set_state (n, Stateful::loading_state_version)) {
3376 } else if (type->value() == "send") {
3378 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
3379 XMLNode n (**niter);
3381 Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
3383 IOProcessor::prepare_for_reset (n, s->name());
3385 if (s->set_state (n, Stateful::loading_state_version)) {
3392 } else if (type->value() == "return") {
3394 XMLNode n (**niter);
3395 Return* r = new Return (*_session);
3397 IOProcessor::prepare_for_reset (n, r->name());
3399 if (r->set_state (n, Stateful::loading_state_version)) {
3406 } else if (type->value() == "port") {
3408 XMLNode n (**niter);
3409 PortInsert* pi = new PortInsert (*_session, _route->pannable (), _route->mute_master ());
3411 IOProcessor::prepare_for_reset (n, pi->name());
3413 if (pi->set_state (n, Stateful::loading_state_version)) {
3419 /* XXX its a bit limiting to assume that everything else
3422 p.reset (new PluginInsert (*_session));
3423 /* we can't use RAII Stateful::ForceIDRegeneration
3424 * because that'd void copying the state and wrongly bump
3425 * the state-version counter.
3426 * we need to load the state (incl external files) first and
3427 * only then update the ID)
3429 PBD::ID id = p->id();
3430 /* strip side-chain state (processor inside processor must be a side-chain)
3431 * otherwise we'll end up with duplicate ports-names.
3432 * (this needs a better solution which retains connections)
3433 * We really would want Stateful::ForceIDRegeneration here :(
3435 XMLNode state (**niter);
3436 state.remove_nodes ("Processor");
3438 p->set_state (state, Stateful::current_state_version);
3439 boost::dynamic_pointer_cast<PluginInsert>(p)->update_id (id);
3442 copies.push_back (p);
3446 error << _("plugin insert constructor failed") << endmsg;
3450 if (copies.empty()) {
3454 if (_route->add_processors (copies, p)) {
3457 "Copying the set of processors on the clipboard failed,\n\
3458 probably because the I/O configuration of the plugins\n\
3459 could not match the configuration of this track.");
3460 MessageDialog am (msg);
3466 ProcessorBox::get_selected_processors (ProcSelection& processors) const
3468 const list<ProcessorEntry*> selection = processor_display.selection ();
3469 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
3470 processors.push_back ((*i)->processor ());
3475 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
3477 list<ProcessorEntry*> selection = processor_display.selection ();
3478 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
3479 (this->*method) ((*i)->processor ());
3484 ProcessorBox::all_visible_processors_active (bool state)
3486 _route->all_visible_processors_active (state);
3490 ProcessorBox::ab_plugins ()
3492 _route->ab_plugins (ab_direction);
3493 ab_direction = !ab_direction;
3498 ProcessorBox::clear_processors ()
3501 vector<string> choices;
3503 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
3504 "(this cannot be undone)"), _route->name());
3506 choices.push_back (_("Cancel"));
3507 choices.push_back (_("Yes, remove them all"));
3509 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
3511 if (prompter.run () == 1) {
3512 _route->clear_processors (PreFader);
3513 _route->clear_processors (PostFader);
3518 ProcessorBox::clear_processors (Placement p)
3521 vector<string> choices;
3523 if (p == PreFader) {
3524 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
3525 "(this cannot be undone)"), _route->name());
3527 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
3528 "(this cannot be undone)"), _route->name());
3531 choices.push_back (_("Cancel"));
3532 choices.push_back (_("Yes, remove them all"));
3534 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
3536 if (prompter.run () == 1) {
3537 _route->clear_processors (p);
3542 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
3544 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
3545 if (at && at->freeze_state() == AudioTrack::Frozen) {
3550 boost::dynamic_pointer_cast<Send> (processor) ||
3551 boost::dynamic_pointer_cast<Return> (processor) ||
3552 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
3553 boost::dynamic_pointer_cast<PortInsert> (processor)
3562 ProcessorBox::one_processor_can_be_edited ()
3564 list<ProcessorEntry*> selection = processor_display.selection ();
3565 list<ProcessorEntry*>::iterator i = selection.begin();
3566 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
3570 return (i != selection.end());
3574 ProcessorBox::get_editor_window (boost::shared_ptr<Processor> processor, bool use_custom)
3576 boost::shared_ptr<Send> send;
3577 boost::shared_ptr<InternalSend> internal_send;
3578 boost::shared_ptr<Return> retrn;
3579 boost::shared_ptr<PluginInsert> plugin_insert;
3580 boost::shared_ptr<PortInsert> port_insert;
3583 /* This method may or may not return a Window, but if it does not it
3584 * will modify the parent mixer strip appearance layout to allow
3585 * "editing" the @param processor that was passed in.
3587 * So for example, if the processor is an Amp (gain), the parent strip
3588 * will be forced back into a model where the fader controls the main gain.
3589 * If the processor is a send, then we map the send controls onto the
3592 * Plugins and others will return a window for control.
3595 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
3597 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
3602 if (boost::dynamic_pointer_cast<Amp> (processor) && boost::dynamic_pointer_cast<Amp> (processor)->gain_control()->parameter().type() == GainAutomation) {
3604 if (_parent_strip) {
3605 _parent_strip->revert_to_default_display ();
3608 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
3610 if (!_session->engine().connected()) {
3614 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
3616 gidget = new SendUIWindow (send, _session);
3619 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
3621 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
3622 /* no GUI for these */
3626 if (!_session->engine().connected()) {
3630 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
3632 ReturnUIWindow *return_ui;
3633 Window* w = get_processor_ui (retrn);
3637 return_ui = new ReturnUIWindow (retrn, _session);
3638 return_ui->set_title (retrn->name ());
3639 set_processor_ui (send, return_ui);
3642 return_ui = dynamic_cast<ReturnUIWindow *> (w);
3647 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
3649 PluginUIWindow *plugin_ui;
3651 /* these are both allowed to be null */
3653 Window* w = get_processor_ui (plugin_insert);
3656 plugin_ui = new PluginUIWindow (plugin_insert, false, use_custom);
3657 plugin_ui->set_title (generate_processor_title (plugin_insert));
3658 set_processor_ui (plugin_insert, plugin_ui);
3661 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
3666 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
3668 if (!_session->engine().connected()) {
3669 MessageDialog msg ( _("Not connected to audio engine - no I/O changes are possible"));
3674 PortInsertWindow *io_selector;
3676 Window* w = get_processor_ui (port_insert);
3679 io_selector = new PortInsertWindow (_session, port_insert);
3680 set_processor_ui (port_insert, io_selector);
3683 io_selector = dynamic_cast<PortInsertWindow *> (w);
3686 gidget = io_selector;
3693 ProcessorBox::get_generic_editor_window (boost::shared_ptr<Processor> processor)
3695 boost::shared_ptr<PluginInsert> plugin_insert
3696 = boost::dynamic_pointer_cast<PluginInsert>(processor);
3698 if (!plugin_insert) {
3702 PluginUIWindow* win = new PluginUIWindow (plugin_insert, true, false);
3703 win->set_title (generate_processor_title (plugin_insert));
3709 ProcessorBox::register_actions ()
3711 processor_box_actions = myactions.create_action_group (X_("ProcessorMenu"));
3713 Glib::RefPtr<Action> act;
3716 myactions.register_action (processor_box_actions, X_("newplugin"), _("New Plugin"),
3717 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
3719 act = myactions.register_action (processor_box_actions, X_("newinsert"), _("New Insert"),
3720 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
3721 ActionManager::engine_sensitive_actions.push_back (act);
3722 act = myactions.register_action (processor_box_actions, X_("newsend"), _("New External Send ..."),
3723 sigc::ptr_fun (ProcessorBox::rb_choose_send));
3724 ActionManager::engine_sensitive_actions.push_back (act);
3726 myactions.register_action (processor_box_actions, X_("newaux"), _("New Aux Send ..."));
3728 myactions.register_action (processor_box_actions, X_("controls"), _("Controls"));
3729 myactions.register_action (processor_box_actions, X_("send_options"), _("Send Options"));
3731 myactions.register_action (processor_box_actions, X_("clear"), _("Clear (all)"),
3732 sigc::ptr_fun (ProcessorBox::rb_clear));
3733 myactions.register_action (processor_box_actions, X_("clear_pre"), _("Clear (pre-fader)"),
3734 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
3735 myactions.register_action (processor_box_actions, X_("clear_post"), _("Clear (post-fader)"),
3736 sigc::ptr_fun (ProcessorBox::rb_clear_post));
3738 /* standard editing stuff */
3740 cut_action = myactions.register_action (processor_box_actions, X_("cut"), _("Cut"),
3741 sigc::ptr_fun (ProcessorBox::rb_cut));
3742 copy_action = myactions.register_action (processor_box_actions, X_("copy"), _("Copy"),
3743 sigc::ptr_fun (ProcessorBox::rb_copy));
3744 delete_action = myactions.register_action (processor_box_actions, X_("delete"), _("Delete"),
3745 sigc::ptr_fun (ProcessorBox::rb_delete));
3746 backspace_action = myactions.register_action (processor_box_actions, X_("backspace"), _("Delete"),
3747 sigc::ptr_fun (ProcessorBox::rb_delete));
3749 ActionManager::plugin_selection_sensitive_actions.push_back (cut_action);
3750 ActionManager::plugin_selection_sensitive_actions.push_back (copy_action);
3751 ActionManager::plugin_selection_sensitive_actions.push_back (delete_action);
3752 ActionManager::plugin_selection_sensitive_actions.push_back (backspace_action);
3754 paste_action = myactions.register_action (processor_box_actions, X_("paste"), _("Paste"),
3755 sigc::ptr_fun (ProcessorBox::rb_paste));
3756 rename_action = myactions.register_action (processor_box_actions, X_("rename"), _("Rename"),
3757 sigc::ptr_fun (ProcessorBox::rb_rename));
3758 myactions.register_action (processor_box_actions, X_("selectall"), _("Select All"),
3759 sigc::ptr_fun (ProcessorBox::rb_select_all));
3760 myactions.register_action (processor_box_actions, X_("deselectall"), _("Deselect All"),
3761 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
3763 /* activation etc. */
3765 myactions.register_action (processor_box_actions, X_("activate_all"), _("Activate All"),
3766 sigc::ptr_fun (ProcessorBox::rb_activate_all));
3767 myactions.register_action (processor_box_actions, X_("deactivate_all"), _("Deactivate All"),
3768 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
3769 myactions.register_action (processor_box_actions, X_("ab_plugins"), _("A/B Plugins"),
3770 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
3772 manage_pins_action = myactions.register_action (
3773 processor_box_actions, X_("manage-pins"), _("Pin Connections..."),
3774 sigc::ptr_fun (ProcessorBox::rb_manage_pins));
3777 edit_action = myactions.register_action (
3778 processor_box_actions, X_("edit"), _("Edit..."),
3779 sigc::ptr_fun (ProcessorBox::rb_edit));
3781 edit_generic_action = myactions.register_action (
3782 processor_box_actions, X_("edit-generic"), _("Edit with generic controls..."),
3783 sigc::ptr_fun (ProcessorBox::rb_edit_generic));
3789 ProcessorBox::rb_edit_generic ()
3791 if (_current_processor_box == 0) {
3795 _current_processor_box->for_selected_processors (&ProcessorBox::generic_edit_processor);
3799 ProcessorBox::rb_ab_plugins ()
3801 if (_current_processor_box == 0) {
3805 _current_processor_box->ab_plugins ();
3809 ProcessorBox::rb_manage_pins ()
3811 if (_current_processor_box == 0) {
3815 _current_processor_box->for_selected_processors (&ProcessorBox::manage_pins);
3818 ProcessorBox::rb_choose_plugin ()
3820 if (_current_processor_box == 0) {
3823 _current_processor_box->choose_plugin ();
3827 ProcessorBox::rb_choose_insert ()
3829 if (_current_processor_box == 0) {
3832 _current_processor_box->choose_insert ();
3836 ProcessorBox::rb_choose_send ()
3838 if (_current_processor_box == 0) {
3841 _current_processor_box->choose_send ();
3845 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
3847 if (_current_processor_box == 0) {
3851 _current_processor_box->choose_aux (wr);
3855 ProcessorBox::rb_clear ()
3857 if (_current_processor_box == 0) {
3861 _current_processor_box->clear_processors ();
3866 ProcessorBox::rb_clear_pre ()
3868 if (_current_processor_box == 0) {
3872 _current_processor_box->clear_processors (PreFader);
3877 ProcessorBox::rb_clear_post ()
3879 if (_current_processor_box == 0) {
3883 _current_processor_box->clear_processors (PostFader);
3887 ProcessorBox::rb_cut ()
3889 if (_current_processor_box == 0) {
3893 _current_processor_box->processor_operation (ProcessorsCut);
3897 ProcessorBox::rb_delete ()
3899 if (_current_processor_box == 0) {
3903 _current_processor_box->processor_operation (ProcessorsDelete);
3907 ProcessorBox::rb_copy ()
3909 if (_current_processor_box == 0) {
3912 _current_processor_box->processor_operation (ProcessorsCopy);
3916 ProcessorBox::rb_paste ()
3918 if (_current_processor_box == 0) {
3922 _current_processor_box->processor_operation (ProcessorsPaste);
3926 ProcessorBox::rb_rename ()
3928 if (_current_processor_box == 0) {
3931 _current_processor_box->rename_processors ();
3935 ProcessorBox::rb_select_all ()
3937 if (_current_processor_box == 0) {
3941 _current_processor_box->processor_operation (ProcessorsSelectAll);
3945 ProcessorBox::rb_deselect_all ()
3947 if (_current_processor_box == 0) {
3951 _current_processor_box->deselect_all_processors ();
3955 ProcessorBox::rb_activate_all ()
3957 if (_current_processor_box == 0) {
3961 _current_processor_box->all_visible_processors_active (true);
3965 ProcessorBox::rb_deactivate_all ()
3967 if (_current_processor_box == 0) {
3970 _current_processor_box->all_visible_processors_active (false);
3974 ProcessorBox::rb_edit ()
3976 if (_current_processor_box == 0) {
3980 _current_processor_box->for_selected_processors (&ProcessorBox::edit_processor);
3984 ProcessorBox::edit_aux_send (boost::shared_ptr<Processor> processor)
3986 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
3990 if (_parent_strip) {
3991 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
3992 if (_parent_strip->current_delivery() == send) {
3993 _parent_strip->revert_to_default_display ();
3995 _parent_strip->show_send(send);
4002 ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
4007 if (edit_aux_send (processor)) {
4010 if (!_session->engine().connected()) {
4014 ProcessorWindowProxy* proxy = find_window_proxy (processor);
4017 proxy->set_custom_ui_mode (true);
4018 proxy->show_the_right_window ();
4023 ProcessorBox::generic_edit_processor (boost::shared_ptr<Processor> processor)
4028 if (edit_aux_send (processor)) {
4031 if (!_session->engine().connected()) {
4035 ProcessorWindowProxy* proxy = find_window_proxy (processor);
4038 proxy->set_custom_ui_mode (false);
4039 proxy->show_the_right_window ();
4044 ProcessorBox::manage_pins (boost::shared_ptr<Processor> processor)
4049 PluginPinWindowProxy* proxy = processor->pinmgr_proxy ();
4058 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
4060 if (!what_changed.contains (ARDOUR::Properties::name)) {
4064 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
4066 boost::shared_ptr<Processor> processor;
4067 boost::shared_ptr<PluginInsert> plugin_insert;
4068 boost::shared_ptr<Send> send;
4070 list<ProcessorEntry*> children = processor_display.children();
4072 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
4074 processor = (*iter)->processor ();
4080 Window* w = get_processor_ui (processor);
4086 /* rename editor windows for sends and plugins */
4088 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
4089 w->set_title (send->name ());
4090 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
4091 w->set_title (generate_processor_title (plugin_insert));
4097 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
4099 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
4100 string::size_type email_pos;
4102 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
4103 maker = maker.substr (0, email_pos - 1);
4106 if (maker.length() > 32) {
4107 maker = maker.substr (0, 32);
4111 SessionObject* owner = pi->owner();
4114 return string_compose(_("%1: %2 (by %3)"), owner->name(), pi->name(), maker);
4116 return string_compose(_("%1 (by %2)"), pi->name(), maker);
4120 /** @param p Processor.
4121 * @return the UI window for \a p.
4124 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
4126 ProcessorWindowProxy* wp = p->window_proxy();
4133 /** Make a note of the UI window that a processor is using.
4134 * @param p Processor.
4135 * @param w UI window.
4138 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
4140 assert (p->window_proxy());
4142 p->window_proxy()->use_window (*w);
4146 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
4148 boost::shared_ptr<Delivery> d = w.lock ();
4153 list<ProcessorEntry*> children = processor_display.children ();
4154 list<ProcessorEntry*>::const_iterator i = children.begin();
4155 while (i != children.end() && (*i)->processor() != d) {
4159 if (i == children.end()) {
4160 processor_display.set_active (0);
4162 processor_display.set_active (*i);
4166 /** Called to repair the damage of Editor::show_window doing a show_all() */
4168 ProcessorBox::hide_things ()
4170 list<ProcessorEntry*> c = processor_display.children ();
4171 for (list<ProcessorEntry*>::iterator i = c.begin(); i != c.end(); ++i) {
4172 (*i)->hide_things ();
4177 ProcessorBox::processor_menu_unmapped ()
4179 processor_display.remove_placeholder ();
4180 /* make all possibly-desensitized actions sensitive again so that
4181 they be activated by other means (e.g. bindings)
4183 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, true);
4187 ProcessorBox::entry_gui_object_state (ProcessorEntry* entry)
4189 if (!_parent_strip) {
4193 GUIObjectState& st = _parent_strip->gui_object_state ();
4195 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
4197 return st.get_or_add_node (strip, entry->state_id());
4201 ProcessorBox::update_gui_object_state (ProcessorEntry* entry)
4203 XMLNode* proc = entry_gui_object_state (entry);
4208 /* XXX: this is a bit inefficient; we just remove all child nodes and re-add them */
4209 proc->remove_nodes_and_delete (X_("Object"));
4210 entry->add_control_state (proc);
4214 ProcessorBox::is_editor_mixer_strip() const
4216 return _parent_strip && !_parent_strip->mixer_owned();
4219 ProcessorWindowProxy::ProcessorWindowProxy (string const & name, ProcessorBox* box, boost::weak_ptr<Processor> processor)
4220 : WM::ProxyBase (name, string())
4221 , _processor_box (box)
4222 , _processor (processor)
4224 , want_custom (false)
4226 boost::shared_ptr<Processor> p = _processor.lock ();
4230 p->DropReferences.connect (going_away_connection, MISSING_INVALIDATOR, boost::bind (&ProcessorWindowProxy::processor_going_away, this), gui_context());
4233 ProcessorWindowProxy::~ProcessorWindowProxy()
4235 /* processor window proxies do not own the windows they create with
4236 * ::get(), so set _window to null before the normal WindowProxy method
4243 ProcessorWindowProxy::processor_going_away ()
4247 WM::Manager::instance().remove (this);
4248 /* should be no real reason to do this, since the object that would
4249 send DropReferences is about to be deleted, but lets do it anyway.
4251 going_away_connection.disconnect();
4255 ARDOUR::SessionHandlePtr*
4256 ProcessorWindowProxy::session_handle()
4263 ProcessorWindowProxy::get_state ()
4266 node = &ProxyBase::get_state();
4267 node->set_property (X_("custom-ui"), is_custom);
4272 ProcessorWindowProxy::set_state (const XMLNode& node, int /*version*/)
4274 XMLNodeList children = node.children ();
4275 XMLNodeList::const_iterator i = children.begin ();
4276 while (i != children.end()) {
4278 if ((*i)->name() == X_("Window") && (*i)->get_property (X_("name"), name) && name == _name) {
4284 if (i != children.end()) {
4285 (*i)->get_property (X_("custom-ui"), want_custom);
4288 return ProxyBase::set_state (node, 0);
4292 ProcessorWindowProxy::get (bool create)
4294 boost::shared_ptr<Processor> p = _processor.lock ();
4299 if (_window && (is_custom != want_custom)) {
4300 /* drop existing window - wrong type */
4301 set_state_mask (Gtkmm2ext::WindowProxy::StateMask (state_mask () & ~WindowProxy::Size));
4310 is_custom = want_custom;
4311 _window = _processor_box->get_editor_window (p, is_custom);
4316 _window->show_all ();
4322 ProcessorWindowProxy::show_the_right_window ()
4324 if (_window && (is_custom != want_custom)) {
4325 /* drop existing window - wrong type */
4326 set_state_mask (Gtkmm2ext::WindowProxy::StateMask (state_mask () & ~WindowProxy::Size));
4333 PluginPinWindowProxy::PluginPinWindowProxy(std::string const &name, boost::weak_ptr<ARDOUR::Processor> processor)
4334 : WM::ProxyBase (name, string())
4335 , _processor (processor)
4337 boost::shared_ptr<Processor> p = _processor.lock ();
4341 p->DropReferences.connect (going_away_connection, MISSING_INVALIDATOR, boost::bind (&PluginPinWindowProxy::processor_going_away, this), gui_context());
4344 PluginPinWindowProxy::~PluginPinWindowProxy()
4349 ARDOUR::SessionHandlePtr*
4350 PluginPinWindowProxy::session_handle ()
4352 ArdourWindow* aw = dynamic_cast<ArdourWindow*> (_window);
4353 if (aw) { return aw; }
4358 PluginPinWindowProxy::get (bool create)
4360 boost::shared_ptr<Processor> p = _processor.lock ();
4361 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (p);
4370 _window = new PluginPinDialog (pi);
4371 ArdourWindow* aw = dynamic_cast<ArdourWindow*> (_window);
4373 aw->set_session (_session);
4375 _window->show_all ();
4381 PluginPinWindowProxy::processor_going_away ()
4385 WM::Manager::instance().remove (this);
4386 going_away_connection.disconnect();
4391 ProcessorBox::load_bindings ()
4393 bindings = Bindings::get_bindings (X_("Processor Box"), myactions);