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>
42 #include "ardour/amp.h"
43 #include "ardour/audio_track.h"
44 #include "ardour/audioengine.h"
45 #include "ardour/internal_return.h"
46 #include "ardour/internal_send.h"
47 #include "ardour/plugin_insert.h"
48 #include "ardour/port_insert.h"
49 #include "ardour/profile.h"
50 #include "ardour/return.h"
51 #include "ardour/route.h"
52 #include "ardour/send.h"
53 #include "ardour/session.h"
54 #include "ardour/types.h"
57 #include "ardour_dialog.h"
58 #include "ardour_ui.h"
59 #include "gui_thread.h"
60 #include "io_selector.h"
63 #include "mixer_strip.h"
64 #include "plugin_selector.h"
65 #include "plugin_ui.h"
66 #include "port_insert_ui.h"
67 #include "processor_box.h"
68 #include "public_editor.h"
69 #include "return_ui.h"
70 #include "route_processor_selection.h"
76 #ifdef AUDIOUNIT_SUPPORT
81 using namespace ARDOUR;
85 using namespace Gtkmm2ext;
87 ProcessorBox* ProcessorBox::_current_processor_box = 0;
88 RefPtr<Action> ProcessorBox::paste_action;
89 RefPtr<Action> ProcessorBox::cut_action;
90 RefPtr<Action> ProcessorBox::rename_action;
91 RefPtr<Action> ProcessorBox::edit_action;
92 RefPtr<Action> ProcessorBox::edit_generic_action;
94 ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processor> p, Width w)
95 : _button (ArdourButton::led_default_elements)
96 , _position (PreFader)
100 , _visual_state (Gtk::STATE_NORMAL)
104 _button.set_diameter (3);
105 _button.set_distinct_led_click (true);
106 _button.set_led_left (true);
107 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &ProcessorEntry::led_clicked));
108 _button.set_text (name (_width));
112 _vbox.pack_start (_button, true, true);
114 _button.set_active (_processor->active());
117 _processor->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_active_changed, this), gui_context());
118 _processor->PropertyChanged.connect (name_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_property_changed, this, _1), gui_context());
120 set<Evoral::Parameter> p = _processor->what_can_be_automated ();
121 for (set<Evoral::Parameter>::iterator i = p.begin(); i != p.end(); ++i) {
123 Control* c = new Control (_processor->automation_control (*i), _processor->describe_parameter (*i));
125 _controls.push_back (c);
127 if (boost::dynamic_pointer_cast<Amp> (_processor) == 0) {
128 /* Add non-Amp controls to the processor box */
129 _vbox.pack_start (c->box);
132 if (boost::dynamic_pointer_cast<Send> (_processor)) {
133 /* Don't label send faders */
141 _vbox.set_size_request (-1, _button.size_request().height);
145 ProcessorEntry::~ProcessorEntry ()
147 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
153 ProcessorEntry::action_widget ()
159 ProcessorEntry::widget ()
165 ProcessorEntry::drag_text () const
171 ProcessorEntry::set_position (Position p)
178 ProcessorEntry::set_visual_state (Gtkmm2ext::VisualState s, bool yn)
181 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() | s));
183 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() & ~s));
188 ProcessorEntry::setup_visuals ()
192 _button.set_name ("processor prefader");
196 _button.set_name ("processor fader");
200 _button.set_name ("processor postfader");
206 boost::shared_ptr<Processor>
207 ProcessorEntry::processor () const
213 ProcessorEntry::set_enum_width (Width w)
219 ProcessorEntry::led_clicked()
222 if (_button.get_active ()) {
223 _processor->deactivate ();
225 _processor->activate ();
231 ProcessorEntry::processor_active_changed ()
234 _button.set_active (_processor->active());
239 ProcessorEntry::processor_property_changed (const PropertyChange& what_changed)
241 if (what_changed.contains (ARDOUR::Properties::name)) {
242 _button.set_text (name (_width));
248 ProcessorEntry::setup_tooltip ()
250 ARDOUR_UI::instance()->set_tip (_button, name (Wide));
254 ProcessorEntry::name (Width w) const
256 boost::shared_ptr<Send> send;
263 if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
264 !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
268 /* grab the send name out of its overall name */
270 string::size_type lbracket, rbracket;
271 lbracket = send->name().find ('[');
272 rbracket = send->name().find (']');
276 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
279 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
287 name_display += _processor->display_name();
290 name_display += PBD::short_version (_processor->display_name(), 5);
300 ProcessorEntry::show_all_controls ()
302 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
303 (*i)->set_visible (true);
306 _parent->update_gui_object_state (this);
310 ProcessorEntry::hide_all_controls ()
312 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
313 (*i)->set_visible (false);
316 _parent->update_gui_object_state (this);
320 ProcessorEntry::add_control_state (XMLNode* node) const
322 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
323 (*i)->add_state (node);
328 ProcessorEntry::set_control_state (XMLNode const * node)
330 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
331 (*i)->set_state (node);
336 ProcessorEntry::state_id () const
338 return string_compose ("processor %1", _processor->id().to_s());
342 ProcessorEntry::hide_things ()
344 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
345 (*i)->hide_things ();
351 ProcessorEntry::build_controls_menu ()
353 using namespace Menu_Helpers;
354 Menu* menu = manage (new Menu);
355 MenuList& items = menu->items ();
358 MenuElem (_("Show All Controls"), sigc::mem_fun (*this, &ProcessorEntry::show_all_controls))
362 MenuElem (_("Hide All Controls"), sigc::mem_fun (*this, &ProcessorEntry::hide_all_controls))
365 if (!_controls.empty ()) {
366 items.push_back (SeparatorElem ());
369 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
370 items.push_back (CheckMenuElem ((*i)->name ()));
371 CheckMenuItem* c = dynamic_cast<CheckMenuItem*> (&items.back ());
372 c->set_active ((*i)->visible ());
373 c->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &ProcessorEntry::toggle_control_visibility), *i));
380 ProcessorEntry::toggle_control_visibility (Control* c)
382 c->set_visible (!c->visible ());
383 _parent->update_gui_object_state (this);
386 ProcessorEntry::Control::Control (boost::shared_ptr<AutomationControl> c, string const & n)
388 , _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1)
389 , _slider (&_adjustment, 0, 13, false)
390 , _slider_persistant_tooltip (&_slider)
391 , _button (ArdourButton::Element (ArdourButton::Text | ArdourButton::Indicator))
392 , _ignore_ui_adjustment (false)
396 _slider.set_controllable (c);
399 _button.set_text (_name);
400 _button.set_led_left (true);
401 _button.set_name ("processor control button");
402 box.pack_start (_button);
405 _button.signal_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked));
406 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked));
407 c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
411 _slider.set_name ("PluginSlider");
412 _slider.set_text (_name);
414 box.pack_start (_slider);
417 double const lo = c->internal_to_interface (c->lower ());
418 double const up = c->internal_to_interface (c->upper ());
420 _adjustment.set_lower (lo);
421 _adjustment.set_upper (up);
422 _adjustment.set_step_increment ((up - lo) / 100);
423 _adjustment.set_page_increment ((up - lo) / 10);
424 _slider.set_default_value (c->internal_to_interface (c->normal ()));
426 _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &Control::slider_adjusted));
427 c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
430 ARDOUR_UI::RapidScreenUpdate.connect (sigc::mem_fun (*this, &Control::control_changed));
435 /* We're providing our own PersistentTooltip */
436 set_no_tooltip_whatsoever (_slider);
440 ProcessorEntry::Control::set_tooltip ()
442 boost::shared_ptr<AutomationControl> c = _control.lock ();
451 s << (c->get_value() > 0.5 ? _("on") : _("off"));
453 s << setprecision(2) << fixed;
454 s << c->internal_to_user (c->get_value ());
457 string sm = Glib::Markup::escape_text (s.str());
459 ARDOUR_UI::instance()->set_tip (_label, sm);
460 _slider_persistant_tooltip.set_tip (sm);
461 ARDOUR_UI::instance()->set_tip (_button, sm);
465 ProcessorEntry::Control::slider_adjusted ()
467 if (_ignore_ui_adjustment) {
471 boost::shared_ptr<AutomationControl> c = _control.lock ();
477 c->set_value (c->interface_to_internal (_adjustment.get_value ()));
482 ProcessorEntry::Control::button_clicked ()
484 boost::shared_ptr<AutomationControl> c = _control.lock ();
490 bool const n = _button.get_active ();
492 c->set_value (n ? 0 : 1);
493 _button.set_active (!n);
497 ProcessorEntry::Control::control_changed ()
499 boost::shared_ptr<AutomationControl> c = _control.lock ();
504 _ignore_ui_adjustment = true;
508 _button.set_active (c->get_value() > 0.5);
512 _adjustment.set_value (c->internal_to_interface (c->get_value ()));
516 s.setf (ios::fixed, ios::floatfield);
517 s << c->internal_to_user (c->get_value ());
520 _ignore_ui_adjustment = false;
524 ProcessorEntry::Control::add_state (XMLNode* node) const
526 XMLNode* c = new XMLNode (X_("Object"));
527 c->add_property (X_("id"), state_id ());
528 c->add_property (X_("visible"), _visible);
529 node->add_child_nocopy (*c);
533 ProcessorEntry::Control::set_state (XMLNode const * node)
535 XMLNode* n = GUIObjectState::get_node (node, state_id ());
537 XMLProperty* p = n->property (X_("visible"));
538 set_visible (p && string_is_affirmative (p->value ()));
545 ProcessorEntry::Control::set_visible (bool v)
556 /** Called when the Editor might have re-shown things that
560 ProcessorEntry::Control::hide_things ()
568 ProcessorEntry::Control::hide_label ()
574 ProcessorEntry::Control::state_id () const
576 boost::shared_ptr<AutomationControl> c = _control.lock ();
579 return string_compose (X_("control %1"), c->id().to_s ());
582 BlankProcessorEntry::BlankProcessorEntry (ProcessorBox* b, Width w)
583 : ProcessorEntry (b, boost::shared_ptr<Processor>(), w)
587 PluginInsertProcessorEntry::PluginInsertProcessorEntry (ProcessorBox* b, boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
588 : ProcessorEntry (b, p, w)
591 p->SplittingChanged.connect (
592 _splitting_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::plugin_insert_splitting_changed, this), gui_context()
595 _splitting_icon.set_size_request (-1, 12);
597 _vbox.pack_start (_splitting_icon);
598 _vbox.reorder_child (_splitting_icon, 0);
600 plugin_insert_splitting_changed ();
604 PluginInsertProcessorEntry::plugin_insert_splitting_changed ()
606 if (_plugin_insert->splitting ()) {
607 _splitting_icon.show ();
609 _splitting_icon.hide ();
614 PluginInsertProcessorEntry::hide_things ()
616 ProcessorEntry::hide_things ();
617 plugin_insert_splitting_changed ();
621 PluginInsertProcessorEntry::setup_visuals ()
625 _splitting_icon.set_name ("ProcessorPreFader");
629 _splitting_icon.set_name ("ProcessorFader");
633 _splitting_icon.set_name ("ProcessorPostFader");
637 ProcessorEntry::setup_visuals ();
641 PluginInsertProcessorEntry::SplittingIcon::on_expose_event (GdkEventExpose* ev)
643 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
645 cairo_set_line_width (cr, 1);
647 double const width = ev->area.width;
648 double const height = ev->area.height;
650 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
651 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
653 cairo_rectangle (cr, 0, 0, width, height);
656 Gdk::Color const fg = get_style()->get_fg (STATE_NORMAL);
657 cairo_set_source_rgb (cr, fg.get_red_p (), fg.get_green_p (), fg.get_blue_p ());
659 cairo_move_to (cr, width * 0.3, height);
660 cairo_line_to (cr, width * 0.3, height * 0.5);
661 cairo_line_to (cr, width * 0.7, height * 0.5);
662 cairo_line_to (cr, width * 0.7, height);
663 cairo_move_to (cr, width * 0.5, height * 0.5);
664 cairo_line_to (cr, width * 0.5, 0);
670 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
671 RouteProcessorSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
672 : _parent_strip (parent)
673 , _owner_is_mixer (owner_is_mixer)
674 , ab_direction (true)
675 , _get_plugin_selector (get_plugin_selector)
677 , _visible_prefader_processors (0)
678 , _rr_selection(rsel)
679 , _redisplay_pending (false)
686 no_processor_redisplay = false;
688 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
689 processor_scroller.add (processor_display);
690 pack_start (processor_scroller, true, true);
692 processor_display.set_flags (CAN_FOCUS);
693 processor_display.set_name ("ProcessorList");
694 processor_display.set_data ("processorbox", this);
695 processor_display.set_size_request (48, -1);
696 processor_display.set_spacing (2);
698 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
699 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
701 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
702 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
704 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
705 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
707 processor_scroller.show ();
708 processor_display.show ();
711 parent->DeliveryChanged.connect (
712 _mixer_strip_connections, invalidator (*this), boost::bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
716 ARDOUR_UI::instance()->set_tip (processor_display, _("Right-click to add/remove/edit\nplugins,inserts,sends and more"));
719 ProcessorBox::~ProcessorBox ()
721 /* it may appear as if we should delete processor_menu but that is a
722 * pointer to a widget owned by the UI Manager, and has potentially
723 * be returned to many other ProcessorBoxes. GTK doesn't really make
724 * clear the ownership of this widget, which is a menu and thus is
725 * never packed into any container other than an implict GtkWindow.
727 * For now, until or if we ever get clarification over the ownership
728 * story just let it continue to exist. At worst, its a small memory leak.
733 ProcessorBox::set_route (boost::shared_ptr<Route> r)
739 _route_connections.drop_connections();
741 /* new route: any existing block on processor redisplay must be meaningless */
742 no_processor_redisplay = false;
745 _route->processors_changed.connect (
746 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
749 _route->DropReferences.connect (
750 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
753 _route->PropertyChanged.connect (
754 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
757 redisplay_processors ();
761 ProcessorBox::route_going_away ()
763 /* don't keep updating display as processors are deleted */
764 no_processor_redisplay = true;
769 ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
771 boost::shared_ptr<Processor> p;
773 p = position->processor ();
775 /* dropped on the blank entry (which will be before the
776 fader), so use the first non-blank child as our
777 `dropped on' processor */
778 list<ProcessorEntry*> c = processor_display.children ();
779 list<ProcessorEntry*>::iterator i = c.begin ();
780 while (dynamic_cast<BlankProcessorEntry*> (*i)) {
781 assert (i != c.end ());
785 assert (i != c.end ());
786 p = (*i)->processor ();
791 list<ProcessorEntry*> children = source->selection ();
792 list<boost::shared_ptr<Processor> > procs;
793 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
794 if ((*i)->processor ()) {
795 procs.push_back ((*i)->processor ());
799 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
800 XMLNode& state = (*i)->get_state ();
802 nlist.push_back (&state);
803 paste_processor_state (nlist, p);
807 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
811 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
812 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
814 other->delete_dragged_processors (procs);
820 ProcessorBox::set_width (Width w)
828 list<ProcessorEntry*> children = processor_display.children ();
829 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
830 (*i)->set_enum_width (w);
837 ProcessorBox::build_possible_aux_menu ()
839 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
842 /* No aux sends if there are no busses */
846 using namespace Menu_Helpers;
847 Menu* menu = manage (new Menu);
848 MenuList& items = menu->items();
850 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
851 if (!_route->internal_send_for (*r) && *r != _route) {
852 items.push_back (MenuElem ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
860 ProcessorBox::show_processor_menu (int arg)
862 if (processor_menu == 0) {
863 processor_menu = build_processor_menu ();
864 processor_menu->signal_unmap().connect (sigc::mem_fun (*this, &ProcessorBox::processor_menu_unmapped));
867 /* Sort out the plugin submenu */
869 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newplugin"));
871 if (plugin_menu_item) {
872 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
875 /* And the aux submenu */
877 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newaux"));
880 Menu* m = build_possible_aux_menu();
881 if (m && !m->items().empty()) {
882 aux_menu_item->set_submenu (*m);
883 aux_menu_item->set_sensitive (true);
885 /* stupid gtkmm: we need to pass a null reference here */
886 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
887 aux_menu_item->set_sensitive (false);
891 ProcessorEntry* single_selection = 0;
892 if (processor_display.selection().size() == 1) {
893 single_selection = processor_display.selection().front();
896 /* And the controls submenu */
898 Gtk::MenuItem* controls_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/controls"));
900 if (controls_menu_item) {
901 if (single_selection) {
902 Menu* m = single_selection->build_controls_menu ();
903 if (m && !m->items().empty()) {
904 controls_menu_item->set_submenu (*m);
905 controls_menu_item->set_sensitive (true);
907 gtk_menu_item_set_submenu (controls_menu_item->gobj(), 0);
908 controls_menu_item->set_sensitive (false);
913 /* Sensitise actions as approprioate */
915 cut_action->set_sensitive (can_cut());
916 paste_action->set_sensitive (!_rr_selection.processors.empty());
918 const bool sensitive = !processor_display.selection().empty();
919 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
920 edit_action->set_sensitive (one_processor_can_be_edited ());
922 boost::shared_ptr<PluginInsert> pi;
923 if (single_selection) {
924 pi = boost::dynamic_pointer_cast<PluginInsert> (single_selection->processor ());
927 /* allow editing with an Ardour-generated UI for plugin inserts with editors */
928 edit_generic_action->set_sensitive (pi && pi->plugin()->has_editor ());
930 /* disallow rename for multiple selections, for plugin inserts and for the fader */
931 rename_action->set_sensitive (single_selection && !pi && !boost::dynamic_pointer_cast<Amp> (single_selection->processor ()));
933 processor_menu->popup (1, arg);
935 /* Add a placeholder gap to the processor list to indicate where a processor would be
936 inserted were one chosen from the menu.
939 processor_display.get_pointer (x, y);
940 _placement = processor_display.add_placeholder (y);
942 if (_visible_prefader_processors == 0 && _placement > 0) {
948 ProcessorBox::enter_notify (GdkEventCrossing*)
950 _current_processor_box = this;
955 ProcessorBox::leave_notify (GdkEventCrossing*)
961 ProcessorBox::processor_operation (ProcessorOperation op)
963 ProcSelection targets;
965 get_selected_processors (targets);
967 if (targets.empty()) {
970 processor_display.get_pointer (x, y);
972 pair<ProcessorEntry *, double> const pointer = processor_display.get_child_at_position (y);
974 if (pointer.first && pointer.first->processor()) {
975 targets.push_back (pointer.first->processor ());
980 case ProcessorsSelectAll:
981 processor_display.select_all ();
985 copy_processors (targets);
989 cut_processors (targets);
992 case ProcessorsPaste:
993 if (targets.empty()) {
996 paste_processors (targets.front());
1000 case ProcessorsDelete:
1001 delete_processors (targets);
1004 case ProcessorsToggleActive:
1005 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
1006 if ((*i)->active()) {
1007 (*i)->deactivate ();
1023 ProcessorWindowProxy*
1024 ProcessorBox::find_window_proxy (boost::shared_ptr<Processor> processor) const
1026 for (list<ProcessorWindowProxy*>::const_iterator i = _processor_window_info.begin(); i != _processor_window_info.end(); ++i) {
1027 boost::shared_ptr<Processor> p = (*i)->processor().lock();
1029 if (p && p == processor) {
1040 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
1042 boost::shared_ptr<Processor> processor;
1044 processor = child->processor ();
1048 bool selected = processor_display.selected (child);
1050 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
1052 if (_session->engine().connected()) {
1054 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
1056 if (Config->get_use_plugin_own_gui ()) {
1057 edit_processor (processor);
1059 generic_edit_processor (processor);
1065 } else if (processor && ev->button == 1 && selected) {
1067 // this is purely informational but necessary for route params UI
1068 ProcessorSelected (processor); // emit
1070 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
1073 _get_plugin_selector()->show_manager ();
1080 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
1082 boost::shared_ptr<Processor> processor;
1084 processor = child->processor ();
1087 if (processor && Keyboard::is_delete_event (ev)) {
1089 Glib::signal_idle().connect (sigc::bind (
1090 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
1091 boost::weak_ptr<Processor>(processor)));
1093 } else if (Keyboard::is_context_menu_event (ev)) {
1095 show_processor_menu (ev->time);
1097 } else if (processor && Keyboard::is_button2_event (ev)
1099 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
1103 /* button2-click with no/appropriate modifiers */
1105 if (processor->active()) {
1106 processor->deactivate ();
1108 processor->activate ();
1116 ProcessorBox::build_processor_menu ()
1118 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/ProcessorMenu") );
1119 processor_menu->set_name ("ArdourContextMenu");
1120 return processor_menu;
1124 ProcessorBox::select_all_processors ()
1126 processor_display.select_all ();
1130 ProcessorBox::deselect_all_processors ()
1132 processor_display.select_none ();
1136 ProcessorBox::choose_plugin ()
1138 _get_plugin_selector()->set_interested_object (*this);
1141 /** @return true if an error occurred, otherwise false */
1143 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
1145 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
1147 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
1149 Route::ProcessorStreams err_streams;
1151 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
1152 weird_plugin_dialog (**p, err_streams);
1154 // XXX SHAREDPTR delete plugin here .. do we even need to care?
1157 if (Profile->get_sae()) {
1158 processor->activate ();
1167 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
1169 ArdourDialog dialog (_("Plugin Incompatibility"));
1172 string text = string_compose(_("You attempted to add the plugin \"%1\" in slot %2.\n"),
1173 p.name(), streams.index);
1175 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
1176 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
1178 text += _("\nThis plugin has:\n");
1180 uint32_t const n = p.get_info()->n_inputs.n_midi ();
1181 text += string_compose (ngettext ("\t%1 MIDI input\n", "\t%1 MIDI inputs\n", n), n);
1184 uint32_t const n = p.get_info()->n_inputs.n_audio ();
1185 text += string_compose (ngettext ("\t%1 audio input\n", "\t%1 audio inputs\n", n), n);
1188 text += _("\nbut at the insertion point, there are:\n");
1190 uint32_t const n = streams.count.n_midi ();
1191 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
1194 uint32_t const n = streams.count.n_audio ();
1195 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
1198 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
1199 label.set_text(text);
1201 dialog.get_vbox()->pack_start (label);
1202 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1204 dialog.set_name (X_("PluginIODialog"));
1205 dialog.set_modal (true);
1212 ProcessorBox::choose_insert ()
1214 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->pannable(), _route->mute_master()));
1215 _route->add_processor_by_index (processor, _placement);
1218 /* Caller must not hold process lock */
1220 ProcessorBox::choose_send ()
1222 boost::shared_ptr<Send> send (new Send (*_session, _route->pannable(), _route->mute_master()));
1224 /* make an educated guess at the initial number of outputs for the send */
1225 ChanCount outs = (_session->master_out())
1226 ? _session->master_out()->n_outputs()
1227 : _route->n_outputs();
1229 /* XXX need processor lock on route */
1231 Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock());
1232 send->output()->ensure_io (outs, false, this);
1233 } catch (AudioEngine::PortRegistrationFailure& err) {
1234 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
1238 /* let the user adjust the IO setup before creation.
1240 Note: this dialog is NOT modal - we just leave it to run and it will
1241 return when its Finished signal is emitted - typically when the window
1245 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
1248 /* keep a reference to the send so it doesn't get deleted while
1249 the IOSelectorWindow is doing its stuff
1251 _processor_being_created = send;
1253 ios->selector().Finished.connect (sigc::bind (
1254 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
1255 boost::weak_ptr<Processor>(send), ios));
1260 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1262 boost::shared_ptr<Processor> processor (weak_processor.lock());
1264 /* drop our temporary reference to the new send */
1265 _processor_being_created.reset ();
1272 case IOSelector::Cancelled:
1273 // processor will go away when all shared_ptrs to it vanish
1276 case IOSelector::Accepted:
1277 _route->add_processor_by_index (processor, _placement);
1278 if (Profile->get_sae()) {
1279 processor->activate ();
1284 delete_when_idle (ios);
1288 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1290 boost::shared_ptr<Processor> processor (weak_processor.lock());
1292 /* drop our temporary reference to the new return */
1293 _processor_being_created.reset ();
1300 case IOSelector::Cancelled:
1301 // processor will go away when all shared_ptrs to it vanish
1304 case IOSelector::Accepted:
1305 _route->add_processor_by_index (processor, _placement);
1306 if (Profile->get_sae()) {
1307 processor->activate ();
1312 delete_when_idle (ios);
1316 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
1322 boost::shared_ptr<Route> target = wr.lock();
1328 _session->add_internal_send (target, _placement, _route);
1332 ProcessorBox::route_processors_changed (RouteProcessorChange c)
1334 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
1335 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
1339 redisplay_processors ();
1343 ProcessorBox::redisplay_processors ()
1345 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors);
1348 if (no_processor_redisplay) {
1352 processor_display.clear ();
1354 _visible_prefader_processors = 0;
1357 _route->foreach_processor (sigc::bind (sigc::mem_fun (*this, &ProcessorBox::help_count_visible_prefader_processors),
1358 &_visible_prefader_processors, &fader_seen));
1360 if (_visible_prefader_processors == 0) { // fader only
1361 BlankProcessorEntry* bpe = new BlankProcessorEntry (this, _width);
1362 processor_display.add_child (bpe);
1365 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
1367 for (list<ProcessorWindowProxy*>::iterator i = _processor_window_info.begin(); i != _processor_window_info.end(); ++i) {
1368 (*i)->marked = false;
1371 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
1373 /* trim dead wood from the processor window proxy list */
1375 list<ProcessorWindowProxy*>::iterator i = _processor_window_info.begin();
1376 while (i != _processor_window_info.end()) {
1377 list<ProcessorWindowProxy*>::iterator j = i;
1380 if (!(*i)->marked) {
1381 WindowManager::instance().remove (*i);
1383 _processor_window_info.erase (i);
1389 setup_entry_positions ();
1392 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
1393 * not already have one.
1396 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
1398 boost::shared_ptr<Processor> p = w.lock ();
1403 list<ProcessorWindowProxy*>::iterator i = _processor_window_info.begin ();
1404 while (i != _processor_window_info.end()) {
1406 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
1409 /* this processor is already on the list; done */
1410 (*i)->marked = true;
1417 /* not on the list; add it */
1420 if (_parent_strip) {
1421 if (_parent_strip->mixer_owned()) {
1430 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
1431 string_compose ("%1-%2-%3", loc, _route->id(), p->id()),
1435 const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
1438 wp->set_state (*ui_xml);
1443 /* if the processor already has an existing UI,
1444 note that so that we don't recreate it
1447 void* existing_ui = p->get_ui ();
1450 wp->use_window (*(reinterpret_cast<Gtk::Window*>(existing_ui)));
1453 _processor_window_info.push_back (wp);
1454 WindowManager::instance().register_window (wp);
1458 ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor> p, uint32_t* cnt, bool* amp_seen)
1460 boost::shared_ptr<Processor> processor (p.lock ());
1462 if (processor && processor->display_to_user()) {
1464 if (boost::dynamic_pointer_cast<Amp>(processor)) {
1475 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
1477 boost::shared_ptr<Processor> processor (p.lock ());
1479 if (!processor || !processor->display_to_user()) {
1483 boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
1484 ProcessorEntry* e = 0;
1485 if (plugin_insert) {
1486 e = new PluginInsertProcessorEntry (this, plugin_insert, _width);
1488 e = new ProcessorEntry (this, processor, _width);
1491 /* Set up this entry's state from the GUIObjectState */
1492 XMLNode* proc = entry_gui_object_state (e);
1494 e->set_control_state (proc);
1497 if (boost::dynamic_pointer_cast<Send> (processor)) {
1498 /* Always show send controls */
1499 e->show_all_controls ();
1502 processor_display.add_child (e);
1506 ProcessorBox::reordered ()
1508 compute_processor_sort_keys ();
1509 setup_entry_positions ();
1513 ProcessorBox::setup_entry_positions ()
1515 list<ProcessorEntry*> children = processor_display.children ();
1516 bool pre_fader = true;
1518 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1519 if (boost::dynamic_pointer_cast<Amp>((*i)->processor())) {
1521 (*i)->set_position (ProcessorEntry::Fader);
1524 (*i)->set_position (ProcessorEntry::PreFader);
1526 (*i)->set_position (ProcessorEntry::PostFader);
1533 ProcessorBox::compute_processor_sort_keys ()
1535 list<ProcessorEntry*> children = processor_display.children ();
1536 Route::ProcessorList our_processors;
1538 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1539 if ((*i)->processor()) {
1540 our_processors.push_back ((*i)->processor ());
1544 if (_route->reorder_processors (our_processors)) {
1545 /* Reorder failed, so report this to the user. As far as I can see this must be done
1546 in an idle handler: it seems that the redisplay_processors() that happens below destroys
1547 widgets that were involved in the drag-and-drop on the processor list, which causes problems
1548 when the drag is torn down after this handler function is finished.
1550 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
1555 ProcessorBox::report_failed_reorder ()
1557 /* reorder failed, so redisplay */
1559 redisplay_processors ();
1561 /* now tell them about the problem */
1563 ArdourDialog dialog (_("Plugin Incompatibility"));
1566 label.set_text (_("\
1567 You cannot reorder these plugins/sends/inserts\n\
1568 in that way because the inputs and\n\
1569 outputs will not work correctly."));
1571 dialog.get_vbox()->set_border_width (12);
1572 dialog.get_vbox()->pack_start (label);
1573 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1575 dialog.set_name (X_("PluginIODialog"));
1576 dialog.set_modal (true);
1583 ProcessorBox::rename_processors ()
1585 ProcSelection to_be_renamed;
1587 get_selected_processors (to_be_renamed);
1589 if (to_be_renamed.empty()) {
1593 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
1594 rename_processor (*i);
1599 ProcessorBox::can_cut () const
1601 vector<boost::shared_ptr<Processor> > sel;
1603 get_selected_processors (sel);
1605 /* cut_processors () does not cut inserts */
1607 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
1609 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1610 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1611 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1620 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
1622 if (to_be_removed.empty()) {
1626 XMLNode* node = new XMLNode (X_("cut"));
1627 Route::ProcessorList to_cut;
1629 no_processor_redisplay = true;
1630 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
1631 // Cut only plugins, sends and returns
1632 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1633 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1634 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1636 Window* w = get_processor_ui (*i);
1642 XMLNode& child ((*i)->get_state());
1643 node->add_child_nocopy (child);
1644 to_cut.push_back (*i);
1648 if (_route->remove_processors (to_cut) != 0) {
1650 no_processor_redisplay = false;
1654 _rr_selection.set (node);
1656 no_processor_redisplay = false;
1657 redisplay_processors ();
1661 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
1663 if (to_be_copied.empty()) {
1667 XMLNode* node = new XMLNode (X_("copy"));
1669 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
1670 // Copy only plugins, sends, returns
1671 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1672 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1673 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1674 node->add_child_nocopy ((*i)->get_state());
1678 _rr_selection.set (node);
1682 ProcessorBox::delete_processors (const ProcSelection& targets)
1684 if (targets.empty()) {
1688 no_processor_redisplay = true;
1690 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
1692 Window* w = get_processor_ui (*i);
1698 _route->remove_processor(*i);
1701 no_processor_redisplay = false;
1702 redisplay_processors ();
1706 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
1708 list<boost::shared_ptr<Processor> >::const_iterator x;
1710 no_processor_redisplay = true;
1711 for (x = procs.begin(); x != procs.end(); ++x) {
1713 Window* w = get_processor_ui (*x);
1719 _route->remove_processor(*x);
1722 no_processor_redisplay = false;
1723 redisplay_processors ();
1727 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
1729 boost::shared_ptr<Processor> processor (weak_processor.lock());
1735 /* NOT copied to _mixer.selection() */
1737 no_processor_redisplay = true;
1738 _route->remove_processor (processor);
1739 no_processor_redisplay = false;
1740 redisplay_processors ();
1746 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
1748 ArdourPrompter name_prompter (true);
1750 name_prompter.set_title (_("Rename Processor"));
1751 name_prompter.set_prompt (_("New name:"));
1752 name_prompter.set_initial_text (processor->name());
1753 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
1754 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
1755 name_prompter.show_all ();
1757 switch (name_prompter.run ()) {
1759 case Gtk::RESPONSE_ACCEPT:
1760 name_prompter.get_result (result);
1761 if (result.length()) {
1764 string test = result;
1766 while (tries < 100) {
1767 if (_session->io_name_is_legal (test)) {
1773 test = string_compose ("%1-%2", result, tries);
1777 processor->set_name (result);
1780 ARDOUR_UI::instance()->popup_error
1781 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
1791 ProcessorBox::paste_processors ()
1793 if (_rr_selection.processors.empty()) {
1797 paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
1801 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
1804 if (_rr_selection.processors.empty()) {
1808 paste_processor_state (_rr_selection.processors.get_node().children(), before);
1812 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
1814 XMLNodeConstIterator niter;
1815 list<boost::shared_ptr<Processor> > copies;
1817 if (nlist.empty()) {
1821 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1823 XMLProperty const * type = (*niter)->property ("type");
1824 XMLProperty const * role = (*niter)->property ("role");
1827 boost::shared_ptr<Processor> p;
1829 if (type->value() == "meter" ||
1830 type->value() == "main-outs" ||
1831 type->value() == "amp" ||
1832 type->value() == "intreturn") {
1833 /* do not paste meter, main outs, amp or internal returns */
1836 } else if (type->value() == "intsend") {
1838 /* aux sends are OK, but those used for
1839 * other purposes, are not.
1844 if (role->value() != "Aux") {
1848 XMLNode n (**niter);
1849 InternalSend* s = new InternalSend (*_session, _route->pannable(), _route->mute_master(),
1850 boost::shared_ptr<Route>(), Delivery::Aux);
1852 IOProcessor::prepare_for_reset (n, s->name());
1854 if (s->set_state (n, Stateful::loading_state_version)) {
1861 } else if (type->value() == "send") {
1863 XMLNode n (**niter);
1864 Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
1866 IOProcessor::prepare_for_reset (n, s->name());
1868 if (s->set_state (n, Stateful::loading_state_version)) {
1875 } else if (type->value() == "return") {
1877 XMLNode n (**niter);
1878 Return* r = new Return (*_session);
1880 IOProcessor::prepare_for_reset (n, r->name());
1882 if (r->set_state (n, Stateful::loading_state_version)) {
1889 } else if (type->value() == "port") {
1891 XMLNode n (**niter);
1892 PortInsert* pi = new PortInsert (*_session, _route->pannable (), _route->mute_master ());
1894 IOProcessor::prepare_for_reset (n, pi->name());
1896 if (pi->set_state (n, Stateful::loading_state_version)) {
1903 /* XXX its a bit limiting to assume that everything else
1907 p.reset (new PluginInsert (*_session));
1908 p->set_state (**niter, Stateful::current_state_version);
1911 copies.push_back (p);
1915 error << _("plugin insert constructor failed") << endmsg;
1919 if (copies.empty()) {
1923 if (_route->add_processors (copies, p)) {
1926 "Copying the set of processors on the clipboard failed,\n\
1927 probably because the I/O configuration of the plugins\n\
1928 could not match the configuration of this track.");
1929 MessageDialog am (msg);
1935 ProcessorBox::get_selected_processors (ProcSelection& processors) const
1937 const list<ProcessorEntry*> selection = processor_display.selection ();
1938 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
1939 processors.push_back ((*i)->processor ());
1944 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
1946 list<ProcessorEntry*> selection = processor_display.selection ();
1947 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
1948 (this->*method) ((*i)->processor ());
1953 ProcessorBox::all_visible_processors_active (bool state)
1955 _route->all_visible_processors_active (state);
1959 ProcessorBox::ab_plugins ()
1961 _route->ab_plugins (ab_direction);
1962 ab_direction = !ab_direction;
1967 ProcessorBox::clear_processors ()
1970 vector<string> choices;
1972 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
1973 "(this cannot be undone)"), _route->name());
1975 choices.push_back (_("Cancel"));
1976 choices.push_back (_("Yes, remove them all"));
1978 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1980 if (prompter.run () == 1) {
1981 _route->clear_processors (PreFader);
1982 _route->clear_processors (PostFader);
1987 ProcessorBox::clear_processors (Placement p)
1990 vector<string> choices;
1992 if (p == PreFader) {
1993 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
1994 "(this cannot be undone)"), _route->name());
1996 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
1997 "(this cannot be undone)"), _route->name());
2000 choices.push_back (_("Cancel"));
2001 choices.push_back (_("Yes, remove them all"));
2003 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
2005 if (prompter.run () == 1) {
2006 _route->clear_processors (p);
2011 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
2013 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
2014 if (at && at->freeze_state() == AudioTrack::Frozen) {
2019 (boost::dynamic_pointer_cast<Send> (processor) && !boost::dynamic_pointer_cast<InternalSend> (processor))||
2020 boost::dynamic_pointer_cast<Return> (processor) ||
2021 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
2022 boost::dynamic_pointer_cast<PortInsert> (processor)
2031 ProcessorBox::one_processor_can_be_edited ()
2033 list<ProcessorEntry*> selection = processor_display.selection ();
2034 list<ProcessorEntry*>::iterator i = selection.begin();
2035 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
2039 return (i != selection.end());
2043 ProcessorBox::get_editor_window (boost::shared_ptr<Processor> processor)
2045 boost::shared_ptr<Send> send;
2046 boost::shared_ptr<InternalSend> internal_send;
2047 boost::shared_ptr<Return> retrn;
2048 boost::shared_ptr<PluginInsert> plugin_insert;
2049 boost::shared_ptr<PortInsert> port_insert;
2052 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
2054 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
2059 if (boost::dynamic_pointer_cast<Amp> (processor)) {
2061 if (_parent_strip) {
2062 _parent_strip->revert_to_default_display ();
2065 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
2067 if (!_session->engine().connected()) {
2071 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
2072 SendUIWindow* w = new SendUIWindow (send, _session);
2075 /* assign internal send to main fader */
2076 if (_parent_strip) {
2077 if (_parent_strip->current_delivery() == send) {
2078 _parent_strip->revert_to_default_display ();
2080 _parent_strip->show_send(send);
2085 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
2087 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
2088 /* no GUI for these */
2092 if (!_session->engine().connected()) {
2096 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
2098 ReturnUIWindow *return_ui;
2099 Window* w = get_processor_ui (retrn);
2103 return_ui = new ReturnUIWindow (retrn, _session);
2104 return_ui->set_title (retrn->name ());
2105 set_processor_ui (send, return_ui);
2108 return_ui = dynamic_cast<ReturnUIWindow *> (w);
2113 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
2115 PluginUIWindow *plugin_ui;
2117 /* these are both allowed to be null */
2119 Window* w = get_processor_ui (plugin_insert);
2123 plugin_ui = new PluginUIWindow (plugin_insert, false, Config->get_use_plugin_own_gui());
2124 plugin_ui->set_title (generate_processor_title (plugin_insert));
2125 set_processor_ui (plugin_insert, plugin_ui);
2128 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
2133 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
2135 if (!_session->engine().connected()) {
2136 MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible"));
2141 PortInsertWindow *io_selector;
2143 Window* w = get_processor_ui (port_insert);
2146 io_selector = new PortInsertWindow (_session, port_insert);
2147 set_processor_ui (port_insert, io_selector);
2150 io_selector = dynamic_cast<PortInsertWindow *> (w);
2153 gidget = io_selector;
2160 ProcessorBox::get_generic_editor_window (boost::shared_ptr<Processor> processor)
2162 boost::shared_ptr<PluginInsert> plugin_insert
2163 = boost::dynamic_pointer_cast<PluginInsert>(processor);
2165 if (!plugin_insert) {
2169 PluginUIWindow* win = new PluginUIWindow (plugin_insert, true, false);
2170 win->set_title (generate_processor_title (plugin_insert));
2176 ProcessorBox::register_actions ()
2178 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("ProcessorMenu"));
2179 Glib::RefPtr<Action> act;
2182 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin"),
2183 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
2185 act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"),
2186 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
2187 ActionManager::jack_sensitive_actions.push_back (act);
2188 act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New External Send ..."),
2189 sigc::ptr_fun (ProcessorBox::rb_choose_send));
2190 ActionManager::jack_sensitive_actions.push_back (act);
2192 ActionManager::register_action (popup_act_grp, X_("newaux"), _("New Aux Send ..."));
2194 ActionManager::register_action (popup_act_grp, X_("controls"), _("Controls"));
2196 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear (all)"),
2197 sigc::ptr_fun (ProcessorBox::rb_clear));
2198 ActionManager::register_action (popup_act_grp, X_("clear_pre"), _("Clear (pre-fader)"),
2199 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
2200 ActionManager::register_action (popup_act_grp, X_("clear_post"), _("Clear (post-fader)"),
2201 sigc::ptr_fun (ProcessorBox::rb_clear_post));
2203 /* standard editing stuff */
2204 cut_action = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"),
2205 sigc::ptr_fun (ProcessorBox::rb_cut));
2206 ActionManager::plugin_selection_sensitive_actions.push_back(cut_action);
2207 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),
2208 sigc::ptr_fun (ProcessorBox::rb_copy));
2209 ActionManager::plugin_selection_sensitive_actions.push_back(act);
2211 act = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"),
2212 sigc::ptr_fun (ProcessorBox::rb_delete));
2213 ActionManager::plugin_selection_sensitive_actions.push_back(act); // ??
2215 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"),
2216 sigc::ptr_fun (ProcessorBox::rb_paste));
2217 rename_action = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"),
2218 sigc::ptr_fun (ProcessorBox::rb_rename));
2219 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"),
2220 sigc::ptr_fun (ProcessorBox::rb_select_all));
2221 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"),
2222 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
2224 /* activation etc. */
2226 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate All"),
2227 sigc::ptr_fun (ProcessorBox::rb_activate_all));
2228 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate All"),
2229 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
2230 ActionManager::register_action (popup_act_grp, X_("ab_plugins"), _("A/B Plugins"),
2231 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
2234 edit_action = ActionManager::register_action (
2235 popup_act_grp, X_("edit"), _("Edit..."),
2236 sigc::ptr_fun (ProcessorBox::rb_edit));
2238 edit_generic_action = ActionManager::register_action (
2239 popup_act_grp, X_("edit-generic"), _("Edit with basic controls..."),
2240 sigc::ptr_fun (ProcessorBox::rb_edit_generic));
2242 ActionManager::add_action_group (popup_act_grp);
2246 ProcessorBox::rb_edit_generic ()
2248 if (_current_processor_box == 0) {
2252 _current_processor_box->for_selected_processors (&ProcessorBox::generic_edit_processor);
2256 ProcessorBox::rb_ab_plugins ()
2258 if (_current_processor_box == 0) {
2262 _current_processor_box->ab_plugins ();
2266 ProcessorBox::rb_choose_plugin ()
2268 if (_current_processor_box == 0) {
2271 _current_processor_box->choose_plugin ();
2275 ProcessorBox::rb_choose_insert ()
2277 if (_current_processor_box == 0) {
2280 _current_processor_box->choose_insert ();
2284 ProcessorBox::rb_choose_send ()
2286 if (_current_processor_box == 0) {
2289 _current_processor_box->choose_send ();
2293 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
2295 if (_current_processor_box == 0) {
2299 _current_processor_box->choose_aux (wr);
2303 ProcessorBox::rb_clear ()
2305 if (_current_processor_box == 0) {
2309 _current_processor_box->clear_processors ();
2314 ProcessorBox::rb_clear_pre ()
2316 if (_current_processor_box == 0) {
2320 _current_processor_box->clear_processors (PreFader);
2325 ProcessorBox::rb_clear_post ()
2327 if (_current_processor_box == 0) {
2331 _current_processor_box->clear_processors (PostFader);
2335 ProcessorBox::rb_cut ()
2337 if (_current_processor_box == 0) {
2341 _current_processor_box->processor_operation (ProcessorsCut);
2345 ProcessorBox::rb_delete ()
2347 if (_current_processor_box == 0) {
2351 _current_processor_box->processor_operation (ProcessorsDelete);
2355 ProcessorBox::rb_copy ()
2357 if (_current_processor_box == 0) {
2360 _current_processor_box->processor_operation (ProcessorsCopy);
2364 ProcessorBox::rb_paste ()
2366 if (_current_processor_box == 0) {
2370 _current_processor_box->processor_operation (ProcessorsPaste);
2374 ProcessorBox::rb_rename ()
2376 if (_current_processor_box == 0) {
2379 _current_processor_box->rename_processors ();
2383 ProcessorBox::rb_select_all ()
2385 if (_current_processor_box == 0) {
2389 _current_processor_box->processor_operation (ProcessorsSelectAll);
2393 ProcessorBox::rb_deselect_all ()
2395 if (_current_processor_box == 0) {
2399 _current_processor_box->deselect_all_processors ();
2403 ProcessorBox::rb_activate_all ()
2405 if (_current_processor_box == 0) {
2409 _current_processor_box->all_visible_processors_active (true);
2413 ProcessorBox::rb_deactivate_all ()
2415 if (_current_processor_box == 0) {
2418 _current_processor_box->all_visible_processors_active (false);
2422 ProcessorBox::rb_edit ()
2424 if (_current_processor_box == 0) {
2428 _current_processor_box->for_selected_processors (&ProcessorBox::edit_processor);
2432 ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
2438 ProcessorWindowProxy* proxy = find_window_proxy (processor);
2446 ProcessorBox::generic_edit_processor (boost::shared_ptr<Processor> processor)
2452 ProcessorWindowProxy* proxy = find_window_proxy (processor);
2460 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
2462 if (!what_changed.contains (ARDOUR::Properties::name)) {
2466 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
2468 boost::shared_ptr<Processor> processor;
2469 boost::shared_ptr<PluginInsert> plugin_insert;
2470 boost::shared_ptr<Send> send;
2472 list<ProcessorEntry*> children = processor_display.children();
2474 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
2476 processor = (*iter)->processor ();
2482 Window* w = get_processor_ui (processor);
2488 /* rename editor windows for sends and plugins */
2490 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
2491 w->set_title (send->name ());
2492 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
2493 w->set_title (generate_processor_title (plugin_insert));
2499 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
2501 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
2502 string::size_type email_pos;
2504 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
2505 maker = maker.substr (0, email_pos - 1);
2508 if (maker.length() > 32) {
2509 maker = maker.substr (0, 32);
2513 return string_compose(_("%1: %2 (by %3)"), _route->name(), pi->name(), maker);
2516 /** @param p Processor.
2517 * @return the UI window for \a p.
2520 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
2522 list<ProcessorWindowProxy*>::const_iterator i = _processor_window_info.begin ();
2523 while (i != _processor_window_info.end()) {
2524 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2526 return (*i)->get ();
2535 /** Make a note of the UI window that a processor is using.
2536 * @param p Processor.
2537 * @param w UI window.
2540 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
2542 list<ProcessorWindowProxy*>::iterator i = _processor_window_info.begin ();
2546 while (i != _processor_window_info.end()) {
2547 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2549 (*i)->use_window (*w);
2556 /* we shouldn't get here, because the ProcessorUIList should always contain
2557 an entry for each processor.
2563 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
2565 boost::shared_ptr<Delivery> d = w.lock ();
2570 list<ProcessorEntry*> children = processor_display.children ();
2571 list<ProcessorEntry*>::const_iterator i = children.begin();
2572 while (i != children.end() && (*i)->processor() != d) {
2576 if (i == children.end()) {
2577 processor_display.set_active (0);
2579 processor_display.set_active (*i);
2583 /** Called to repair the damage of Editor::show_window doing a show_all() */
2585 ProcessorBox::hide_things ()
2587 list<ProcessorEntry*> c = processor_display.children ();
2588 for (list<ProcessorEntry*>::iterator i = c.begin(); i != c.end(); ++i) {
2589 (*i)->hide_things ();
2594 ProcessorBox::processor_menu_unmapped ()
2596 processor_display.remove_placeholder ();
2600 ProcessorBox::entry_gui_object_state (ProcessorEntry* entry)
2602 if (!_parent_strip) {
2606 GUIObjectState& st = _parent_strip->gui_object_state ();
2608 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
2610 return st.get_or_add_node (strip, entry->state_id());
2614 ProcessorBox::update_gui_object_state (ProcessorEntry* entry)
2616 XMLNode* proc = entry_gui_object_state (entry);
2621 /* XXX: this is a bit inefficient; we just remove all child nodes and re-add them */
2622 proc->remove_nodes_and_delete (X_("Object"));
2623 entry->add_control_state (proc);
2626 ProcessorWindowProxy::ProcessorWindowProxy (string const & name, ProcessorBox* box, boost::weak_ptr<Processor> processor)
2627 : WindowManager::ProxyBase (name, string())
2629 , _processor_box (box)
2630 , _processor (processor)
2636 ARDOUR::SessionHandlePtr*
2637 ProcessorWindowProxy::session_handle()
2644 ProcessorWindowProxy::get (bool create)
2646 boost::shared_ptr<Processor> p = _processor.lock ();
2652 if (_window && (is_custom != Config->get_use_plugin_own_gui ())) {
2653 /* drop existing window - wrong type */
2662 _window = _processor_box->get_editor_window (p);
2663 is_custom = Config->get_use_plugin_own_gui();
2674 ProcessorWindowProxy::toggle ()
2676 if (_window && (is_custom != Config->get_use_plugin_own_gui ())) {
2677 /* drop existing window - wrong type */
2681 WindowManager::ProxyBase::toggle ();