2 Copyright (C) 2000-2004 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "gtk2ardour-config.h"
28 #include <sigc++/bind.h>
30 #include "pbd/convert.h"
32 #include <glibmm/miscutils.h>
34 #include <gtkmm/messagedialog.h>
36 #include <gtkmm2ext/gtk_ui.h>
37 #include <gtkmm2ext/utils.h>
38 #include <gtkmm2ext/choice.h>
39 #include <gtkmm2ext/utils.h>
40 #include <gtkmm2ext/doi.h>
41 #include <gtkmm2ext/rgb_macros.h>
43 #include "ardour/amp.h"
44 #include "ardour/audio_track.h"
45 #include "ardour/audioengine.h"
46 #include "ardour/internal_return.h"
47 #include "ardour/internal_send.h"
48 #include "ardour/panner_shell.h"
49 #include "ardour/plugin_insert.h"
50 #include "ardour/pannable.h"
51 #include "ardour/port_insert.h"
52 #include "ardour/profile.h"
53 #include "ardour/return.h"
54 #include "ardour/route.h"
55 #include "ardour/send.h"
56 #include "ardour/session.h"
57 #include "ardour/types.h"
60 #include "ardour_dialog.h"
61 #include "ardour_ui.h"
62 #include "gui_thread.h"
63 #include "io_selector.h"
66 #include "mixer_strip.h"
67 #include "plugin_selector.h"
68 #include "plugin_ui.h"
69 #include "port_insert_ui.h"
70 #include "processor_box.h"
71 #include "public_editor.h"
72 #include "return_ui.h"
73 #include "route_processor_selection.h"
79 #ifdef AUDIOUNIT_SUPPORT
84 using namespace ARDOUR;
88 using namespace Gtkmm2ext;
90 ProcessorBox* ProcessorBox::_current_processor_box = 0;
91 RefPtr<Action> ProcessorBox::paste_action;
92 RefPtr<Action> ProcessorBox::cut_action;
93 RefPtr<Action> ProcessorBox::rename_action;
94 RefPtr<Action> ProcessorBox::edit_action;
95 RefPtr<Action> ProcessorBox::edit_generic_action;
97 static const uint32_t audio_port_color = 0x4A8A0EFF; // Green
98 static const uint32_t midi_port_color = 0x960909FF; //Red
100 ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processor> p, Width w)
101 : _button (ArdourButton::led_default_elements)
102 , _position (PreFader)
106 , _visual_state (Gtk::STATE_NORMAL)
108 , _output_icon(false)
112 _button.set_diameter (3);
113 _button.set_distinct_led_click (true);
114 _button.set_led_left (true);
115 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &ProcessorEntry::led_clicked));
116 _button.set_text (name (_width));
120 _vbox.pack_start (_routing_icon);
121 _vbox.pack_start (_input_icon);
122 _vbox.pack_start (_button, true, true);
123 _vbox.pack_end (_output_icon);
125 _button.set_active (_processor->active());
127 _routing_icon.set_no_show_all(true);
128 _input_icon.set_no_show_all(true);
131 _routing_icon.set_visible(false);
135 _processor->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_active_changed, this), gui_context());
136 _processor->PropertyChanged.connect (name_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_property_changed, this, _1), gui_context());
137 _processor->ConfigurationChanged.connect (config_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_configuration_changed, this, _1, _2), gui_context());
139 set<Evoral::Parameter> p = _processor->what_can_be_automated ();
140 for (set<Evoral::Parameter>::iterator i = p.begin(); i != p.end(); ++i) {
142 std::string label = _processor->describe_parameter (*i);
144 if (boost::dynamic_pointer_cast<Send> (_processor)) {
146 } else if (boost::dynamic_pointer_cast<Return> (_processor)) {
150 Control* c = new Control (_processor->automation_control (*i), label);
152 _controls.push_back (c);
154 if (boost::dynamic_pointer_cast<Amp> (_processor) == 0) {
155 /* Add non-Amp controls to the processor box */
156 _vbox.pack_start (c->box);
160 _input_icon.set_ports(_processor->input_streams());
161 _output_icon.set_ports(_processor->output_streams());
163 _routing_icon.set_sources(_processor->input_streams());
164 _routing_icon.set_sinks(_processor->output_streams());
169 _vbox.set_size_request (-1, _button.size_request().height);
173 ProcessorEntry::~ProcessorEntry ()
175 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
181 ProcessorEntry::action_widget ()
187 ProcessorEntry::widget ()
193 ProcessorEntry::drag_text () const
199 ProcessorEntry::set_position (Position p, uint32_t num)
204 if (_position_num == 0 || _routing_icon.get_visible()) {
214 ProcessorEntry::set_visual_state (Gtkmm2ext::VisualState s, bool yn)
217 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() | s));
219 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() & ~s));
224 ProcessorEntry::setup_visuals ()
228 _button.set_name ("processor prefader");
232 _button.set_name ("processor fader");
236 _button.set_name ("processor postfader");
242 boost::shared_ptr<Processor>
243 ProcessorEntry::processor () const
249 ProcessorEntry::set_enum_width (Width w)
252 _button.set_text (name (_width));
256 ProcessorEntry::led_clicked()
259 if (_button.get_active ()) {
260 _processor->deactivate ();
262 _processor->activate ();
268 ProcessorEntry::processor_active_changed ()
271 _button.set_active (_processor->active());
276 ProcessorEntry::processor_property_changed (const PropertyChange& what_changed)
278 if (what_changed.contains (ARDOUR::Properties::name)) {
279 _button.set_text (name (_width));
285 ProcessorEntry::processor_configuration_changed (const ChanCount in, const ChanCount out)
287 _input_icon.set_ports(in);
288 _output_icon.set_ports(out);
289 _routing_icon.set_sources(in);
290 _routing_icon.set_sinks(out);
291 _input_icon.queue_draw();
292 _output_icon.queue_draw();
293 _routing_icon.queue_draw();
297 ProcessorEntry::setup_tooltip ()
300 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
302 std::string postfix = "";
304 if ((replicated = pi->get_count()) > 1) {
305 postfix = string_compose(_("\nThis mono plugin has been replicated %1 times."), replicated);
307 if (pi->plugin()->has_editor()) {
308 ARDOUR_UI::instance()->set_tip (_button,
309 string_compose (_("<b>%1</b>\nDouble-click to show GUI.\nAlt+double-click to show generic GUI.%2"), name (Wide), postfix));
311 ARDOUR_UI::instance()->set_tip (_button,
312 string_compose (_("<b>%1</b>\nDouble-click to show generic GUI.%2"), name (Wide), postfix));
317 ARDOUR_UI::instance()->set_tip (_button, string_compose ("<b>%1</b>", name (Wide)));
321 ProcessorEntry::name (Width w) const
323 boost::shared_ptr<Send> send;
330 if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
331 !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
335 /* grab the send name out of its overall name */
337 string::size_type lbracket, rbracket;
338 lbracket = send->name().find ('[');
339 rbracket = send->name().find (']');
343 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
346 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
351 boost::shared_ptr<ARDOUR::PluginInsert> pi;
353 if ((pi = boost::dynamic_pointer_cast<ARDOUR::PluginInsert> (_processor)) != 0
354 && (replicated = pi->get_count()) > 1)
356 name_display += string_compose(_("(%1x1) "), replicated);
361 name_display += _processor->display_name();
364 name_display += PBD::short_version (_processor->display_name(), 5);
374 ProcessorEntry::show_all_controls ()
376 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
377 (*i)->set_visible (true);
380 _parent->update_gui_object_state (this);
384 ProcessorEntry::hide_all_controls ()
386 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
387 (*i)->set_visible (false);
390 _parent->update_gui_object_state (this);
394 ProcessorEntry::add_control_state (XMLNode* node) const
396 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
397 (*i)->add_state (node);
402 ProcessorEntry::set_control_state (XMLNode const * node)
404 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
405 (*i)->set_state (node);
410 ProcessorEntry::state_id () const
412 return string_compose ("processor %1", _processor->id().to_s());
416 ProcessorEntry::hide_things ()
418 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
419 (*i)->hide_things ();
425 ProcessorEntry::build_controls_menu ()
427 using namespace Menu_Helpers;
428 Menu* menu = manage (new Menu);
429 MenuList& items = menu->items ();
432 MenuElem (_("Show All Controls"), sigc::mem_fun (*this, &ProcessorEntry::show_all_controls))
436 MenuElem (_("Hide All Controls"), sigc::mem_fun (*this, &ProcessorEntry::hide_all_controls))
439 if (!_controls.empty ()) {
440 items.push_back (SeparatorElem ());
443 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
444 items.push_back (CheckMenuElem ((*i)->name ()));
445 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
446 c->set_active ((*i)->visible ());
447 c->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &ProcessorEntry::toggle_control_visibility), *i));
454 ProcessorEntry::toggle_control_visibility (Control* c)
456 c->set_visible (!c->visible ());
457 _parent->update_gui_object_state (this);
461 ProcessorEntry::build_send_options_menu ()
463 using namespace Menu_Helpers;
464 Menu* menu = manage (new Menu);
465 MenuList& items = menu->items ();
467 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (_processor);
470 items.push_back (CheckMenuElem (_("Link panner controls")));
471 CheckMenuItem* c = dynamic_cast<CheckMenuItem*> (&items.back ());
472 c->set_active (send->panner_shell()->is_linked_to_route());
473 c->signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::toggle_panner_link));
480 ProcessorEntry::toggle_panner_link ()
482 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (_processor);
484 send->panner_shell()->set_linked_to_route(!send->panner_shell()->is_linked_to_route());
488 ProcessorEntry::Control::Control (boost::shared_ptr<AutomationControl> c, string const & n)
490 , _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1)
491 , _slider (&_adjustment, 0, 13, false)
492 , _slider_persistant_tooltip (&_slider)
493 , _button (ArdourButton::led_default_elements)
494 , _ignore_ui_adjustment (false)
498 _slider.set_controllable (c);
499 box.set_padding(0, 0, 4, 4);
502 _button.set_text (_name);
503 _button.set_led_left (true);
504 _button.set_name ("processor control button");
508 _button.signal_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked));
509 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked));
510 c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
514 _slider.set_name ("ProcessorControlSlider");
515 _slider.set_text (_name);
520 double const lo = c->internal_to_interface (c->lower ());
521 double const up = c->internal_to_interface (c->upper ());
523 _adjustment.set_lower (lo);
524 _adjustment.set_upper (up);
525 _adjustment.set_step_increment ((up - lo) / 100);
526 _adjustment.set_page_increment ((up - lo) / 10);
527 _slider.set_default_value (c->internal_to_interface (c->normal ()));
529 _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &Control::slider_adjusted));
530 c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
533 ARDOUR_UI::RapidScreenUpdate.connect (sigc::mem_fun (*this, &Control::control_changed));
538 /* We're providing our own PersistentTooltip */
539 set_no_tooltip_whatsoever (_slider);
543 ProcessorEntry::Control::set_tooltip ()
545 boost::shared_ptr<AutomationControl> c = _control.lock ();
554 s << (c->get_value() > 0.5 ? _("on") : _("off"));
556 s << setprecision(2) << fixed;
557 s << c->internal_to_user (c->get_value ());
560 string sm = Glib::Markup::escape_text (s.str());
562 _slider_persistant_tooltip.set_tip (sm);
563 ARDOUR_UI::instance()->set_tip (_button, sm);
567 ProcessorEntry::Control::slider_adjusted ()
569 if (_ignore_ui_adjustment) {
573 boost::shared_ptr<AutomationControl> c = _control.lock ();
579 c->set_value (c->interface_to_internal (_adjustment.get_value ()));
584 ProcessorEntry::Control::button_clicked ()
586 boost::shared_ptr<AutomationControl> c = _control.lock ();
592 bool const n = _button.get_active ();
594 c->set_value (n ? 0 : 1);
595 _button.set_active (!n);
600 ProcessorEntry::Control::control_changed ()
602 boost::shared_ptr<AutomationControl> c = _control.lock ();
607 _ignore_ui_adjustment = true;
611 _button.set_active (c->get_value() > 0.5);
615 _adjustment.set_value (c->internal_to_interface (c->get_value ()));
619 s.setf (ios::fixed, ios::floatfield);
620 s << c->internal_to_user (c->get_value ());
623 _ignore_ui_adjustment = false;
627 ProcessorEntry::Control::add_state (XMLNode* node) const
629 XMLNode* c = new XMLNode (X_("Object"));
630 c->add_property (X_("id"), state_id ());
631 c->add_property (X_("visible"), _visible);
632 node->add_child_nocopy (*c);
636 ProcessorEntry::Control::set_state (XMLNode const * node)
638 XMLNode* n = GUIObjectState::get_node (node, state_id ());
640 XMLProperty* p = n->property (X_("visible"));
641 set_visible (p && string_is_affirmative (p->value ()));
648 ProcessorEntry::Control::set_visible (bool v)
659 /** Called when the Editor might have re-shown things that
663 ProcessorEntry::Control::hide_things ()
671 ProcessorEntry::Control::state_id () const
673 boost::shared_ptr<AutomationControl> c = _control.lock ();
676 return string_compose (X_("control %1"), c->id().to_s ());
679 PluginInsertProcessorEntry::PluginInsertProcessorEntry (ProcessorBox* b, boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
680 : ProcessorEntry (b, p, w)
683 p->PluginIoReConfigure.connect (
684 _splitting_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::plugin_insert_splitting_changed, this), gui_context()
687 plugin_insert_splitting_changed ();
691 PluginInsertProcessorEntry::plugin_insert_splitting_changed ()
693 _output_icon.set_ports(_plugin_insert->output_streams());
694 _routing_icon.set_splitting(_plugin_insert->splitting ());
696 ChanCount sources = _plugin_insert->input_streams();
697 ChanCount sinks = _plugin_insert->natural_input_streams();
699 /* replicated instances */
700 if (!_plugin_insert->splitting () && _plugin_insert->get_count() > 1) {
701 for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
702 sinks.set(*t, sinks.get(*t) * _plugin_insert->get_count());
706 if (_plugin_insert->natural_output_streams().n_midi() == 0 &&
707 _plugin_insert->output_streams().n_midi() == 1) {
708 sinks.set(DataType::MIDI, 1);
709 sources.set(DataType::MIDI, 1);
712 _input_icon.set_ports(sinks);
713 _routing_icon.set_sinks(sinks);
714 _routing_icon.set_sources(sources);
716 if (_plugin_insert->splitting () ||
717 _plugin_insert->input_streams().n_audio() < _plugin_insert->natural_input_streams().n_audio()
720 _routing_icon.set_size_request (-1, 7);
721 _routing_icon.set_visible(true);
724 _routing_icon.set_visible(false);
725 if (_position_num != 0) {
730 _input_icon.queue_draw();
731 _output_icon.queue_draw();
732 _routing_icon.queue_draw();
736 PluginInsertProcessorEntry::hide_things ()
738 ProcessorEntry::hide_things ();
739 plugin_insert_splitting_changed ();
744 ProcessorEntry::PortIcon::on_expose_event (GdkEventExpose* ev)
746 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
748 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
751 Gtk::Allocation a = get_allocation();
752 double const width = a.get_width();
753 double const height = a.get_height();
755 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
756 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
758 cairo_rectangle (cr, 0, 0, width, height);
761 if (_ports.n_total() > 1) {
762 for (uint32_t i = 0; i < _ports.n_total(); ++i) {
763 if (i < _ports.n_midi()) {
764 cairo_set_source_rgb (cr,
765 UINT_RGBA_R_FLT(midi_port_color),
766 UINT_RGBA_G_FLT(midi_port_color),
767 UINT_RGBA_B_FLT(midi_port_color));
769 cairo_set_source_rgb (cr,
770 UINT_RGBA_R_FLT(audio_port_color),
771 UINT_RGBA_G_FLT(audio_port_color),
772 UINT_RGBA_B_FLT(audio_port_color));
774 const float x = rintf(width * (.2f + .6f * i / (_ports.n_total() - 1.f)));
775 cairo_rectangle (cr, x-1, 0, 3, height);
778 } else if (_ports.n_total() == 1) {
779 if (_ports.n_midi() == 1) {
780 cairo_set_source_rgb (cr,
781 UINT_RGBA_R_FLT(midi_port_color),
782 UINT_RGBA_G_FLT(midi_port_color),
783 UINT_RGBA_B_FLT(midi_port_color));
785 cairo_set_source_rgb (cr,
786 UINT_RGBA_R_FLT(audio_port_color),
787 UINT_RGBA_G_FLT(audio_port_color),
788 UINT_RGBA_B_FLT(audio_port_color));
790 const float x = rintf(width * .5);
791 cairo_rectangle (cr, x-1, 0, 3, height);
801 ProcessorEntry::RoutingIcon::on_expose_event (GdkEventExpose* ev)
803 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
805 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
808 cairo_set_line_width (cr, 1.0);
809 cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
811 Gtk::Allocation a = get_allocation();
812 double const width = a.get_width();
813 double const height = a.get_height();
815 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
816 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
818 cairo_rectangle (cr, 0, 0, width, height);
821 Gdk::Color const fg = get_style()->get_fg (STATE_NORMAL);
822 cairo_set_source_rgb (cr, fg.get_red_p (), fg.get_green_p (), fg.get_blue_p ());
824 const uint32_t sources = _sources.n_total();
825 const uint32_t sinks = _sinks.n_total();
828 const uint32_t midi_sources = _sources.n_midi();
829 const uint32_t midi_sinks = _sinks.n_midi();
831 cairo_set_source_rgb (cr,
832 UINT_RGBA_R_FLT(midi_port_color),
833 UINT_RGBA_G_FLT(midi_port_color),
834 UINT_RGBA_B_FLT(midi_port_color));
835 if (midi_sources > 0 && midi_sinks > 0 && sinks > 1 && sources > 1) {
836 for (uint32_t i = 0 ; i < midi_sources; ++i) {
837 const float si_x = rintf(width * (.2f + .6f * i / (sinks - 1.f))) + .5f;
838 const float si_x0 = rintf(width * (.2f + .6f * i / (sources - 1.f))) + .5f;
839 cairo_move_to (cr, si_x, height);
840 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
843 } else if (midi_sources == 1 && midi_sinks == 1 && sinks == 1 && sources == 1) {
844 const float si_x = rintf(width * .5f) + .5f;
845 cairo_move_to (cr, si_x, height);
846 cairo_line_to (cr, si_x, 0);
848 } else if (midi_sources == 1 && midi_sinks == 1) {
849 /* unusual cases -- removed synth, midi-track w/audio plugins */
850 const float si_x = rintf(width * (sinks > 1 ? .2f : .5f)) + .5f;
851 const float si_x0 = rintf(width * (sources > 1 ? .2f : .5f)) + .5f;
852 cairo_move_to (cr, si_x, height);
853 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
858 const uint32_t audio_sources = _sources.n_audio();
859 const uint32_t audio_sinks = _sinks.n_audio();
860 cairo_set_source_rgb (cr,
861 UINT_RGBA_R_FLT(audio_port_color),
862 UINT_RGBA_G_FLT(audio_port_color),
863 UINT_RGBA_B_FLT(audio_port_color));
866 assert(audio_sources < 2);
867 assert(audio_sinks > 1);
868 /* assume there is only ever one MIDI port */
869 const float si_x0 = rintf(width * (midi_sources > 0 ? .8f : .5f)) + .5f;
870 for (uint32_t i = midi_sinks; i < sinks; ++i) {
871 const float si_x = rintf(width * (.2f + .6f * i / (sinks - 1.f))) + .5f;
872 cairo_move_to (cr, si_x, height);
873 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
876 } else if (audio_sources > 1) {
877 for (uint32_t i = 0 ; i < audio_sources; ++i) {
878 const float si_x = rintf(width * (.2f + .6f * (i + midi_sinks) / (sinks - 1.f))) + .5f;
879 const float si_x0 = rintf(width * (.2f + .6f * (i + midi_sources) / (sources - 1.f))) + .5f;
880 cairo_move_to (cr, si_x, height);
881 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
884 } else if (audio_sources == 1 && audio_sinks == 1) {
885 const float si_x = rintf(width * .5f) + .5f;
886 cairo_move_to (cr, si_x, height);
887 cairo_line_to (cr, si_x, 0);
894 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
895 RouteProcessorSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
896 : _parent_strip (parent)
897 , _owner_is_mixer (owner_is_mixer)
898 , ab_direction (true)
899 , _get_plugin_selector (get_plugin_selector)
901 , _visible_prefader_processors (0)
902 , _rr_selection(rsel)
903 , _redisplay_pending (false)
910 no_processor_redisplay = false;
912 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
913 processor_scroller.add (processor_display);
914 pack_start (processor_scroller, true, true);
916 processor_display.set_flags (CAN_FOCUS);
917 processor_display.set_name ("ProcessorList");
918 processor_display.set_data ("processorbox", this);
919 processor_display.set_size_request (48, -1);
920 processor_display.set_spacing (0);
922 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
923 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
925 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
926 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
928 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
929 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
931 processor_scroller.show ();
932 processor_display.show ();
935 parent->DeliveryChanged.connect (
936 _mixer_strip_connections, invalidator (*this), boost::bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
940 ARDOUR_UI::instance()->set_tip (processor_display, _("Right-click to add/remove/edit\nplugins,inserts,sends and more"));
943 ProcessorBox::~ProcessorBox ()
945 /* it may appear as if we should delete processor_menu but that is a
946 * pointer to a widget owned by the UI Manager, and has potentially
947 * be returned to many other ProcessorBoxes. GTK doesn't really make
948 * clear the ownership of this widget, which is a menu and thus is
949 * never packed into any container other than an implict GtkWindow.
951 * For now, until or if we ever get clarification over the ownership
952 * story just let it continue to exist. At worst, its a small memory leak.
957 ProcessorBox::set_route (boost::shared_ptr<Route> r)
963 _route_connections.drop_connections();
965 /* new route: any existing block on processor redisplay must be meaningless */
966 no_processor_redisplay = false;
969 _route->processors_changed.connect (
970 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
973 _route->DropReferences.connect (
974 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
977 _route->PropertyChanged.connect (
978 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
981 redisplay_processors ();
985 ProcessorBox::route_going_away ()
987 /* don't keep updating display as processors are deleted */
988 no_processor_redisplay = true;
993 ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
995 boost::shared_ptr<Processor> p;
997 p = position->processor ();
999 /* dropped on the blank entry (which will be before the
1000 fader), so use the first non-blank child as our
1001 `dropped on' processor */
1002 list<ProcessorEntry*> c = processor_display.children ();
1003 list<ProcessorEntry*>::iterator i = c.begin ();
1005 assert (i != c.end ());
1006 p = (*i)->processor ();
1011 list<ProcessorEntry*> children = source->selection ();
1012 list<boost::shared_ptr<Processor> > procs;
1013 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
1014 if ((*i)->processor ()) {
1015 procs.push_back ((*i)->processor ());
1019 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
1020 XMLNode& state = (*i)->get_state ();
1022 nlist.push_back (&state);
1023 paste_processor_state (nlist, p);
1027 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
1031 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
1032 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
1034 other->delete_dragged_processors (procs);
1040 ProcessorBox::set_width (Width w)
1048 list<ProcessorEntry*> children = processor_display.children ();
1049 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1050 (*i)->set_enum_width (w);
1057 ProcessorBox::build_possible_aux_menu ()
1059 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
1062 /* No aux sends if there are no busses */
1066 using namespace Menu_Helpers;
1067 Menu* menu = manage (new Menu);
1068 MenuList& items = menu->items();
1070 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
1071 if (!_route->internal_send_for (*r) && *r != _route) {
1072 items.push_back (MenuElem ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
1080 ProcessorBox::show_processor_menu (int arg)
1082 if (processor_menu == 0) {
1083 processor_menu = build_processor_menu ();
1084 processor_menu->signal_unmap().connect (sigc::mem_fun (*this, &ProcessorBox::processor_menu_unmapped));
1087 /* Sort out the plugin submenu */
1089 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newplugin"));
1091 if (plugin_menu_item) {
1092 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
1095 /* And the aux submenu */
1097 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newaux"));
1099 if (aux_menu_item) {
1100 Menu* m = build_possible_aux_menu();
1101 if (m && !m->items().empty()) {
1102 aux_menu_item->set_submenu (*m);
1103 aux_menu_item->set_sensitive (true);
1105 /* stupid gtkmm: we need to pass a null reference here */
1106 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
1107 aux_menu_item->set_sensitive (false);
1111 ProcessorEntry* single_selection = 0;
1112 if (processor_display.selection().size() == 1) {
1113 single_selection = processor_display.selection().front();
1116 /* And the controls submenu */
1118 Gtk::MenuItem* controls_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/controls"));
1120 if (controls_menu_item) {
1121 if (single_selection) {
1122 Menu* m = single_selection->build_controls_menu ();
1123 if (m && !m->items().empty()) {
1124 controls_menu_item->set_submenu (*m);
1125 controls_menu_item->set_sensitive (true);
1127 gtk_menu_item_set_submenu (controls_menu_item->gobj(), 0);
1128 controls_menu_item->set_sensitive (false);
1133 Gtk::MenuItem* send_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/send_options"));
1134 if (send_menu_item) {
1135 if (single_selection) {
1136 Menu* m = single_selection->build_send_options_menu ();
1137 if (m && !m->items().empty()) {
1138 send_menu_item->set_submenu (*m);
1139 send_menu_item->set_sensitive (true);
1141 gtk_menu_item_set_submenu (send_menu_item->gobj(), 0);
1142 send_menu_item->set_sensitive (false);
1147 /* Sensitise actions as approprioate */
1149 cut_action->set_sensitive (can_cut());
1150 paste_action->set_sensitive (!_rr_selection.processors.empty());
1152 const bool sensitive = !processor_display.selection().empty();
1153 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
1154 edit_action->set_sensitive (one_processor_can_be_edited ());
1155 edit_generic_action->set_sensitive (one_processor_can_be_edited ());
1157 boost::shared_ptr<PluginInsert> pi;
1158 if (single_selection) {
1159 pi = boost::dynamic_pointer_cast<PluginInsert> (single_selection->processor ());
1162 /* allow editing with an Ardour-generated UI for plugin inserts with editors */
1163 edit_action->set_sensitive (pi && pi->plugin()->has_editor ());
1165 /* disallow rename for multiple selections, for plugin inserts and for the fader */
1166 rename_action->set_sensitive (single_selection && !pi && !boost::dynamic_pointer_cast<Amp> (single_selection->processor ()));
1168 processor_menu->popup (1, arg);
1170 /* Add a placeholder gap to the processor list to indicate where a processor would be
1171 inserted were one chosen from the menu.
1174 processor_display.get_pointer (x, y);
1175 _placement = processor_display.add_placeholder (y);
1177 if (_visible_prefader_processors == 0 && _placement > 0) {
1183 ProcessorBox::enter_notify (GdkEventCrossing*)
1185 _current_processor_box = this;
1190 ProcessorBox::leave_notify (GdkEventCrossing*)
1196 ProcessorBox::processor_operation (ProcessorOperation op)
1198 ProcSelection targets;
1200 get_selected_processors (targets);
1202 if (targets.empty()) {
1205 processor_display.get_pointer (x, y);
1207 pair<ProcessorEntry *, double> const pointer = processor_display.get_child_at_position (y);
1209 if (pointer.first && pointer.first->processor()) {
1210 targets.push_back (pointer.first->processor ());
1215 case ProcessorsSelectAll:
1216 processor_display.select_all ();
1219 case ProcessorsCopy:
1220 copy_processors (targets);
1224 cut_processors (targets);
1227 case ProcessorsPaste:
1228 if (targets.empty()) {
1229 paste_processors ();
1231 paste_processors (targets.front());
1235 case ProcessorsDelete:
1236 delete_processors (targets);
1239 case ProcessorsToggleActive:
1240 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
1241 if ((*i)->active()) {
1242 (*i)->deactivate ();
1258 ProcessorWindowProxy*
1259 ProcessorBox::find_window_proxy (boost::shared_ptr<Processor> processor) const
1261 for (list<ProcessorWindowProxy*>::const_iterator i = _processor_window_info.begin(); i != _processor_window_info.end(); ++i) {
1262 boost::shared_ptr<Processor> p = (*i)->processor().lock();
1264 if (p && p == processor) {
1275 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
1277 boost::shared_ptr<Processor> processor;
1279 processor = child->processor ();
1283 bool selected = processor_display.selected (child);
1285 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
1287 if (_session->engine().connected()) {
1288 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
1290 if (!one_processor_can_be_edited ()) return true;
1292 if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
1293 generic_edit_processor (processor);
1295 edit_processor (processor);
1301 } else if (processor && ev->button == 1 && selected) {
1303 // this is purely informational but necessary for route params UI
1304 ProcessorSelected (processor); // emit
1306 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
1309 _get_plugin_selector()->show_manager ();
1316 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
1318 boost::shared_ptr<Processor> processor;
1320 processor = child->processor ();
1323 if (processor && Keyboard::is_delete_event (ev)) {
1325 Glib::signal_idle().connect (sigc::bind (
1326 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
1327 boost::weak_ptr<Processor>(processor)));
1329 } else if (Keyboard::is_context_menu_event (ev)) {
1331 show_processor_menu (ev->time);
1333 } else if (processor && Keyboard::is_button2_event (ev)
1335 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
1339 /* button2-click with no/appropriate modifiers */
1341 if (processor->active()) {
1342 processor->deactivate ();
1344 processor->activate ();
1352 ProcessorBox::build_processor_menu ()
1354 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/ProcessorMenu") );
1355 processor_menu->set_name ("ArdourContextMenu");
1356 return processor_menu;
1360 ProcessorBox::select_all_processors ()
1362 processor_display.select_all ();
1366 ProcessorBox::deselect_all_processors ()
1368 processor_display.select_none ();
1372 ProcessorBox::choose_plugin ()
1374 _get_plugin_selector()->set_interested_object (*this);
1377 /** @return true if an error occurred, otherwise false */
1379 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
1381 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
1383 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
1385 Route::ProcessorStreams err_streams;
1387 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
1388 weird_plugin_dialog (**p, err_streams);
1390 // XXX SHAREDPTR delete plugin here .. do we even need to care?
1393 if (Profile->get_sae()) {
1394 processor->activate ();
1403 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
1405 ArdourDialog dialog (_("Plugin Incompatibility"));
1408 string text = string_compose(_("You attempted to add the plugin \"%1\" in slot %2.\n"),
1409 p.name(), streams.index);
1411 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
1412 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
1414 text += _("\nThis plugin has:\n");
1416 uint32_t const n = p.get_info()->n_inputs.n_midi ();
1417 text += string_compose (ngettext ("\t%1 MIDI input\n", "\t%1 MIDI inputs\n", n), n);
1420 uint32_t const n = p.get_info()->n_inputs.n_audio ();
1421 text += string_compose (ngettext ("\t%1 audio input\n", "\t%1 audio inputs\n", n), n);
1424 text += _("\nbut at the insertion point, there are:\n");
1426 uint32_t const n = streams.count.n_midi ();
1427 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
1430 uint32_t const n = streams.count.n_audio ();
1431 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
1434 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
1435 label.set_text(text);
1437 dialog.get_vbox()->pack_start (label);
1438 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1440 dialog.set_name (X_("PluginIODialog"));
1441 dialog.set_modal (true);
1448 ProcessorBox::choose_insert ()
1450 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->pannable(), _route->mute_master()));
1451 _route->add_processor_by_index (processor, _placement);
1454 /* Caller must not hold process lock */
1456 ProcessorBox::choose_send ()
1458 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
1459 boost::shared_ptr<Send> send (new Send (*_session, sendpan, _route->mute_master()));
1461 /* make an educated guess at the initial number of outputs for the send */
1462 ChanCount outs = (_session->master_out())
1463 ? _session->master_out()->n_outputs()
1464 : _route->n_outputs();
1466 /* XXX need processor lock on route */
1468 Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock());
1469 send->output()->ensure_io (outs, false, this);
1470 } catch (AudioEngine::PortRegistrationFailure& err) {
1471 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
1475 /* let the user adjust the IO setup before creation.
1477 Note: this dialog is NOT modal - we just leave it to run and it will
1478 return when its Finished signal is emitted - typically when the window
1482 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
1485 /* keep a reference to the send so it doesn't get deleted while
1486 the IOSelectorWindow is doing its stuff
1488 _processor_being_created = send;
1490 ios->selector().Finished.connect (sigc::bind (
1491 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
1492 boost::weak_ptr<Processor>(send), ios));
1497 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1499 boost::shared_ptr<Processor> processor (weak_processor.lock());
1501 /* drop our temporary reference to the new send */
1502 _processor_being_created.reset ();
1509 case IOSelector::Cancelled:
1510 // processor will go away when all shared_ptrs to it vanish
1513 case IOSelector::Accepted:
1514 _route->add_processor_by_index (processor, _placement);
1515 if (Profile->get_sae()) {
1516 processor->activate ();
1521 delete_when_idle (ios);
1525 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1527 boost::shared_ptr<Processor> processor (weak_processor.lock());
1529 /* drop our temporary reference to the new return */
1530 _processor_being_created.reset ();
1537 case IOSelector::Cancelled:
1538 // processor will go away when all shared_ptrs to it vanish
1541 case IOSelector::Accepted:
1542 _route->add_processor_by_index (processor, _placement);
1543 if (Profile->get_sae()) {
1544 processor->activate ();
1549 delete_when_idle (ios);
1553 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
1559 boost::shared_ptr<Route> target = wr.lock();
1565 _session->add_internal_send (target, _placement, _route);
1569 ProcessorBox::route_processors_changed (RouteProcessorChange c)
1571 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
1572 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
1576 redisplay_processors ();
1580 ProcessorBox::redisplay_processors ()
1582 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors);
1585 if (no_processor_redisplay) {
1589 processor_display.clear ();
1591 _visible_prefader_processors = 0;
1594 _route->foreach_processor (sigc::bind (sigc::mem_fun (*this, &ProcessorBox::help_count_visible_prefader_processors),
1595 &_visible_prefader_processors, &fader_seen));
1597 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
1599 for (ProcessorWindowProxies::iterator i = _processor_window_info.begin(); i != _processor_window_info.end(); ++i) {
1600 (*i)->marked = false;
1603 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
1605 /* trim dead wood from the processor window proxy list */
1607 ProcessorWindowProxies::iterator i = _processor_window_info.begin();
1608 while (i != _processor_window_info.end()) {
1609 ProcessorWindowProxies::iterator j = i;
1612 if (!(*i)->valid()) {
1614 WM::Manager::instance().remove (*i);
1616 _processor_window_info.erase (i);
1618 } else if (!(*i)->marked) {
1620 /* this processor is no longer part of this processor
1623 * that could be because it was deleted or it could be
1624 * because the route being displayed in the parent
1627 * The latter only happens with the editor mixer strip.
1630 if (is_editor_mixer_strip()) {
1632 /* editor mixer strip .. DO NOTHING
1634 * note: the processor window stays visible if
1635 * it is already visible
1639 WM::Manager::instance().remove (*i);
1641 _processor_window_info.erase (i);
1648 setup_entry_positions ();
1651 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
1652 * not already have one.
1655 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
1657 boost::shared_ptr<Processor> p = w.lock ();
1662 ProcessorWindowProxies::iterator i = _processor_window_info.begin ();
1663 while (i != _processor_window_info.end()) {
1665 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
1668 /* this processor is already on the list; done */
1669 (*i)->marked = true;
1676 /* not on the list; add it */
1679 if (_parent_strip) {
1680 if (_parent_strip->mixer_owned()) {
1689 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
1690 string_compose ("%1-%2-%3", loc, _route->id(), p->id()),
1694 const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
1697 wp->set_state (*ui_xml);
1702 /* if the processor already has an existing UI,
1703 note that so that we don't recreate it
1706 void* existing_ui = p->get_ui ();
1709 wp->use_window (*(reinterpret_cast<Gtk::Window*>(existing_ui)));
1712 _processor_window_info.push_back (wp);
1713 WM::Manager::instance().register_window (wp);
1717 ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor> p, uint32_t* cnt, bool* amp_seen)
1719 boost::shared_ptr<Processor> processor (p.lock ());
1721 if (processor && processor->display_to_user()) {
1723 if (boost::dynamic_pointer_cast<Amp>(processor)) {
1734 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
1736 boost::shared_ptr<Processor> processor (p.lock ());
1738 if (!processor || !processor->display_to_user()) {
1742 boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
1743 ProcessorEntry* e = 0;
1744 if (plugin_insert) {
1745 e = new PluginInsertProcessorEntry (this, plugin_insert, _width);
1747 e = new ProcessorEntry (this, processor, _width);
1750 /* Set up this entry's state from the GUIObjectState */
1751 XMLNode* proc = entry_gui_object_state (e);
1753 e->set_control_state (proc);
1756 if (boost::dynamic_pointer_cast<Send> (processor)) {
1757 /* Always show send controls */
1758 e->show_all_controls ();
1761 processor_display.add_child (e);
1765 ProcessorBox::reordered ()
1767 compute_processor_sort_keys ();
1768 setup_entry_positions ();
1772 ProcessorBox::setup_entry_positions ()
1774 list<ProcessorEntry*> children = processor_display.children ();
1775 bool pre_fader = true;
1778 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1779 if (boost::dynamic_pointer_cast<Amp>((*i)->processor())) {
1781 (*i)->set_position (ProcessorEntry::Fader, num++);
1784 (*i)->set_position (ProcessorEntry::PreFader, num++);
1786 (*i)->set_position (ProcessorEntry::PostFader, num++);
1793 ProcessorBox::compute_processor_sort_keys ()
1795 list<ProcessorEntry*> children = processor_display.children ();
1796 Route::ProcessorList our_processors;
1798 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1799 if ((*i)->processor()) {
1800 our_processors.push_back ((*i)->processor ());
1804 if (_route->reorder_processors (our_processors)) {
1805 /* Reorder failed, so report this to the user. As far as I can see this must be done
1806 in an idle handler: it seems that the redisplay_processors() that happens below destroys
1807 widgets that were involved in the drag-and-drop on the processor list, which causes problems
1808 when the drag is torn down after this handler function is finished.
1810 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
1815 ProcessorBox::report_failed_reorder ()
1817 /* reorder failed, so redisplay */
1819 redisplay_processors ();
1821 /* now tell them about the problem */
1823 ArdourDialog dialog (_("Plugin Incompatibility"));
1826 label.set_text (_("\
1827 You cannot reorder these plugins/sends/inserts\n\
1828 in that way because the inputs and\n\
1829 outputs will not work correctly."));
1831 dialog.get_vbox()->set_border_width (12);
1832 dialog.get_vbox()->pack_start (label);
1833 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1835 dialog.set_name (X_("PluginIODialog"));
1836 dialog.set_modal (true);
1843 ProcessorBox::rename_processors ()
1845 ProcSelection to_be_renamed;
1847 get_selected_processors (to_be_renamed);
1849 if (to_be_renamed.empty()) {
1853 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
1854 rename_processor (*i);
1859 ProcessorBox::can_cut () const
1861 vector<boost::shared_ptr<Processor> > sel;
1863 get_selected_processors (sel);
1865 /* cut_processors () does not cut inserts */
1867 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
1869 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1870 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1871 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1880 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
1882 if (to_be_removed.empty()) {
1886 XMLNode* node = new XMLNode (X_("cut"));
1887 Route::ProcessorList to_cut;
1889 no_processor_redisplay = true;
1890 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
1891 // Cut only plugins, sends and returns
1892 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1893 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1894 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1896 Window* w = get_processor_ui (*i);
1902 XMLNode& child ((*i)->get_state());
1903 node->add_child_nocopy (child);
1904 to_cut.push_back (*i);
1908 if (_route->remove_processors (to_cut) != 0) {
1910 no_processor_redisplay = false;
1914 _rr_selection.set (node);
1916 no_processor_redisplay = false;
1917 redisplay_processors ();
1921 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
1923 if (to_be_copied.empty()) {
1927 XMLNode* node = new XMLNode (X_("copy"));
1929 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
1930 // Copy only plugins, sends, returns
1931 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1932 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1933 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1934 node->add_child_nocopy ((*i)->get_state());
1938 _rr_selection.set (node);
1942 ProcessorBox::delete_processors (const ProcSelection& targets)
1944 if (targets.empty()) {
1948 no_processor_redisplay = true;
1950 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
1952 Window* w = get_processor_ui (*i);
1958 _route->remove_processor(*i);
1961 no_processor_redisplay = false;
1962 redisplay_processors ();
1966 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
1968 list<boost::shared_ptr<Processor> >::const_iterator x;
1970 no_processor_redisplay = true;
1971 for (x = procs.begin(); x != procs.end(); ++x) {
1973 Window* w = get_processor_ui (*x);
1979 _route->remove_processor(*x);
1982 no_processor_redisplay = false;
1983 redisplay_processors ();
1987 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
1989 boost::shared_ptr<Processor> processor (weak_processor.lock());
1995 /* NOT copied to _mixer.selection() */
1997 no_processor_redisplay = true;
1998 _route->remove_processor (processor);
1999 no_processor_redisplay = false;
2000 redisplay_processors ();
2006 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
2008 ArdourPrompter name_prompter (true);
2010 name_prompter.set_title (_("Rename Processor"));
2011 name_prompter.set_prompt (_("New name:"));
2012 name_prompter.set_initial_text (processor->name());
2013 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
2014 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
2015 name_prompter.show_all ();
2017 switch (name_prompter.run ()) {
2019 case Gtk::RESPONSE_ACCEPT:
2020 name_prompter.get_result (result);
2021 if (result.length()) {
2024 string test = result;
2026 while (tries < 100) {
2027 if (_session->io_name_is_legal (test)) {
2033 test = string_compose ("%1-%2", result, tries);
2037 processor->set_name (result);
2040 ARDOUR_UI::instance()->popup_error
2041 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
2051 ProcessorBox::paste_processors ()
2053 if (_rr_selection.processors.empty()) {
2057 paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
2061 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
2064 if (_rr_selection.processors.empty()) {
2068 paste_processor_state (_rr_selection.processors.get_node().children(), before);
2072 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
2074 XMLNodeConstIterator niter;
2075 list<boost::shared_ptr<Processor> > copies;
2077 if (nlist.empty()) {
2081 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2083 XMLProperty const * type = (*niter)->property ("type");
2084 XMLProperty const * role = (*niter)->property ("role");
2087 boost::shared_ptr<Processor> p;
2089 if (type->value() == "meter" ||
2090 type->value() == "main-outs" ||
2091 type->value() == "amp" ||
2092 type->value() == "intreturn") {
2093 /* do not paste meter, main outs, amp or internal returns */
2096 } else if (type->value() == "intsend") {
2098 /* aux sends are OK, but those used for
2099 * other purposes, are not.
2104 if (role->value() != "Aux") {
2108 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
2109 XMLNode n (**niter);
2110 InternalSend* s = new InternalSend (*_session, sendpan, _route->mute_master(),
2111 boost::shared_ptr<Route>(), Delivery::Aux);
2113 IOProcessor::prepare_for_reset (n, s->name());
2115 if (s->set_state (n, Stateful::loading_state_version)) {
2122 } else if (type->value() == "send") {
2124 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
2125 XMLNode n (**niter);
2127 Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
2129 IOProcessor::prepare_for_reset (n, s->name());
2131 if (s->set_state (n, Stateful::loading_state_version)) {
2138 } else if (type->value() == "return") {
2140 XMLNode n (**niter);
2141 Return* r = new Return (*_session);
2143 IOProcessor::prepare_for_reset (n, r->name());
2145 if (r->set_state (n, Stateful::loading_state_version)) {
2152 } else if (type->value() == "port") {
2154 XMLNode n (**niter);
2155 PortInsert* pi = new PortInsert (*_session, _route->pannable (), _route->mute_master ());
2157 IOProcessor::prepare_for_reset (n, pi->name());
2159 if (pi->set_state (n, Stateful::loading_state_version)) {
2166 /* XXX its a bit limiting to assume that everything else
2170 p.reset (new PluginInsert (*_session));
2171 p->set_state (**niter, Stateful::current_state_version);
2174 copies.push_back (p);
2178 error << _("plugin insert constructor failed") << endmsg;
2182 if (copies.empty()) {
2186 if (_route->add_processors (copies, p)) {
2189 "Copying the set of processors on the clipboard failed,\n\
2190 probably because the I/O configuration of the plugins\n\
2191 could not match the configuration of this track.");
2192 MessageDialog am (msg);
2198 ProcessorBox::get_selected_processors (ProcSelection& processors) const
2200 const list<ProcessorEntry*> selection = processor_display.selection ();
2201 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
2202 processors.push_back ((*i)->processor ());
2207 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
2209 list<ProcessorEntry*> selection = processor_display.selection ();
2210 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
2211 (this->*method) ((*i)->processor ());
2216 ProcessorBox::all_visible_processors_active (bool state)
2218 _route->all_visible_processors_active (state);
2222 ProcessorBox::ab_plugins ()
2224 _route->ab_plugins (ab_direction);
2225 ab_direction = !ab_direction;
2230 ProcessorBox::clear_processors ()
2233 vector<string> choices;
2235 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
2236 "(this cannot be undone)"), _route->name());
2238 choices.push_back (_("Cancel"));
2239 choices.push_back (_("Yes, remove them all"));
2241 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
2243 if (prompter.run () == 1) {
2244 _route->clear_processors (PreFader);
2245 _route->clear_processors (PostFader);
2250 ProcessorBox::clear_processors (Placement p)
2253 vector<string> choices;
2255 if (p == PreFader) {
2256 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
2257 "(this cannot be undone)"), _route->name());
2259 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
2260 "(this cannot be undone)"), _route->name());
2263 choices.push_back (_("Cancel"));
2264 choices.push_back (_("Yes, remove them all"));
2266 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
2268 if (prompter.run () == 1) {
2269 _route->clear_processors (p);
2274 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
2276 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
2277 if (at && at->freeze_state() == AudioTrack::Frozen) {
2282 boost::dynamic_pointer_cast<Send> (processor) ||
2283 boost::dynamic_pointer_cast<Return> (processor) ||
2284 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
2285 boost::dynamic_pointer_cast<PortInsert> (processor)
2294 ProcessorBox::one_processor_can_be_edited ()
2296 list<ProcessorEntry*> selection = processor_display.selection ();
2297 list<ProcessorEntry*>::iterator i = selection.begin();
2298 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
2302 return (i != selection.end());
2306 ProcessorBox::get_editor_window (boost::shared_ptr<Processor> processor, bool use_custom)
2308 boost::shared_ptr<Send> send;
2309 boost::shared_ptr<InternalSend> internal_send;
2310 boost::shared_ptr<Return> retrn;
2311 boost::shared_ptr<PluginInsert> plugin_insert;
2312 boost::shared_ptr<PortInsert> port_insert;
2315 /* This method may or may not return a Window, but if it does not it
2316 * will modify the parent mixer strip appearance layout to allow
2317 * "editing" the @param processor that was passed in.
2319 * So for example, if the processor is an Amp (gain), the parent strip
2320 * will be forced back into a model where the fader controls the main gain.
2321 * If the processor is a send, then we map the send controls onto the
2324 * Plugins and others will return a window for control.
2327 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
2329 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
2334 if (boost::dynamic_pointer_cast<Amp> (processor)) {
2336 if (_parent_strip) {
2337 _parent_strip->revert_to_default_display ();
2340 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
2342 if (!_session->engine().connected()) {
2346 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
2348 gidget = new SendUIWindow (send, _session);
2351 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
2353 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
2354 /* no GUI for these */
2358 if (!_session->engine().connected()) {
2362 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
2364 ReturnUIWindow *return_ui;
2365 Window* w = get_processor_ui (retrn);
2369 return_ui = new ReturnUIWindow (retrn, _session);
2370 return_ui->set_title (retrn->name ());
2371 set_processor_ui (send, return_ui);
2374 return_ui = dynamic_cast<ReturnUIWindow *> (w);
2379 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
2381 PluginUIWindow *plugin_ui;
2383 /* these are both allowed to be null */
2385 Window* w = get_processor_ui (plugin_insert);
2388 plugin_ui = new PluginUIWindow (plugin_insert, false, use_custom);
2389 plugin_ui->set_title (generate_processor_title (plugin_insert));
2390 set_processor_ui (plugin_insert, plugin_ui);
2393 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
2398 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
2400 if (!_session->engine().connected()) {
2401 MessageDialog msg ( _("Not connected to audio engine - no I/O changes are possible"));
2406 PortInsertWindow *io_selector;
2408 Window* w = get_processor_ui (port_insert);
2411 io_selector = new PortInsertWindow (_session, port_insert);
2412 set_processor_ui (port_insert, io_selector);
2415 io_selector = dynamic_cast<PortInsertWindow *> (w);
2418 gidget = io_selector;
2425 ProcessorBox::get_generic_editor_window (boost::shared_ptr<Processor> processor)
2427 boost::shared_ptr<PluginInsert> plugin_insert
2428 = boost::dynamic_pointer_cast<PluginInsert>(processor);
2430 if (!plugin_insert) {
2434 PluginUIWindow* win = new PluginUIWindow (plugin_insert, true, false);
2435 win->set_title (generate_processor_title (plugin_insert));
2441 ProcessorBox::register_actions ()
2443 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("ProcessorMenu"));
2444 Glib::RefPtr<Action> act;
2447 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin"),
2448 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
2450 act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"),
2451 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
2452 ActionManager::engine_sensitive_actions.push_back (act);
2453 act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New External Send ..."),
2454 sigc::ptr_fun (ProcessorBox::rb_choose_send));
2455 ActionManager::engine_sensitive_actions.push_back (act);
2457 ActionManager::register_action (popup_act_grp, X_("newaux"), _("New Aux Send ..."));
2459 ActionManager::register_action (popup_act_grp, X_("controls"), _("Controls"));
2460 ActionManager::register_action (popup_act_grp, X_("send_options"), _("Send Options"));
2462 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear (all)"),
2463 sigc::ptr_fun (ProcessorBox::rb_clear));
2464 ActionManager::register_action (popup_act_grp, X_("clear_pre"), _("Clear (pre-fader)"),
2465 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
2466 ActionManager::register_action (popup_act_grp, X_("clear_post"), _("Clear (post-fader)"),
2467 sigc::ptr_fun (ProcessorBox::rb_clear_post));
2469 /* standard editing stuff */
2470 cut_action = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"),
2471 sigc::ptr_fun (ProcessorBox::rb_cut));
2472 ActionManager::plugin_selection_sensitive_actions.push_back(cut_action);
2473 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),
2474 sigc::ptr_fun (ProcessorBox::rb_copy));
2475 ActionManager::plugin_selection_sensitive_actions.push_back(act);
2477 act = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"),
2478 sigc::ptr_fun (ProcessorBox::rb_delete));
2479 ActionManager::plugin_selection_sensitive_actions.push_back(act); // ??
2481 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"),
2482 sigc::ptr_fun (ProcessorBox::rb_paste));
2483 rename_action = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"),
2484 sigc::ptr_fun (ProcessorBox::rb_rename));
2485 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"),
2486 sigc::ptr_fun (ProcessorBox::rb_select_all));
2487 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"),
2488 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
2490 /* activation etc. */
2492 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate All"),
2493 sigc::ptr_fun (ProcessorBox::rb_activate_all));
2494 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate All"),
2495 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
2496 ActionManager::register_action (popup_act_grp, X_("ab_plugins"), _("A/B Plugins"),
2497 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
2500 edit_action = ActionManager::register_action (
2501 popup_act_grp, X_("edit"), _("Edit..."),
2502 sigc::ptr_fun (ProcessorBox::rb_edit));
2504 edit_generic_action = ActionManager::register_action (
2505 popup_act_grp, X_("edit-generic"), _("Edit with generic controls..."),
2506 sigc::ptr_fun (ProcessorBox::rb_edit_generic));
2508 ActionManager::add_action_group (popup_act_grp);
2512 ProcessorBox::rb_edit_generic ()
2514 if (_current_processor_box == 0) {
2518 _current_processor_box->for_selected_processors (&ProcessorBox::generic_edit_processor);
2522 ProcessorBox::rb_ab_plugins ()
2524 if (_current_processor_box == 0) {
2528 _current_processor_box->ab_plugins ();
2532 ProcessorBox::rb_choose_plugin ()
2534 if (_current_processor_box == 0) {
2537 _current_processor_box->choose_plugin ();
2541 ProcessorBox::rb_choose_insert ()
2543 if (_current_processor_box == 0) {
2546 _current_processor_box->choose_insert ();
2550 ProcessorBox::rb_choose_send ()
2552 if (_current_processor_box == 0) {
2555 _current_processor_box->choose_send ();
2559 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
2561 if (_current_processor_box == 0) {
2565 _current_processor_box->choose_aux (wr);
2569 ProcessorBox::rb_clear ()
2571 if (_current_processor_box == 0) {
2575 _current_processor_box->clear_processors ();
2580 ProcessorBox::rb_clear_pre ()
2582 if (_current_processor_box == 0) {
2586 _current_processor_box->clear_processors (PreFader);
2591 ProcessorBox::rb_clear_post ()
2593 if (_current_processor_box == 0) {
2597 _current_processor_box->clear_processors (PostFader);
2601 ProcessorBox::rb_cut ()
2603 if (_current_processor_box == 0) {
2607 _current_processor_box->processor_operation (ProcessorsCut);
2611 ProcessorBox::rb_delete ()
2613 if (_current_processor_box == 0) {
2617 _current_processor_box->processor_operation (ProcessorsDelete);
2621 ProcessorBox::rb_copy ()
2623 if (_current_processor_box == 0) {
2626 _current_processor_box->processor_operation (ProcessorsCopy);
2630 ProcessorBox::rb_paste ()
2632 if (_current_processor_box == 0) {
2636 _current_processor_box->processor_operation (ProcessorsPaste);
2640 ProcessorBox::rb_rename ()
2642 if (_current_processor_box == 0) {
2645 _current_processor_box->rename_processors ();
2649 ProcessorBox::rb_select_all ()
2651 if (_current_processor_box == 0) {
2655 _current_processor_box->processor_operation (ProcessorsSelectAll);
2659 ProcessorBox::rb_deselect_all ()
2661 if (_current_processor_box == 0) {
2665 _current_processor_box->deselect_all_processors ();
2669 ProcessorBox::rb_activate_all ()
2671 if (_current_processor_box == 0) {
2675 _current_processor_box->all_visible_processors_active (true);
2679 ProcessorBox::rb_deactivate_all ()
2681 if (_current_processor_box == 0) {
2684 _current_processor_box->all_visible_processors_active (false);
2688 ProcessorBox::rb_edit ()
2690 if (_current_processor_box == 0) {
2694 _current_processor_box->for_selected_processors (&ProcessorBox::edit_processor);
2698 ProcessorBox::edit_aux_send (boost::shared_ptr<Processor> processor)
2700 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
2704 if (_parent_strip) {
2705 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
2706 if (_parent_strip->current_delivery() == send) {
2707 _parent_strip->revert_to_default_display ();
2709 _parent_strip->show_send(send);
2716 ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
2721 if (edit_aux_send (processor)) {
2725 ProcessorWindowProxy* proxy = find_window_proxy (processor);
2728 proxy->set_custom_ui_mode (true);
2734 ProcessorBox::generic_edit_processor (boost::shared_ptr<Processor> processor)
2739 if (edit_aux_send (processor)) {
2743 ProcessorWindowProxy* proxy = find_window_proxy (processor);
2746 proxy->set_custom_ui_mode (false);
2752 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
2754 if (!what_changed.contains (ARDOUR::Properties::name)) {
2758 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
2760 boost::shared_ptr<Processor> processor;
2761 boost::shared_ptr<PluginInsert> plugin_insert;
2762 boost::shared_ptr<Send> send;
2764 list<ProcessorEntry*> children = processor_display.children();
2766 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
2768 processor = (*iter)->processor ();
2774 Window* w = get_processor_ui (processor);
2780 /* rename editor windows for sends and plugins */
2782 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
2783 w->set_title (send->name ());
2784 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
2785 w->set_title (generate_processor_title (plugin_insert));
2791 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
2793 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
2794 string::size_type email_pos;
2796 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
2797 maker = maker.substr (0, email_pos - 1);
2800 if (maker.length() > 32) {
2801 maker = maker.substr (0, 32);
2805 SessionObject* owner = pi->owner();
2808 return string_compose(_("%1: %2 (by %3)"), owner->name(), pi->name(), maker);
2810 return string_compose(_("%1 (by %2)"), pi->name(), maker);
2814 /** @param p Processor.
2815 * @return the UI window for \a p.
2818 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
2820 list<ProcessorWindowProxy*>::const_iterator i = _processor_window_info.begin ();
2821 while (i != _processor_window_info.end()) {
2822 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2824 return (*i)->get ();
2833 /** Make a note of the UI window that a processor is using.
2834 * @param p Processor.
2835 * @param w UI window.
2838 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
2840 list<ProcessorWindowProxy*>::iterator i = _processor_window_info.begin ();
2844 while (i != _processor_window_info.end()) {
2845 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2847 (*i)->use_window (*w);
2854 /* we shouldn't get here, because the ProcessorUIList should always contain
2855 an entry for each processor.
2861 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
2863 boost::shared_ptr<Delivery> d = w.lock ();
2868 list<ProcessorEntry*> children = processor_display.children ();
2869 list<ProcessorEntry*>::const_iterator i = children.begin();
2870 while (i != children.end() && (*i)->processor() != d) {
2874 if (i == children.end()) {
2875 processor_display.set_active (0);
2877 processor_display.set_active (*i);
2881 /** Called to repair the damage of Editor::show_window doing a show_all() */
2883 ProcessorBox::hide_things ()
2885 list<ProcessorEntry*> c = processor_display.children ();
2886 for (list<ProcessorEntry*>::iterator i = c.begin(); i != c.end(); ++i) {
2887 (*i)->hide_things ();
2892 ProcessorBox::processor_menu_unmapped ()
2894 processor_display.remove_placeholder ();
2898 ProcessorBox::entry_gui_object_state (ProcessorEntry* entry)
2900 if (!_parent_strip) {
2904 GUIObjectState& st = _parent_strip->gui_object_state ();
2906 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
2908 return st.get_or_add_node (strip, entry->state_id());
2912 ProcessorBox::update_gui_object_state (ProcessorEntry* entry)
2914 XMLNode* proc = entry_gui_object_state (entry);
2919 /* XXX: this is a bit inefficient; we just remove all child nodes and re-add them */
2920 proc->remove_nodes_and_delete (X_("Object"));
2921 entry->add_control_state (proc);
2925 ProcessorBox::is_editor_mixer_strip() const
2927 return _parent_strip && !_parent_strip->mixer_owned();
2930 ProcessorWindowProxy::ProcessorWindowProxy (string const & name, ProcessorBox* box, boost::weak_ptr<Processor> processor)
2931 : WM::ProxyBase (name, string())
2933 , _processor_box (box)
2934 , _processor (processor)
2936 , want_custom (false)
2939 boost::shared_ptr<Processor> p = _processor.lock ();
2943 p->DropReferences.connect (going_away_connection, MISSING_INVALIDATOR, boost::bind (&ProcessorWindowProxy::processor_going_away, this), gui_context());
2946 ProcessorWindowProxy::~ProcessorWindowProxy()
2948 /* processor window proxies do not own the windows they create with
2949 * ::get(), so set _window to null before the normal WindowProxy method
2956 ProcessorWindowProxy::processor_going_away ()
2961 /* should be no real reason to do this, since the object that would
2962 send DropReferences is about to be deleted, but lets do it anyway.
2964 going_away_connection.disconnect();
2967 ARDOUR::SessionHandlePtr*
2968 ProcessorWindowProxy::session_handle()
2975 ProcessorWindowProxy::valid() const
2981 ProcessorWindowProxy::get_state () const
2984 node = &ProxyBase::get_state();
2985 node->add_property (X_("custom-ui"), is_custom? X_("yes") : X_("no"));
2990 ProcessorWindowProxy::set_state (const XMLNode& node)
2992 XMLNodeList children = node.children ();
2993 XMLNodeList::const_iterator i = children.begin ();
2994 while (i != children.end()) {
2995 XMLProperty* prop = (*i)->property (X_("name"));
2996 if ((*i)->name() == X_("Window") && prop && prop->value() == _name) {
3002 if (i != children.end()) {
3004 if ((prop = (*i)->property (X_("custom-ui"))) != 0) {
3005 want_custom = PBD::string_is_affirmative (prop->value ());
3009 ProxyBase::set_state(node);
3013 ProcessorWindowProxy::get (bool create)
3015 boost::shared_ptr<Processor> p = _processor.lock ();
3020 if (_window && (is_custom != want_custom)) {
3021 /* drop existing window - wrong type */
3030 is_custom = want_custom;
3031 _window = _processor_box->get_editor_window (p, is_custom);
3042 ProcessorWindowProxy::toggle ()
3044 if (_window && (is_custom != want_custom)) {
3045 /* drop existing window - wrong type */
3048 is_custom = want_custom;
3050 WM::ProxyBase::toggle ();