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);
851 const uint32_t audio_sources = _sources.n_audio();
852 const uint32_t audio_sinks = _sinks.n_audio();
853 cairo_set_source_rgb (cr,
854 UINT_RGBA_R_FLT(audio_port_color),
855 UINT_RGBA_G_FLT(audio_port_color),
856 UINT_RGBA_B_FLT(audio_port_color));
859 assert(audio_sinks > 1);
860 const float si_x0 = rintf(width * .5f) + .5f;
861 for (uint32_t i = midi_sinks; i < sinks; ++i) {
862 const float si_x = rintf(width * (.2f + .6f * i / (sinks - 1.f))) + .5f;
863 cairo_move_to (cr, si_x, height);
864 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
867 } else if (audio_sources > 1) {
868 for (uint32_t i = 0 ; i < audio_sources; ++i) {
869 const float si_x = rintf(width * (.2f + .6f * (i + midi_sinks) / (sinks - 1.f))) + .5f;
870 const float si_x0 = rintf(width * (.2f + .6f * (i + midi_sources) / (sources - 1.f))) + .5f;
871 cairo_move_to (cr, si_x, height);
872 cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
875 } else if (audio_sources == 1 && audio_sinks == 1) {
876 const float si_x = rintf(width * .5f) + .5f;
877 cairo_move_to (cr, si_x, height);
878 cairo_line_to (cr, si_x, 0);
885 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
886 RouteProcessorSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
887 : _parent_strip (parent)
888 , _owner_is_mixer (owner_is_mixer)
889 , ab_direction (true)
890 , _get_plugin_selector (get_plugin_selector)
892 , _visible_prefader_processors (0)
893 , _rr_selection(rsel)
894 , _redisplay_pending (false)
901 no_processor_redisplay = false;
903 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
904 processor_scroller.add (processor_display);
905 pack_start (processor_scroller, true, true);
907 processor_display.set_flags (CAN_FOCUS);
908 processor_display.set_name ("ProcessorList");
909 processor_display.set_data ("processorbox", this);
910 processor_display.set_size_request (48, -1);
911 processor_display.set_spacing (0);
913 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
914 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
916 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
917 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
919 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
920 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
922 processor_scroller.show ();
923 processor_display.show ();
926 parent->DeliveryChanged.connect (
927 _mixer_strip_connections, invalidator (*this), boost::bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
931 ARDOUR_UI::instance()->set_tip (processor_display, _("Right-click to add/remove/edit\nplugins,inserts,sends and more"));
934 ProcessorBox::~ProcessorBox ()
936 /* it may appear as if we should delete processor_menu but that is a
937 * pointer to a widget owned by the UI Manager, and has potentially
938 * be returned to many other ProcessorBoxes. GTK doesn't really make
939 * clear the ownership of this widget, which is a menu and thus is
940 * never packed into any container other than an implict GtkWindow.
942 * For now, until or if we ever get clarification over the ownership
943 * story just let it continue to exist. At worst, its a small memory leak.
948 ProcessorBox::set_route (boost::shared_ptr<Route> r)
954 _route_connections.drop_connections();
956 /* new route: any existing block on processor redisplay must be meaningless */
957 no_processor_redisplay = false;
960 _route->processors_changed.connect (
961 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
964 _route->DropReferences.connect (
965 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
968 _route->PropertyChanged.connect (
969 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
972 redisplay_processors ();
976 ProcessorBox::route_going_away ()
978 /* don't keep updating display as processors are deleted */
979 no_processor_redisplay = true;
984 ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
986 boost::shared_ptr<Processor> p;
988 p = position->processor ();
990 /* dropped on the blank entry (which will be before the
991 fader), so use the first non-blank child as our
992 `dropped on' processor */
993 list<ProcessorEntry*> c = processor_display.children ();
994 list<ProcessorEntry*>::iterator i = c.begin ();
996 assert (i != c.end ());
997 p = (*i)->processor ();
1002 list<ProcessorEntry*> children = source->selection ();
1003 list<boost::shared_ptr<Processor> > procs;
1004 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
1005 if ((*i)->processor ()) {
1006 procs.push_back ((*i)->processor ());
1010 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
1011 XMLNode& state = (*i)->get_state ();
1013 nlist.push_back (&state);
1014 paste_processor_state (nlist, p);
1018 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
1022 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
1023 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
1025 other->delete_dragged_processors (procs);
1031 ProcessorBox::set_width (Width w)
1039 list<ProcessorEntry*> children = processor_display.children ();
1040 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1041 (*i)->set_enum_width (w);
1048 ProcessorBox::build_possible_aux_menu ()
1050 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
1053 /* No aux sends if there are no busses */
1057 using namespace Menu_Helpers;
1058 Menu* menu = manage (new Menu);
1059 MenuList& items = menu->items();
1061 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
1062 if (!_route->internal_send_for (*r) && *r != _route) {
1063 items.push_back (MenuElem ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
1071 ProcessorBox::show_processor_menu (int arg)
1073 if (processor_menu == 0) {
1074 processor_menu = build_processor_menu ();
1075 processor_menu->signal_unmap().connect (sigc::mem_fun (*this, &ProcessorBox::processor_menu_unmapped));
1078 /* Sort out the plugin submenu */
1080 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newplugin"));
1082 if (plugin_menu_item) {
1083 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
1086 /* And the aux submenu */
1088 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newaux"));
1090 if (aux_menu_item) {
1091 Menu* m = build_possible_aux_menu();
1092 if (m && !m->items().empty()) {
1093 aux_menu_item->set_submenu (*m);
1094 aux_menu_item->set_sensitive (true);
1096 /* stupid gtkmm: we need to pass a null reference here */
1097 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
1098 aux_menu_item->set_sensitive (false);
1102 ProcessorEntry* single_selection = 0;
1103 if (processor_display.selection().size() == 1) {
1104 single_selection = processor_display.selection().front();
1107 /* And the controls submenu */
1109 Gtk::MenuItem* controls_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/controls"));
1111 if (controls_menu_item) {
1112 if (single_selection) {
1113 Menu* m = single_selection->build_controls_menu ();
1114 if (m && !m->items().empty()) {
1115 controls_menu_item->set_submenu (*m);
1116 controls_menu_item->set_sensitive (true);
1118 gtk_menu_item_set_submenu (controls_menu_item->gobj(), 0);
1119 controls_menu_item->set_sensitive (false);
1124 Gtk::MenuItem* send_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/send_options"));
1125 if (send_menu_item) {
1126 if (single_selection) {
1127 Menu* m = single_selection->build_send_options_menu ();
1128 if (m && !m->items().empty()) {
1129 send_menu_item->set_submenu (*m);
1130 send_menu_item->set_sensitive (true);
1132 gtk_menu_item_set_submenu (send_menu_item->gobj(), 0);
1133 send_menu_item->set_sensitive (false);
1138 /* Sensitise actions as approprioate */
1140 cut_action->set_sensitive (can_cut());
1141 paste_action->set_sensitive (!_rr_selection.processors.empty());
1143 const bool sensitive = !processor_display.selection().empty();
1144 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
1145 edit_action->set_sensitive (one_processor_can_be_edited ());
1146 edit_generic_action->set_sensitive (one_processor_can_be_edited ());
1148 boost::shared_ptr<PluginInsert> pi;
1149 if (single_selection) {
1150 pi = boost::dynamic_pointer_cast<PluginInsert> (single_selection->processor ());
1153 /* allow editing with an Ardour-generated UI for plugin inserts with editors */
1154 edit_action->set_sensitive (pi && pi->plugin()->has_editor ());
1156 /* disallow rename for multiple selections, for plugin inserts and for the fader */
1157 rename_action->set_sensitive (single_selection && !pi && !boost::dynamic_pointer_cast<Amp> (single_selection->processor ()));
1159 processor_menu->popup (1, arg);
1161 /* Add a placeholder gap to the processor list to indicate where a processor would be
1162 inserted were one chosen from the menu.
1165 processor_display.get_pointer (x, y);
1166 _placement = processor_display.add_placeholder (y);
1168 if (_visible_prefader_processors == 0 && _placement > 0) {
1174 ProcessorBox::enter_notify (GdkEventCrossing*)
1176 _current_processor_box = this;
1181 ProcessorBox::leave_notify (GdkEventCrossing*)
1187 ProcessorBox::processor_operation (ProcessorOperation op)
1189 ProcSelection targets;
1191 get_selected_processors (targets);
1193 if (targets.empty()) {
1196 processor_display.get_pointer (x, y);
1198 pair<ProcessorEntry *, double> const pointer = processor_display.get_child_at_position (y);
1200 if (pointer.first && pointer.first->processor()) {
1201 targets.push_back (pointer.first->processor ());
1206 case ProcessorsSelectAll:
1207 processor_display.select_all ();
1210 case ProcessorsCopy:
1211 copy_processors (targets);
1215 cut_processors (targets);
1218 case ProcessorsPaste:
1219 if (targets.empty()) {
1220 paste_processors ();
1222 paste_processors (targets.front());
1226 case ProcessorsDelete:
1227 delete_processors (targets);
1230 case ProcessorsToggleActive:
1231 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
1232 if ((*i)->active()) {
1233 (*i)->deactivate ();
1249 ProcessorWindowProxy*
1250 ProcessorBox::find_window_proxy (boost::shared_ptr<Processor> processor) const
1252 for (list<ProcessorWindowProxy*>::const_iterator i = _processor_window_info.begin(); i != _processor_window_info.end(); ++i) {
1253 boost::shared_ptr<Processor> p = (*i)->processor().lock();
1255 if (p && p == processor) {
1266 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
1268 boost::shared_ptr<Processor> processor;
1270 processor = child->processor ();
1274 bool selected = processor_display.selected (child);
1276 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
1278 if (_session->engine().connected()) {
1279 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
1281 if (!one_processor_can_be_edited ()) return true;
1283 if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
1284 generic_edit_processor (processor);
1286 edit_processor (processor);
1292 } else if (processor && ev->button == 1 && selected) {
1294 // this is purely informational but necessary for route params UI
1295 ProcessorSelected (processor); // emit
1297 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
1300 _get_plugin_selector()->show_manager ();
1307 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
1309 boost::shared_ptr<Processor> processor;
1311 processor = child->processor ();
1314 if (processor && Keyboard::is_delete_event (ev)) {
1316 Glib::signal_idle().connect (sigc::bind (
1317 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
1318 boost::weak_ptr<Processor>(processor)));
1320 } else if (Keyboard::is_context_menu_event (ev)) {
1322 show_processor_menu (ev->time);
1324 } else if (processor && Keyboard::is_button2_event (ev)
1326 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
1330 /* button2-click with no/appropriate modifiers */
1332 if (processor->active()) {
1333 processor->deactivate ();
1335 processor->activate ();
1343 ProcessorBox::build_processor_menu ()
1345 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/ProcessorMenu") );
1346 processor_menu->set_name ("ArdourContextMenu");
1347 return processor_menu;
1351 ProcessorBox::select_all_processors ()
1353 processor_display.select_all ();
1357 ProcessorBox::deselect_all_processors ()
1359 processor_display.select_none ();
1363 ProcessorBox::choose_plugin ()
1365 _get_plugin_selector()->set_interested_object (*this);
1368 /** @return true if an error occurred, otherwise false */
1370 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
1372 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
1374 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
1376 Route::ProcessorStreams err_streams;
1378 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
1379 weird_plugin_dialog (**p, err_streams);
1381 // XXX SHAREDPTR delete plugin here .. do we even need to care?
1384 if (Profile->get_sae()) {
1385 processor->activate ();
1394 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
1396 ArdourDialog dialog (_("Plugin Incompatibility"));
1399 string text = string_compose(_("You attempted to add the plugin \"%1\" in slot %2.\n"),
1400 p.name(), streams.index);
1402 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
1403 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
1405 text += _("\nThis plugin has:\n");
1407 uint32_t const n = p.get_info()->n_inputs.n_midi ();
1408 text += string_compose (ngettext ("\t%1 MIDI input\n", "\t%1 MIDI inputs\n", n), n);
1411 uint32_t const n = p.get_info()->n_inputs.n_audio ();
1412 text += string_compose (ngettext ("\t%1 audio input\n", "\t%1 audio inputs\n", n), n);
1415 text += _("\nbut at the insertion point, there are:\n");
1417 uint32_t const n = streams.count.n_midi ();
1418 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
1421 uint32_t const n = streams.count.n_audio ();
1422 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
1425 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
1426 label.set_text(text);
1428 dialog.get_vbox()->pack_start (label);
1429 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1431 dialog.set_name (X_("PluginIODialog"));
1432 dialog.set_modal (true);
1439 ProcessorBox::choose_insert ()
1441 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->pannable(), _route->mute_master()));
1442 _route->add_processor_by_index (processor, _placement);
1445 /* Caller must not hold process lock */
1447 ProcessorBox::choose_send ()
1449 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
1450 boost::shared_ptr<Send> send (new Send (*_session, sendpan, _route->mute_master()));
1452 /* make an educated guess at the initial number of outputs for the send */
1453 ChanCount outs = (_session->master_out())
1454 ? _session->master_out()->n_outputs()
1455 : _route->n_outputs();
1457 /* XXX need processor lock on route */
1459 Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock());
1460 send->output()->ensure_io (outs, false, this);
1461 } catch (AudioEngine::PortRegistrationFailure& err) {
1462 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
1466 /* let the user adjust the IO setup before creation.
1468 Note: this dialog is NOT modal - we just leave it to run and it will
1469 return when its Finished signal is emitted - typically when the window
1473 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
1476 /* keep a reference to the send so it doesn't get deleted while
1477 the IOSelectorWindow is doing its stuff
1479 _processor_being_created = send;
1481 ios->selector().Finished.connect (sigc::bind (
1482 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
1483 boost::weak_ptr<Processor>(send), ios));
1488 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1490 boost::shared_ptr<Processor> processor (weak_processor.lock());
1492 /* drop our temporary reference to the new send */
1493 _processor_being_created.reset ();
1500 case IOSelector::Cancelled:
1501 // processor will go away when all shared_ptrs to it vanish
1504 case IOSelector::Accepted:
1505 _route->add_processor_by_index (processor, _placement);
1506 if (Profile->get_sae()) {
1507 processor->activate ();
1512 delete_when_idle (ios);
1516 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1518 boost::shared_ptr<Processor> processor (weak_processor.lock());
1520 /* drop our temporary reference to the new return */
1521 _processor_being_created.reset ();
1528 case IOSelector::Cancelled:
1529 // processor will go away when all shared_ptrs to it vanish
1532 case IOSelector::Accepted:
1533 _route->add_processor_by_index (processor, _placement);
1534 if (Profile->get_sae()) {
1535 processor->activate ();
1540 delete_when_idle (ios);
1544 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
1550 boost::shared_ptr<Route> target = wr.lock();
1556 _session->add_internal_send (target, _placement, _route);
1560 ProcessorBox::route_processors_changed (RouteProcessorChange c)
1562 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
1563 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
1567 redisplay_processors ();
1571 ProcessorBox::redisplay_processors ()
1573 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors);
1576 if (no_processor_redisplay) {
1580 processor_display.clear ();
1582 _visible_prefader_processors = 0;
1585 _route->foreach_processor (sigc::bind (sigc::mem_fun (*this, &ProcessorBox::help_count_visible_prefader_processors),
1586 &_visible_prefader_processors, &fader_seen));
1588 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
1590 for (ProcessorWindowProxies::iterator i = _processor_window_info.begin(); i != _processor_window_info.end(); ++i) {
1591 (*i)->marked = false;
1594 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
1596 /* trim dead wood from the processor window proxy list */
1598 ProcessorWindowProxies::iterator i = _processor_window_info.begin();
1599 while (i != _processor_window_info.end()) {
1600 ProcessorWindowProxies::iterator j = i;
1603 if (!(*i)->valid()) {
1605 WM::Manager::instance().remove (*i);
1607 _processor_window_info.erase (i);
1609 } else if (!(*i)->marked) {
1611 /* this processor is no longer part of this processor
1614 * that could be because it was deleted or it could be
1615 * because the route being displayed in the parent
1618 * The latter only happens with the editor mixer strip.
1621 if (is_editor_mixer_strip()) {
1623 /* editor mixer strip .. DO NOTHING
1625 * note: the processor window stays visible if
1626 * it is already visible
1630 WM::Manager::instance().remove (*i);
1632 _processor_window_info.erase (i);
1639 setup_entry_positions ();
1642 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
1643 * not already have one.
1646 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
1648 boost::shared_ptr<Processor> p = w.lock ();
1653 ProcessorWindowProxies::iterator i = _processor_window_info.begin ();
1654 while (i != _processor_window_info.end()) {
1656 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
1659 /* this processor is already on the list; done */
1660 (*i)->marked = true;
1667 /* not on the list; add it */
1670 if (_parent_strip) {
1671 if (_parent_strip->mixer_owned()) {
1680 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
1681 string_compose ("%1-%2-%3", loc, _route->id(), p->id()),
1685 const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
1688 wp->set_state (*ui_xml);
1693 /* if the processor already has an existing UI,
1694 note that so that we don't recreate it
1697 void* existing_ui = p->get_ui ();
1700 wp->use_window (*(reinterpret_cast<Gtk::Window*>(existing_ui)));
1703 _processor_window_info.push_back (wp);
1704 WM::Manager::instance().register_window (wp);
1708 ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor> p, uint32_t* cnt, bool* amp_seen)
1710 boost::shared_ptr<Processor> processor (p.lock ());
1712 if (processor && processor->display_to_user()) {
1714 if (boost::dynamic_pointer_cast<Amp>(processor)) {
1725 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
1727 boost::shared_ptr<Processor> processor (p.lock ());
1729 if (!processor || !processor->display_to_user()) {
1733 boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
1734 ProcessorEntry* e = 0;
1735 if (plugin_insert) {
1736 e = new PluginInsertProcessorEntry (this, plugin_insert, _width);
1738 e = new ProcessorEntry (this, processor, _width);
1741 /* Set up this entry's state from the GUIObjectState */
1742 XMLNode* proc = entry_gui_object_state (e);
1744 e->set_control_state (proc);
1747 if (boost::dynamic_pointer_cast<Send> (processor)) {
1748 /* Always show send controls */
1749 e->show_all_controls ();
1752 processor_display.add_child (e);
1756 ProcessorBox::reordered ()
1758 compute_processor_sort_keys ();
1759 setup_entry_positions ();
1763 ProcessorBox::setup_entry_positions ()
1765 list<ProcessorEntry*> children = processor_display.children ();
1766 bool pre_fader = true;
1769 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1770 if (boost::dynamic_pointer_cast<Amp>((*i)->processor())) {
1772 (*i)->set_position (ProcessorEntry::Fader, num++);
1775 (*i)->set_position (ProcessorEntry::PreFader, num++);
1777 (*i)->set_position (ProcessorEntry::PostFader, num++);
1784 ProcessorBox::compute_processor_sort_keys ()
1786 list<ProcessorEntry*> children = processor_display.children ();
1787 Route::ProcessorList our_processors;
1789 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1790 if ((*i)->processor()) {
1791 our_processors.push_back ((*i)->processor ());
1795 if (_route->reorder_processors (our_processors)) {
1796 /* Reorder failed, so report this to the user. As far as I can see this must be done
1797 in an idle handler: it seems that the redisplay_processors() that happens below destroys
1798 widgets that were involved in the drag-and-drop on the processor list, which causes problems
1799 when the drag is torn down after this handler function is finished.
1801 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
1806 ProcessorBox::report_failed_reorder ()
1808 /* reorder failed, so redisplay */
1810 redisplay_processors ();
1812 /* now tell them about the problem */
1814 ArdourDialog dialog (_("Plugin Incompatibility"));
1817 label.set_text (_("\
1818 You cannot reorder these plugins/sends/inserts\n\
1819 in that way because the inputs and\n\
1820 outputs will not work correctly."));
1822 dialog.get_vbox()->set_border_width (12);
1823 dialog.get_vbox()->pack_start (label);
1824 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1826 dialog.set_name (X_("PluginIODialog"));
1827 dialog.set_modal (true);
1834 ProcessorBox::rename_processors ()
1836 ProcSelection to_be_renamed;
1838 get_selected_processors (to_be_renamed);
1840 if (to_be_renamed.empty()) {
1844 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
1845 rename_processor (*i);
1850 ProcessorBox::can_cut () const
1852 vector<boost::shared_ptr<Processor> > sel;
1854 get_selected_processors (sel);
1856 /* cut_processors () does not cut inserts */
1858 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
1860 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1861 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1862 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1871 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
1873 if (to_be_removed.empty()) {
1877 XMLNode* node = new XMLNode (X_("cut"));
1878 Route::ProcessorList to_cut;
1880 no_processor_redisplay = true;
1881 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
1882 // Cut only plugins, sends and returns
1883 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1884 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1885 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1887 Window* w = get_processor_ui (*i);
1893 XMLNode& child ((*i)->get_state());
1894 node->add_child_nocopy (child);
1895 to_cut.push_back (*i);
1899 if (_route->remove_processors (to_cut) != 0) {
1901 no_processor_redisplay = false;
1905 _rr_selection.set (node);
1907 no_processor_redisplay = false;
1908 redisplay_processors ();
1912 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
1914 if (to_be_copied.empty()) {
1918 XMLNode* node = new XMLNode (X_("copy"));
1920 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
1921 // Copy only plugins, sends, returns
1922 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1923 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1924 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1925 node->add_child_nocopy ((*i)->get_state());
1929 _rr_selection.set (node);
1933 ProcessorBox::delete_processors (const ProcSelection& targets)
1935 if (targets.empty()) {
1939 no_processor_redisplay = true;
1941 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
1943 Window* w = get_processor_ui (*i);
1949 _route->remove_processor(*i);
1952 no_processor_redisplay = false;
1953 redisplay_processors ();
1957 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
1959 list<boost::shared_ptr<Processor> >::const_iterator x;
1961 no_processor_redisplay = true;
1962 for (x = procs.begin(); x != procs.end(); ++x) {
1964 Window* w = get_processor_ui (*x);
1970 _route->remove_processor(*x);
1973 no_processor_redisplay = false;
1974 redisplay_processors ();
1978 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
1980 boost::shared_ptr<Processor> processor (weak_processor.lock());
1986 /* NOT copied to _mixer.selection() */
1988 no_processor_redisplay = true;
1989 _route->remove_processor (processor);
1990 no_processor_redisplay = false;
1991 redisplay_processors ();
1997 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
1999 ArdourPrompter name_prompter (true);
2001 name_prompter.set_title (_("Rename Processor"));
2002 name_prompter.set_prompt (_("New name:"));
2003 name_prompter.set_initial_text (processor->name());
2004 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
2005 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
2006 name_prompter.show_all ();
2008 switch (name_prompter.run ()) {
2010 case Gtk::RESPONSE_ACCEPT:
2011 name_prompter.get_result (result);
2012 if (result.length()) {
2015 string test = result;
2017 while (tries < 100) {
2018 if (_session->io_name_is_legal (test)) {
2024 test = string_compose ("%1-%2", result, tries);
2028 processor->set_name (result);
2031 ARDOUR_UI::instance()->popup_error
2032 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
2042 ProcessorBox::paste_processors ()
2044 if (_rr_selection.processors.empty()) {
2048 paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
2052 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
2055 if (_rr_selection.processors.empty()) {
2059 paste_processor_state (_rr_selection.processors.get_node().children(), before);
2063 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
2065 XMLNodeConstIterator niter;
2066 list<boost::shared_ptr<Processor> > copies;
2068 if (nlist.empty()) {
2072 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2074 XMLProperty const * type = (*niter)->property ("type");
2075 XMLProperty const * role = (*niter)->property ("role");
2078 boost::shared_ptr<Processor> p;
2080 if (type->value() == "meter" ||
2081 type->value() == "main-outs" ||
2082 type->value() == "amp" ||
2083 type->value() == "intreturn") {
2084 /* do not paste meter, main outs, amp or internal returns */
2087 } else if (type->value() == "intsend") {
2089 /* aux sends are OK, but those used for
2090 * other purposes, are not.
2095 if (role->value() != "Aux") {
2099 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
2100 XMLNode n (**niter);
2101 InternalSend* s = new InternalSend (*_session, sendpan, _route->mute_master(),
2102 boost::shared_ptr<Route>(), Delivery::Aux);
2104 IOProcessor::prepare_for_reset (n, s->name());
2106 if (s->set_state (n, Stateful::loading_state_version)) {
2113 } else if (type->value() == "send") {
2115 boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
2116 XMLNode n (**niter);
2118 Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
2120 IOProcessor::prepare_for_reset (n, s->name());
2122 if (s->set_state (n, Stateful::loading_state_version)) {
2129 } else if (type->value() == "return") {
2131 XMLNode n (**niter);
2132 Return* r = new Return (*_session);
2134 IOProcessor::prepare_for_reset (n, r->name());
2136 if (r->set_state (n, Stateful::loading_state_version)) {
2143 } else if (type->value() == "port") {
2145 XMLNode n (**niter);
2146 PortInsert* pi = new PortInsert (*_session, _route->pannable (), _route->mute_master ());
2148 IOProcessor::prepare_for_reset (n, pi->name());
2150 if (pi->set_state (n, Stateful::loading_state_version)) {
2157 /* XXX its a bit limiting to assume that everything else
2161 p.reset (new PluginInsert (*_session));
2162 p->set_state (**niter, Stateful::current_state_version);
2165 copies.push_back (p);
2169 error << _("plugin insert constructor failed") << endmsg;
2173 if (copies.empty()) {
2177 if (_route->add_processors (copies, p)) {
2180 "Copying the set of processors on the clipboard failed,\n\
2181 probably because the I/O configuration of the plugins\n\
2182 could not match the configuration of this track.");
2183 MessageDialog am (msg);
2189 ProcessorBox::get_selected_processors (ProcSelection& processors) const
2191 const list<ProcessorEntry*> selection = processor_display.selection ();
2192 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
2193 processors.push_back ((*i)->processor ());
2198 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
2200 list<ProcessorEntry*> selection = processor_display.selection ();
2201 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
2202 (this->*method) ((*i)->processor ());
2207 ProcessorBox::all_visible_processors_active (bool state)
2209 _route->all_visible_processors_active (state);
2213 ProcessorBox::ab_plugins ()
2215 _route->ab_plugins (ab_direction);
2216 ab_direction = !ab_direction;
2221 ProcessorBox::clear_processors ()
2224 vector<string> choices;
2226 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
2227 "(this cannot be undone)"), _route->name());
2229 choices.push_back (_("Cancel"));
2230 choices.push_back (_("Yes, remove them all"));
2232 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
2234 if (prompter.run () == 1) {
2235 _route->clear_processors (PreFader);
2236 _route->clear_processors (PostFader);
2241 ProcessorBox::clear_processors (Placement p)
2244 vector<string> choices;
2246 if (p == PreFader) {
2247 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
2248 "(this cannot be undone)"), _route->name());
2250 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
2251 "(this cannot be undone)"), _route->name());
2254 choices.push_back (_("Cancel"));
2255 choices.push_back (_("Yes, remove them all"));
2257 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
2259 if (prompter.run () == 1) {
2260 _route->clear_processors (p);
2265 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
2267 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
2268 if (at && at->freeze_state() == AudioTrack::Frozen) {
2273 boost::dynamic_pointer_cast<Send> (processor) ||
2274 boost::dynamic_pointer_cast<Return> (processor) ||
2275 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
2276 boost::dynamic_pointer_cast<PortInsert> (processor)
2285 ProcessorBox::one_processor_can_be_edited ()
2287 list<ProcessorEntry*> selection = processor_display.selection ();
2288 list<ProcessorEntry*>::iterator i = selection.begin();
2289 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
2293 return (i != selection.end());
2297 ProcessorBox::get_editor_window (boost::shared_ptr<Processor> processor, bool use_custom)
2299 boost::shared_ptr<Send> send;
2300 boost::shared_ptr<InternalSend> internal_send;
2301 boost::shared_ptr<Return> retrn;
2302 boost::shared_ptr<PluginInsert> plugin_insert;
2303 boost::shared_ptr<PortInsert> port_insert;
2306 /* This method may or may not return a Window, but if it does not it
2307 * will modify the parent mixer strip appearance layout to allow
2308 * "editing" the @param processor that was passed in.
2310 * So for example, if the processor is an Amp (gain), the parent strip
2311 * will be forced back into a model where the fader controls the main gain.
2312 * If the processor is a send, then we map the send controls onto the
2315 * Plugins and others will return a window for control.
2318 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
2320 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
2325 if (boost::dynamic_pointer_cast<Amp> (processor)) {
2327 if (_parent_strip) {
2328 _parent_strip->revert_to_default_display ();
2331 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
2333 if (!_session->engine().connected()) {
2337 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
2339 gidget = new SendUIWindow (send, _session);
2342 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
2344 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
2345 /* no GUI for these */
2349 if (!_session->engine().connected()) {
2353 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
2355 ReturnUIWindow *return_ui;
2356 Window* w = get_processor_ui (retrn);
2360 return_ui = new ReturnUIWindow (retrn, _session);
2361 return_ui->set_title (retrn->name ());
2362 set_processor_ui (send, return_ui);
2365 return_ui = dynamic_cast<ReturnUIWindow *> (w);
2370 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
2372 PluginUIWindow *plugin_ui;
2374 /* these are both allowed to be null */
2376 Window* w = get_processor_ui (plugin_insert);
2379 plugin_ui = new PluginUIWindow (plugin_insert, false, use_custom);
2380 plugin_ui->set_title (generate_processor_title (plugin_insert));
2381 set_processor_ui (plugin_insert, plugin_ui);
2384 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
2389 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
2391 if (!_session->engine().connected()) {
2392 MessageDialog msg ( _("Not connected to audio engine - no I/O changes are possible"));
2397 PortInsertWindow *io_selector;
2399 Window* w = get_processor_ui (port_insert);
2402 io_selector = new PortInsertWindow (_session, port_insert);
2403 set_processor_ui (port_insert, io_selector);
2406 io_selector = dynamic_cast<PortInsertWindow *> (w);
2409 gidget = io_selector;
2416 ProcessorBox::get_generic_editor_window (boost::shared_ptr<Processor> processor)
2418 boost::shared_ptr<PluginInsert> plugin_insert
2419 = boost::dynamic_pointer_cast<PluginInsert>(processor);
2421 if (!plugin_insert) {
2425 PluginUIWindow* win = new PluginUIWindow (plugin_insert, true, false);
2426 win->set_title (generate_processor_title (plugin_insert));
2432 ProcessorBox::register_actions ()
2434 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("ProcessorMenu"));
2435 Glib::RefPtr<Action> act;
2438 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin"),
2439 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
2441 act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"),
2442 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
2443 ActionManager::engine_sensitive_actions.push_back (act);
2444 act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New External Send ..."),
2445 sigc::ptr_fun (ProcessorBox::rb_choose_send));
2446 ActionManager::engine_sensitive_actions.push_back (act);
2448 ActionManager::register_action (popup_act_grp, X_("newaux"), _("New Aux Send ..."));
2450 ActionManager::register_action (popup_act_grp, X_("controls"), _("Controls"));
2451 ActionManager::register_action (popup_act_grp, X_("send_options"), _("Send Options"));
2453 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear (all)"),
2454 sigc::ptr_fun (ProcessorBox::rb_clear));
2455 ActionManager::register_action (popup_act_grp, X_("clear_pre"), _("Clear (pre-fader)"),
2456 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
2457 ActionManager::register_action (popup_act_grp, X_("clear_post"), _("Clear (post-fader)"),
2458 sigc::ptr_fun (ProcessorBox::rb_clear_post));
2460 /* standard editing stuff */
2461 cut_action = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"),
2462 sigc::ptr_fun (ProcessorBox::rb_cut));
2463 ActionManager::plugin_selection_sensitive_actions.push_back(cut_action);
2464 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),
2465 sigc::ptr_fun (ProcessorBox::rb_copy));
2466 ActionManager::plugin_selection_sensitive_actions.push_back(act);
2468 act = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"),
2469 sigc::ptr_fun (ProcessorBox::rb_delete));
2470 ActionManager::plugin_selection_sensitive_actions.push_back(act); // ??
2472 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"),
2473 sigc::ptr_fun (ProcessorBox::rb_paste));
2474 rename_action = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"),
2475 sigc::ptr_fun (ProcessorBox::rb_rename));
2476 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"),
2477 sigc::ptr_fun (ProcessorBox::rb_select_all));
2478 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"),
2479 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
2481 /* activation etc. */
2483 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate All"),
2484 sigc::ptr_fun (ProcessorBox::rb_activate_all));
2485 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate All"),
2486 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
2487 ActionManager::register_action (popup_act_grp, X_("ab_plugins"), _("A/B Plugins"),
2488 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
2491 edit_action = ActionManager::register_action (
2492 popup_act_grp, X_("edit"), _("Edit..."),
2493 sigc::ptr_fun (ProcessorBox::rb_edit));
2495 edit_generic_action = ActionManager::register_action (
2496 popup_act_grp, X_("edit-generic"), _("Edit with generic controls..."),
2497 sigc::ptr_fun (ProcessorBox::rb_edit_generic));
2499 ActionManager::add_action_group (popup_act_grp);
2503 ProcessorBox::rb_edit_generic ()
2505 if (_current_processor_box == 0) {
2509 _current_processor_box->for_selected_processors (&ProcessorBox::generic_edit_processor);
2513 ProcessorBox::rb_ab_plugins ()
2515 if (_current_processor_box == 0) {
2519 _current_processor_box->ab_plugins ();
2523 ProcessorBox::rb_choose_plugin ()
2525 if (_current_processor_box == 0) {
2528 _current_processor_box->choose_plugin ();
2532 ProcessorBox::rb_choose_insert ()
2534 if (_current_processor_box == 0) {
2537 _current_processor_box->choose_insert ();
2541 ProcessorBox::rb_choose_send ()
2543 if (_current_processor_box == 0) {
2546 _current_processor_box->choose_send ();
2550 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
2552 if (_current_processor_box == 0) {
2556 _current_processor_box->choose_aux (wr);
2560 ProcessorBox::rb_clear ()
2562 if (_current_processor_box == 0) {
2566 _current_processor_box->clear_processors ();
2571 ProcessorBox::rb_clear_pre ()
2573 if (_current_processor_box == 0) {
2577 _current_processor_box->clear_processors (PreFader);
2582 ProcessorBox::rb_clear_post ()
2584 if (_current_processor_box == 0) {
2588 _current_processor_box->clear_processors (PostFader);
2592 ProcessorBox::rb_cut ()
2594 if (_current_processor_box == 0) {
2598 _current_processor_box->processor_operation (ProcessorsCut);
2602 ProcessorBox::rb_delete ()
2604 if (_current_processor_box == 0) {
2608 _current_processor_box->processor_operation (ProcessorsDelete);
2612 ProcessorBox::rb_copy ()
2614 if (_current_processor_box == 0) {
2617 _current_processor_box->processor_operation (ProcessorsCopy);
2621 ProcessorBox::rb_paste ()
2623 if (_current_processor_box == 0) {
2627 _current_processor_box->processor_operation (ProcessorsPaste);
2631 ProcessorBox::rb_rename ()
2633 if (_current_processor_box == 0) {
2636 _current_processor_box->rename_processors ();
2640 ProcessorBox::rb_select_all ()
2642 if (_current_processor_box == 0) {
2646 _current_processor_box->processor_operation (ProcessorsSelectAll);
2650 ProcessorBox::rb_deselect_all ()
2652 if (_current_processor_box == 0) {
2656 _current_processor_box->deselect_all_processors ();
2660 ProcessorBox::rb_activate_all ()
2662 if (_current_processor_box == 0) {
2666 _current_processor_box->all_visible_processors_active (true);
2670 ProcessorBox::rb_deactivate_all ()
2672 if (_current_processor_box == 0) {
2675 _current_processor_box->all_visible_processors_active (false);
2679 ProcessorBox::rb_edit ()
2681 if (_current_processor_box == 0) {
2685 _current_processor_box->for_selected_processors (&ProcessorBox::edit_processor);
2689 ProcessorBox::edit_aux_send (boost::shared_ptr<Processor> processor)
2691 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
2695 if (_parent_strip) {
2696 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
2697 if (_parent_strip->current_delivery() == send) {
2698 _parent_strip->revert_to_default_display ();
2700 _parent_strip->show_send(send);
2707 ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
2712 if (edit_aux_send (processor)) {
2716 ProcessorWindowProxy* proxy = find_window_proxy (processor);
2719 proxy->set_custom_ui_mode (true);
2725 ProcessorBox::generic_edit_processor (boost::shared_ptr<Processor> processor)
2730 if (edit_aux_send (processor)) {
2734 ProcessorWindowProxy* proxy = find_window_proxy (processor);
2737 proxy->set_custom_ui_mode (false);
2743 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
2745 if (!what_changed.contains (ARDOUR::Properties::name)) {
2749 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
2751 boost::shared_ptr<Processor> processor;
2752 boost::shared_ptr<PluginInsert> plugin_insert;
2753 boost::shared_ptr<Send> send;
2755 list<ProcessorEntry*> children = processor_display.children();
2757 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
2759 processor = (*iter)->processor ();
2765 Window* w = get_processor_ui (processor);
2771 /* rename editor windows for sends and plugins */
2773 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
2774 w->set_title (send->name ());
2775 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
2776 w->set_title (generate_processor_title (plugin_insert));
2782 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
2784 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
2785 string::size_type email_pos;
2787 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
2788 maker = maker.substr (0, email_pos - 1);
2791 if (maker.length() > 32) {
2792 maker = maker.substr (0, 32);
2796 SessionObject* owner = pi->owner();
2799 return string_compose(_("%1: %2 (by %3)"), owner->name(), pi->name(), maker);
2801 return string_compose(_("%1 (by %2)"), pi->name(), maker);
2805 /** @param p Processor.
2806 * @return the UI window for \a p.
2809 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
2811 list<ProcessorWindowProxy*>::const_iterator i = _processor_window_info.begin ();
2812 while (i != _processor_window_info.end()) {
2813 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2815 return (*i)->get ();
2824 /** Make a note of the UI window that a processor is using.
2825 * @param p Processor.
2826 * @param w UI window.
2829 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
2831 list<ProcessorWindowProxy*>::iterator i = _processor_window_info.begin ();
2835 while (i != _processor_window_info.end()) {
2836 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2838 (*i)->use_window (*w);
2845 /* we shouldn't get here, because the ProcessorUIList should always contain
2846 an entry for each processor.
2852 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
2854 boost::shared_ptr<Delivery> d = w.lock ();
2859 list<ProcessorEntry*> children = processor_display.children ();
2860 list<ProcessorEntry*>::const_iterator i = children.begin();
2861 while (i != children.end() && (*i)->processor() != d) {
2865 if (i == children.end()) {
2866 processor_display.set_active (0);
2868 processor_display.set_active (*i);
2872 /** Called to repair the damage of Editor::show_window doing a show_all() */
2874 ProcessorBox::hide_things ()
2876 list<ProcessorEntry*> c = processor_display.children ();
2877 for (list<ProcessorEntry*>::iterator i = c.begin(); i != c.end(); ++i) {
2878 (*i)->hide_things ();
2883 ProcessorBox::processor_menu_unmapped ()
2885 processor_display.remove_placeholder ();
2889 ProcessorBox::entry_gui_object_state (ProcessorEntry* entry)
2891 if (!_parent_strip) {
2895 GUIObjectState& st = _parent_strip->gui_object_state ();
2897 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
2899 return st.get_or_add_node (strip, entry->state_id());
2903 ProcessorBox::update_gui_object_state (ProcessorEntry* entry)
2905 XMLNode* proc = entry_gui_object_state (entry);
2910 /* XXX: this is a bit inefficient; we just remove all child nodes and re-add them */
2911 proc->remove_nodes_and_delete (X_("Object"));
2912 entry->add_control_state (proc);
2916 ProcessorBox::is_editor_mixer_strip() const
2918 return _parent_strip && !_parent_strip->mixer_owned();
2921 ProcessorWindowProxy::ProcessorWindowProxy (string const & name, ProcessorBox* box, boost::weak_ptr<Processor> processor)
2922 : WM::ProxyBase (name, string())
2924 , _processor_box (box)
2925 , _processor (processor)
2927 , want_custom (false)
2930 boost::shared_ptr<Processor> p = _processor.lock ();
2934 p->DropReferences.connect (going_away_connection, MISSING_INVALIDATOR, boost::bind (&ProcessorWindowProxy::processor_going_away, this), gui_context());
2937 ProcessorWindowProxy::~ProcessorWindowProxy()
2939 /* processor window proxies do not own the windows they create with
2940 * ::get(), so set _window to null before the normal WindowProxy method
2947 ProcessorWindowProxy::processor_going_away ()
2952 /* should be no real reason to do this, since the object that would
2953 send DropReferences is about to be deleted, but lets do it anyway.
2955 going_away_connection.disconnect();
2958 ARDOUR::SessionHandlePtr*
2959 ProcessorWindowProxy::session_handle()
2966 ProcessorWindowProxy::valid() const
2972 ProcessorWindowProxy::get_state () const
2975 node = &ProxyBase::get_state();
2976 node->add_property (X_("custom-ui"), is_custom? X_("yes") : X_("no"));
2981 ProcessorWindowProxy::set_state (const XMLNode& node)
2983 XMLNodeList children = node.children ();
2984 XMLNodeList::const_iterator i = children.begin ();
2985 while (i != children.end()) {
2986 XMLProperty* prop = (*i)->property (X_("name"));
2987 if ((*i)->name() == X_("Window") && prop && prop->value() == _name) {
2993 if (i != children.end()) {
2995 if ((prop = (*i)->property (X_("custom-ui"))) != 0) {
2996 want_custom = PBD::string_is_affirmative (prop->value ());
3000 ProxyBase::set_state(node);
3004 ProcessorWindowProxy::get (bool create)
3006 boost::shared_ptr<Processor> p = _processor.lock ();
3011 if (_window && (is_custom != want_custom)) {
3012 /* drop existing window - wrong type */
3021 is_custom = want_custom;
3022 _window = _processor_box->get_editor_window (p, is_custom);
3033 ProcessorWindowProxy::toggle ()
3035 if (_window && (is_custom != want_custom)) {
3036 /* drop existing window - wrong type */
3039 is_custom = want_custom;
3041 WM::ProxyBase::toggle ();