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;
93 Glib::RefPtr<Gdk::Pixbuf> ProcessorEntry::_slider_pixbuf;
94 Glib::RefPtr<Gdk::Pixbuf> ProcessorEntry::_slider_pixbuf_desensitised;
96 ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processor> p, Width w)
97 : _button (ArdourButton::led_default_elements)
98 , _position (PreFader)
102 , _visual_state (Gtk::STATE_NORMAL)
106 _button.set_diameter (3);
107 _button.set_distinct_led_click (true);
108 _button.set_led_left (true);
109 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &ProcessorEntry::led_clicked));
110 _button.set_text (name (_width));
114 _vbox.pack_start (_button, true, true);
116 _button.set_active (_processor->active());
119 _processor->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_active_changed, this), gui_context());
120 _processor->PropertyChanged.connect (name_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_property_changed, this, _1), gui_context());
122 set<Evoral::Parameter> p = _processor->what_can_be_automated ();
123 for (set<Evoral::Parameter>::iterator i = p.begin(); i != p.end(); ++i) {
125 Control* c = new Control (
127 _slider_pixbuf_desensitised,
128 _processor->automation_control (*i),
129 _processor->describe_parameter (*i)
132 _controls.push_back (c);
134 if (boost::dynamic_pointer_cast<Amp> (_processor) == 0) {
135 /* Add non-Amp controls to the processor box */
136 _vbox.pack_start (c->box);
139 if (boost::dynamic_pointer_cast<Send> (_processor)) {
140 /* Don't label send faders */
148 _vbox.set_size_request (-1, _button.size_request().height);
152 ProcessorEntry::~ProcessorEntry ()
154 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
160 ProcessorEntry::action_widget ()
166 ProcessorEntry::widget ()
172 ProcessorEntry::drag_text () const
178 ProcessorEntry::set_position (Position p)
185 ProcessorEntry::set_visual_state (Gtkmm2ext::VisualState s, bool yn)
188 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() | s));
190 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() & ~s));
195 ProcessorEntry::setup_visuals ()
199 _button.set_name ("processor prefader");
203 _button.set_name ("processor fader");
207 _button.set_name ("processor postfader");
213 boost::shared_ptr<Processor>
214 ProcessorEntry::processor () const
220 ProcessorEntry::set_enum_width (Width w)
226 ProcessorEntry::led_clicked()
229 if (_button.get_active ()) {
230 _processor->deactivate ();
232 _processor->activate ();
238 ProcessorEntry::processor_active_changed ()
241 _button.set_active (_processor->active());
246 ProcessorEntry::processor_property_changed (const PropertyChange& what_changed)
248 if (what_changed.contains (ARDOUR::Properties::name)) {
249 _button.set_text (name (_width));
255 ProcessorEntry::setup_tooltip ()
257 ARDOUR_UI::instance()->set_tip (_button, name (Wide));
261 ProcessorEntry::name (Width w) const
263 boost::shared_ptr<Send> send;
270 if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
271 !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
275 /* grab the send name out of its overall name */
277 string::size_type lbracket, rbracket;
278 lbracket = send->name().find ('[');
279 rbracket = send->name().find (']');
283 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
286 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
294 name_display += _processor->display_name();
297 name_display += PBD::short_version (_processor->display_name(), 5);
307 ProcessorEntry::setup_slider_pix ()
309 _slider_pixbuf = ::get_icon ("fader_belt_h_thin");
310 assert (_slider_pixbuf);
311 _slider_pixbuf_desensitised = ::get_icon ("fader_belt_h_thin_desensitised");
312 assert (_slider_pixbuf_desensitised);
316 ProcessorEntry::set_pixel_width (int p)
318 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
319 (*i)->set_pixel_width (p);
324 ProcessorEntry::show_all_controls ()
326 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
327 (*i)->set_visible (true);
330 _parent->update_gui_object_state (this);
334 ProcessorEntry::hide_all_controls ()
336 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
337 (*i)->set_visible (false);
340 _parent->update_gui_object_state (this);
344 ProcessorEntry::add_control_state (XMLNode* node) const
346 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
347 (*i)->add_state (node);
352 ProcessorEntry::set_control_state (XMLNode const * node)
354 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
355 (*i)->set_state (node);
360 ProcessorEntry::state_id () const
362 return string_compose ("processor %1", _processor->id().to_s());
366 ProcessorEntry::hide_things ()
368 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
369 (*i)->hide_things ();
375 ProcessorEntry::build_controls_menu ()
377 using namespace Menu_Helpers;
378 Menu* menu = manage (new Menu);
379 MenuList& items = menu->items ();
382 MenuElem (_("Show All Controls"), sigc::mem_fun (*this, &ProcessorEntry::show_all_controls))
386 MenuElem (_("Hide All Controls"), sigc::mem_fun (*this, &ProcessorEntry::hide_all_controls))
389 if (!_controls.empty ()) {
390 items.push_back (SeparatorElem ());
393 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
394 items.push_back (CheckMenuElem ((*i)->name ()));
395 CheckMenuItem* c = dynamic_cast<CheckMenuItem*> (&items.back ());
396 c->set_active ((*i)->visible ());
397 c->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &ProcessorEntry::toggle_control_visibility), *i));
404 ProcessorEntry::toggle_control_visibility (Control* c)
406 c->set_visible (!c->visible ());
407 _parent->update_gui_object_state (this);
410 ProcessorEntry::Control::Control (Glib::RefPtr<Gdk::Pixbuf> s, Glib::RefPtr<Gdk::Pixbuf> sd, boost::shared_ptr<AutomationControl> c, string const & n)
412 , _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1)
413 , _slider (s, sd, &_adjustment, 0, false)
414 , _slider_persistant_tooltip (&_slider)
415 , _button (ArdourButton::Element (ArdourButton::Text | ArdourButton::Indicator))
416 , _ignore_ui_adjustment (false)
420 _slider.set_controllable (c);
423 _button.set_text (_name);
424 _button.set_led_left (true);
425 _button.set_name ("processor control button");
426 box.pack_start (_button);
429 _button.signal_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked));
430 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked));
431 c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
435 _slider.set_name ("PluginSlider");
436 _slider.set_size_request (-1, 13);
437 _slider.set_text (_name);
439 // box.pack_start (_label);
441 // _label.set_text (_name);
442 box.pack_start (_slider);
445 double const lo = c->internal_to_interface (c->lower ());
446 double const up = c->internal_to_interface (c->upper ());
448 _adjustment.set_lower (lo);
449 _adjustment.set_upper (up);
450 _adjustment.set_step_increment ((up - lo) / 100);
451 _adjustment.set_page_increment ((up - lo) / 10);
452 _slider.set_default_value (c->internal_to_interface (c->normal ()));
454 _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &Control::slider_adjusted));
455 c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
458 ARDOUR_UI::RapidScreenUpdate.connect (sigc::mem_fun (*this, &Control::control_changed));
463 /* We're providing our own PersistentTooltip */
464 set_no_tooltip_whatsoever (_slider);
468 ProcessorEntry::Control::set_tooltip ()
470 boost::shared_ptr<AutomationControl> c = _control.lock ();
479 s << (c->get_value() > 0.5 ? _("on") : _("off"));
481 s << setprecision(2) << fixed;
482 s << c->internal_to_user (c->get_value ());
485 ARDOUR_UI::instance()->set_tip (_label, s.str ());
486 _slider_persistant_tooltip.set_tip (s.str ());
487 ARDOUR_UI::instance()->set_tip (_button, s.str ());
491 ProcessorEntry::Control::set_pixel_width (int p)
493 _slider.set_fader_length (p);
497 ProcessorEntry::Control::slider_adjusted ()
499 if (_ignore_ui_adjustment) {
503 boost::shared_ptr<AutomationControl> c = _control.lock ();
509 c->set_value (c->interface_to_internal (_adjustment.get_value ()));
514 ProcessorEntry::Control::button_clicked ()
516 boost::shared_ptr<AutomationControl> c = _control.lock ();
522 bool const n = _button.get_active ();
524 c->set_value (n ? 0 : 1);
525 _button.set_active (!n);
529 ProcessorEntry::Control::control_changed ()
531 boost::shared_ptr<AutomationControl> c = _control.lock ();
536 _ignore_ui_adjustment = true;
540 _button.set_active (c->get_value() > 0.5);
544 _adjustment.set_value (c->internal_to_interface (c->get_value ()));
548 s.setf (ios::fixed, ios::floatfield);
549 s << c->internal_to_user (c->get_value ());
552 _ignore_ui_adjustment = false;
556 ProcessorEntry::Control::add_state (XMLNode* node) const
558 XMLNode* c = new XMLNode (X_("Object"));
559 c->add_property (X_("id"), state_id ());
560 c->add_property (X_("visible"), _visible);
561 node->add_child_nocopy (*c);
565 ProcessorEntry::Control::set_state (XMLNode const * node)
567 XMLNode* n = GUIObjectState::get_node (node, state_id ());
569 XMLProperty* p = n->property (X_("visible"));
570 set_visible (p && string_is_affirmative (p->value ()));
577 ProcessorEntry::Control::set_visible (bool v)
588 /** Called when the Editor might have re-shown things that
592 ProcessorEntry::Control::hide_things ()
600 ProcessorEntry::Control::hide_label ()
606 ProcessorEntry::Control::state_id () const
608 boost::shared_ptr<AutomationControl> c = _control.lock ();
611 return string_compose (X_("control %1"), c->id().to_s ());
614 BlankProcessorEntry::BlankProcessorEntry (ProcessorBox* b, Width w)
615 : ProcessorEntry (b, boost::shared_ptr<Processor>(), w)
619 PluginInsertProcessorEntry::PluginInsertProcessorEntry (ProcessorBox* b, boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
620 : ProcessorEntry (b, p, w)
623 p->SplittingChanged.connect (
624 _splitting_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::plugin_insert_splitting_changed, this), gui_context()
627 _splitting_icon.set_size_request (-1, 12);
629 _vbox.pack_start (_splitting_icon);
630 _vbox.reorder_child (_splitting_icon, 0);
632 plugin_insert_splitting_changed ();
636 PluginInsertProcessorEntry::plugin_insert_splitting_changed ()
638 if (_plugin_insert->splitting ()) {
639 _splitting_icon.show ();
641 _splitting_icon.hide ();
646 PluginInsertProcessorEntry::hide_things ()
648 ProcessorEntry::hide_things ();
649 plugin_insert_splitting_changed ();
653 PluginInsertProcessorEntry::setup_visuals ()
657 _splitting_icon.set_name ("ProcessorPreFader");
661 _splitting_icon.set_name ("ProcessorFader");
665 _splitting_icon.set_name ("ProcessorPostFader");
669 ProcessorEntry::setup_visuals ();
673 PluginInsertProcessorEntry::SplittingIcon::on_expose_event (GdkEventExpose* ev)
675 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
677 cairo_set_line_width (cr, 1);
679 double const width = ev->area.width;
680 double const height = ev->area.height;
682 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
683 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
685 cairo_rectangle (cr, 0, 0, width, height);
688 Gdk::Color const fg = get_style()->get_fg (STATE_NORMAL);
689 cairo_set_source_rgb (cr, fg.get_red_p (), fg.get_green_p (), fg.get_blue_p ());
691 cairo_move_to (cr, width * 0.3, height);
692 cairo_line_to (cr, width * 0.3, height * 0.5);
693 cairo_line_to (cr, width * 0.7, height * 0.5);
694 cairo_line_to (cr, width * 0.7, height);
695 cairo_move_to (cr, width * 0.5, height * 0.5);
696 cairo_line_to (cr, width * 0.5, 0);
702 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
703 RouteProcessorSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
704 : _parent_strip (parent)
705 , _owner_is_mixer (owner_is_mixer)
706 , ab_direction (true)
707 , _get_plugin_selector (get_plugin_selector)
709 , _visible_prefader_processors (0)
710 , _rr_selection(rsel)
716 no_processor_redisplay = false;
718 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
719 processor_scroller.add (processor_display);
720 pack_start (processor_scroller, true, true);
722 processor_display.set_flags (CAN_FOCUS);
723 processor_display.set_name ("ProcessorList");
724 processor_display.set_size_request (48, -1);
725 processor_display.set_data ("processorbox", this);
726 processor_display.set_spacing (2);
728 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
729 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
731 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
732 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
734 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
735 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
737 processor_scroller.show ();
738 processor_display.show ();
741 parent->DeliveryChanged.connect (
742 _mixer_strip_connections, invalidator (*this), boost::bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
746 ARDOUR_UI::instance()->set_tip (processor_display, _("Right-click to add/remove/edit\nplugins,inserts,sends and more"));
749 ProcessorBox::~ProcessorBox ()
751 /* it may appear as if we should delete processor_menu but that is a
752 * pointer to a widget owned by the UI Manager, and has potentially
753 * be returned to many other ProcessorBoxes. GTK doesn't really make
754 * clear the ownership of this widget, which is a menu and thus is
755 * never packed into any container other than an implict GtkWindow.
757 * For now, until or if we ever get clarification over the ownership
758 * story just let it continue to exist. At worst, its a small memory leak.
763 ProcessorBox::set_route (boost::shared_ptr<Route> r)
769 _route_connections.drop_connections();
771 /* new route: any existing block on processor redisplay must be meaningless */
772 no_processor_redisplay = false;
775 _route->processors_changed.connect (
776 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
779 _route->DropReferences.connect (
780 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
783 _route->PropertyChanged.connect (
784 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
787 redisplay_processors ();
791 ProcessorBox::route_going_away ()
793 /* don't keep updating display as processors are deleted */
794 no_processor_redisplay = true;
799 ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
801 boost::shared_ptr<Processor> p;
803 p = position->processor ();
805 /* dropped on the blank entry (which will be before the
806 fader), so use the first non-blank child as our
807 `dropped on' processor */
808 list<ProcessorEntry*> c = processor_display.children ();
809 list<ProcessorEntry*>::iterator i = c.begin ();
810 while (dynamic_cast<BlankProcessorEntry*> (*i)) {
811 assert (i != c.end ());
815 assert (i != c.end ());
816 p = (*i)->processor ();
821 list<ProcessorEntry*> children = source->selection ();
822 list<boost::shared_ptr<Processor> > procs;
823 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
824 if ((*i)->processor ()) {
825 procs.push_back ((*i)->processor ());
829 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
830 XMLNode& state = (*i)->get_state ();
832 nlist.push_back (&state);
833 paste_processor_state (nlist, p);
837 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
841 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
842 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
844 other->delete_dragged_processors (procs);
850 ProcessorBox::set_width (Width w)
858 list<ProcessorEntry*> children = processor_display.children ();
859 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
860 (*i)->set_enum_width (w);
863 redisplay_processors ();
867 ProcessorBox::build_possible_aux_menu ()
869 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
872 /* No aux sends if there are no busses */
876 using namespace Menu_Helpers;
877 Menu* menu = manage (new Menu);
878 MenuList& items = menu->items();
880 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
881 if (!_route->internal_send_for (*r) && *r != _route) {
882 items.push_back (MenuElem ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
890 ProcessorBox::show_processor_menu (int arg)
892 if (processor_menu == 0) {
893 processor_menu = build_processor_menu ();
894 processor_menu->signal_unmap().connect (sigc::mem_fun (*this, &ProcessorBox::processor_menu_unmapped));
897 /* Sort out the plugin submenu */
899 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newplugin"));
901 if (plugin_menu_item) {
902 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
905 /* And the aux submenu */
907 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newaux"));
910 Menu* m = build_possible_aux_menu();
911 if (m && !m->items().empty()) {
912 aux_menu_item->set_submenu (*m);
913 aux_menu_item->set_sensitive (true);
915 /* stupid gtkmm: we need to pass a null reference here */
916 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
917 aux_menu_item->set_sensitive (false);
921 ProcessorEntry* single_selection = 0;
922 if (processor_display.selection().size() == 1) {
923 single_selection = processor_display.selection().front();
926 /* And the controls submenu */
928 Gtk::MenuItem* controls_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/controls"));
930 if (controls_menu_item) {
931 if (single_selection) {
932 Menu* m = single_selection->build_controls_menu ();
933 if (m && !m->items().empty()) {
934 controls_menu_item->set_submenu (*m);
935 controls_menu_item->set_sensitive (true);
937 gtk_menu_item_set_submenu (controls_menu_item->gobj(), 0);
938 controls_menu_item->set_sensitive (false);
943 /* Sensitise actions as approprioate */
945 cut_action->set_sensitive (can_cut());
946 paste_action->set_sensitive (!_rr_selection.processors.empty());
948 const bool sensitive = !processor_display.selection().empty();
949 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
950 edit_action->set_sensitive (one_processor_can_be_edited ());
952 boost::shared_ptr<PluginInsert> pi;
953 if (single_selection) {
954 pi = boost::dynamic_pointer_cast<PluginInsert> (single_selection->processor ());
957 /* allow editing with an Ardour-generated UI for plugin inserts with editors */
958 edit_generic_action->set_sensitive (pi && pi->plugin()->has_editor ());
960 /* disallow rename for multiple selections, for plugin inserts and for the fader */
961 rename_action->set_sensitive (single_selection && !pi && !boost::dynamic_pointer_cast<Amp> (single_selection->processor ()));
963 processor_menu->popup (1, arg);
965 /* Add a placeholder gap to the processor list to indicate where a processor would be
966 inserted were one chosen from the menu.
969 processor_display.get_pointer (x, y);
970 _placement = processor_display.add_placeholder (y);
972 if (_visible_prefader_processors == 0 && _placement > 0) {
978 ProcessorBox::enter_notify (GdkEventCrossing*)
980 _current_processor_box = this;
985 ProcessorBox::leave_notify (GdkEventCrossing*)
991 ProcessorBox::processor_operation (ProcessorOperation op)
993 ProcSelection targets;
995 get_selected_processors (targets);
997 if (targets.empty()) {
1000 processor_display.get_pointer (x, y);
1002 pair<ProcessorEntry *, double> const pointer = processor_display.get_child_at_position (y);
1004 if (pointer.first && pointer.first->processor()) {
1005 targets.push_back (pointer.first->processor ());
1010 case ProcessorsSelectAll:
1011 processor_display.select_all ();
1014 case ProcessorsCopy:
1015 copy_processors (targets);
1019 cut_processors (targets);
1022 case ProcessorsPaste:
1023 if (targets.empty()) {
1024 paste_processors ();
1026 paste_processors (targets.front());
1030 case ProcessorsDelete:
1031 delete_processors (targets);
1034 case ProcessorsToggleActive:
1035 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
1036 if ((*i)->active()) {
1037 (*i)->deactivate ();
1054 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
1056 boost::shared_ptr<Processor> processor;
1058 processor = child->processor ();
1062 bool selected = processor_display.selected (child);
1064 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
1066 if (_session->engine().connected()) {
1067 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
1068 if (Config->get_use_plugin_own_gui ()) {
1069 toggle_edit_processor (processor);
1071 toggle_edit_generic_processor (processor);
1076 } else if (processor && ev->button == 1 && selected) {
1078 // this is purely informational but necessary for route params UI
1079 ProcessorSelected (processor); // emit
1081 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
1084 _get_plugin_selector()->show_manager ();
1091 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
1093 boost::shared_ptr<Processor> processor;
1095 processor = child->processor ();
1098 if (processor && Keyboard::is_delete_event (ev)) {
1100 Glib::signal_idle().connect (sigc::bind (
1101 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
1102 boost::weak_ptr<Processor>(processor)));
1104 } else if (Keyboard::is_context_menu_event (ev)) {
1106 show_processor_menu (ev->time);
1108 } else if (processor && Keyboard::is_button2_event (ev)
1110 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
1114 /* button2-click with no/appropriate modifiers */
1116 if (processor->active()) {
1117 processor->deactivate ();
1119 processor->activate ();
1127 ProcessorBox::build_processor_menu ()
1129 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/ProcessorMenu") );
1130 processor_menu->set_name ("ArdourContextMenu");
1131 return processor_menu;
1135 ProcessorBox::select_all_processors ()
1137 processor_display.select_all ();
1141 ProcessorBox::deselect_all_processors ()
1143 processor_display.select_none ();
1147 ProcessorBox::choose_plugin ()
1149 _get_plugin_selector()->set_interested_object (*this);
1152 /** @return true if an error occurred, otherwise false */
1154 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
1156 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
1158 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
1160 Route::ProcessorStreams err_streams;
1162 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
1163 weird_plugin_dialog (**p, err_streams);
1165 // XXX SHAREDPTR delete plugin here .. do we even need to care?
1168 if (Profile->get_sae()) {
1169 processor->activate ();
1178 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
1180 ArdourDialog dialog (_("Plugin Incompatibility"));
1183 string text = string_compose(_("You attempted to add the plugin \"%1\" in slot %2.\n"),
1184 p.name(), streams.index);
1186 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
1187 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
1189 text += _("\nThis plugin has:\n");
1191 uint32_t const n = p.get_info()->n_inputs.n_midi ();
1192 text += string_compose (ngettext ("\t%1 MIDI input\n", "\t%1 MIDI inputs\n", n), n);
1195 uint32_t const n = p.get_info()->n_inputs.n_audio ();
1196 text += string_compose (ngettext ("\t%1 audio input\n", "\t%1 audio inputs\n", n), n);
1199 text += _("\nbut at the insertion point, there are:\n");
1201 uint32_t const n = streams.count.n_midi ();
1202 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
1205 uint32_t const n = streams.count.n_audio ();
1206 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
1209 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
1210 label.set_text(text);
1212 dialog.get_vbox()->pack_start (label);
1213 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1215 dialog.set_name (X_("PluginIODialog"));
1216 dialog.set_position (Gtk::WIN_POS_MOUSE);
1217 dialog.set_modal (true);
1224 ProcessorBox::choose_insert ()
1226 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->pannable(), _route->mute_master()));
1227 _route->add_processor_by_index (processor, _placement);
1230 /* Caller must not hold process lock */
1232 ProcessorBox::choose_send ()
1234 boost::shared_ptr<Send> send (new Send (*_session, _route->pannable(), _route->mute_master()));
1236 /* make an educated guess at the initial number of outputs for the send */
1237 ChanCount outs = (_session->master_out())
1238 ? _session->master_out()->n_outputs()
1239 : _route->n_outputs();
1241 /* XXX need processor lock on route */
1243 Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock());
1244 send->output()->ensure_io (outs, false, this);
1245 } catch (AudioEngine::PortRegistrationFailure& err) {
1246 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
1250 /* let the user adjust the IO setup before creation.
1252 Note: this dialog is NOT modal - we just leave it to run and it will
1253 return when its Finished signal is emitted - typically when the window
1257 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
1260 /* keep a reference to the send so it doesn't get deleted while
1261 the IOSelectorWindow is doing its stuff
1263 _processor_being_created = send;
1265 ios->selector().Finished.connect (sigc::bind (
1266 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
1267 boost::weak_ptr<Processor>(send), ios));
1272 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1274 boost::shared_ptr<Processor> processor (weak_processor.lock());
1276 /* drop our temporary reference to the new send */
1277 _processor_being_created.reset ();
1284 case IOSelector::Cancelled:
1285 // processor will go away when all shared_ptrs to it vanish
1288 case IOSelector::Accepted:
1289 _route->add_processor_by_index (processor, _placement);
1290 if (Profile->get_sae()) {
1291 processor->activate ();
1296 delete_when_idle (ios);
1300 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1302 boost::shared_ptr<Processor> processor (weak_processor.lock());
1304 /* drop our temporary reference to the new return */
1305 _processor_being_created.reset ();
1312 case IOSelector::Cancelled:
1313 // processor will go away when all shared_ptrs to it vanish
1316 case IOSelector::Accepted:
1317 _route->add_processor_by_index (processor, _placement);
1318 if (Profile->get_sae()) {
1319 processor->activate ();
1324 delete_when_idle (ios);
1328 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
1334 boost::shared_ptr<Route> target = wr.lock();
1340 _session->add_internal_send (target, _placement, _route);
1344 ProcessorBox::route_processors_changed (RouteProcessorChange c)
1346 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
1347 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
1351 redisplay_processors ();
1355 ProcessorBox::redisplay_processors ()
1357 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors);
1360 if (no_processor_redisplay) {
1364 processor_display.clear ();
1366 _visible_prefader_processors = 0;
1369 _route->foreach_processor (sigc::bind (sigc::mem_fun (*this, &ProcessorBox::help_count_visible_prefader_processors),
1370 &_visible_prefader_processors, &fader_seen));
1372 if (_visible_prefader_processors == 0) { // fader only
1373 BlankProcessorEntry* bpe = new BlankProcessorEntry (this, _width);
1374 bpe->set_pixel_width (get_allocation().get_width());
1375 processor_display.add_child (bpe);
1378 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
1380 for (list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin(); i != _processor_window_proxies.end(); ++i) {
1381 (*i)->marked = false;
1384 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
1386 /* trim dead wood from the processor window proxy list */
1388 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin();
1389 while (i != _processor_window_proxies.end()) {
1390 list<ProcessorWindowProxy*>::iterator j = i;
1393 if (!(*i)->marked) {
1394 ARDOUR_UI::instance()->remove_window_proxy (*i);
1396 _processor_window_proxies.erase (i);
1402 setup_entry_positions ();
1405 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
1406 * not already have one.
1409 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
1411 boost::shared_ptr<Processor> p = w.lock ();
1416 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin ();
1417 while (i != _processor_window_proxies.end()) {
1419 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
1422 /* this processor is already on the list; done */
1423 (*i)->marked = true;
1430 /* not on the list; add it */
1433 if (_parent_strip) {
1434 if (_parent_strip->mixer_owned()) {
1443 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
1444 string_compose ("%1-%2-%3", loc, _route->id(), p->id()),
1445 _session->extra_xml (X_("UI")),
1451 /* if the processor already has an existing UI,
1452 note that so that we don't recreate it
1455 void* existing_ui = p->get_ui ();
1458 wp->set (static_cast<Gtk::Window*>(existing_ui));
1461 _processor_window_proxies.push_back (wp);
1462 ARDOUR_UI::instance()->add_window_proxy (wp);
1466 ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor> p, uint32_t* cnt, bool* amp_seen)
1468 boost::shared_ptr<Processor> processor (p.lock ());
1470 if (processor && processor->display_to_user()) {
1472 if (boost::dynamic_pointer_cast<Amp>(processor)) {
1483 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
1485 boost::shared_ptr<Processor> processor (p.lock ());
1487 if (!processor || !processor->display_to_user()) {
1491 boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
1492 ProcessorEntry* e = 0;
1493 if (plugin_insert) {
1494 e = new PluginInsertProcessorEntry (this, plugin_insert, _width);
1496 e = new ProcessorEntry (this, processor, _width);
1499 e->set_pixel_width (get_allocation().get_width());
1501 /* Set up this entry's state from the GUIObjectState */
1502 XMLNode* proc = entry_gui_object_state (e);
1504 e->set_control_state (proc);
1507 if (boost::dynamic_pointer_cast<Send> (processor)) {
1508 /* Always show send controls */
1509 e->show_all_controls ();
1512 processor_display.add_child (e);
1516 ProcessorBox::reordered ()
1518 compute_processor_sort_keys ();
1519 setup_entry_positions ();
1523 ProcessorBox::setup_entry_positions ()
1525 list<ProcessorEntry*> children = processor_display.children ();
1526 bool pre_fader = true;
1528 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1529 if (boost::dynamic_pointer_cast<Amp>((*i)->processor())) {
1531 (*i)->set_position (ProcessorEntry::Fader);
1534 (*i)->set_position (ProcessorEntry::PreFader);
1536 (*i)->set_position (ProcessorEntry::PostFader);
1543 ProcessorBox::compute_processor_sort_keys ()
1545 list<ProcessorEntry*> children = processor_display.children ();
1546 Route::ProcessorList our_processors;
1548 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1549 if ((*i)->processor()) {
1550 our_processors.push_back ((*i)->processor ());
1554 if (_route->reorder_processors (our_processors)) {
1555 /* Reorder failed, so report this to the user. As far as I can see this must be done
1556 in an idle handler: it seems that the redisplay_processors() that happens below destroys
1557 widgets that were involved in the drag-and-drop on the processor list, which causes problems
1558 when the drag is torn down after this handler function is finished.
1560 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
1565 ProcessorBox::report_failed_reorder ()
1567 /* reorder failed, so redisplay */
1569 redisplay_processors ();
1571 /* now tell them about the problem */
1573 ArdourDialog dialog (_("Plugin Incompatibility"));
1576 label.set_text (_("\
1577 You cannot reorder these plugins/sends/inserts\n\
1578 in that way because the inputs and\n\
1579 outputs will not work correctly."));
1581 dialog.get_vbox()->set_border_width (12);
1582 dialog.get_vbox()->pack_start (label);
1583 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1585 dialog.set_name (X_("PluginIODialog"));
1586 dialog.set_position (Gtk::WIN_POS_MOUSE);
1587 dialog.set_modal (true);
1594 ProcessorBox::rename_processors ()
1596 ProcSelection to_be_renamed;
1598 get_selected_processors (to_be_renamed);
1600 if (to_be_renamed.empty()) {
1604 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
1605 rename_processor (*i);
1610 ProcessorBox::can_cut () const
1612 vector<boost::shared_ptr<Processor> > sel;
1614 get_selected_processors (sel);
1616 /* cut_processors () does not cut inserts */
1618 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
1620 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1621 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1622 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1631 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
1633 if (to_be_removed.empty()) {
1637 XMLNode* node = new XMLNode (X_("cut"));
1638 Route::ProcessorList to_cut;
1640 no_processor_redisplay = true;
1641 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
1642 // Cut only plugins, sends and returns
1643 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1644 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1645 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1647 Window* w = get_processor_ui (*i);
1653 XMLNode& child ((*i)->get_state());
1654 node->add_child_nocopy (child);
1655 to_cut.push_back (*i);
1659 if (_route->remove_processors (to_cut) != 0) {
1661 no_processor_redisplay = false;
1665 _rr_selection.set (node);
1667 no_processor_redisplay = false;
1668 redisplay_processors ();
1672 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
1674 if (to_be_copied.empty()) {
1678 XMLNode* node = new XMLNode (X_("copy"));
1680 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
1681 // Copy only plugins, sends, returns
1682 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1683 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1684 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1685 node->add_child_nocopy ((*i)->get_state());
1689 _rr_selection.set (node);
1693 ProcessorBox::delete_processors (const ProcSelection& targets)
1695 if (targets.empty()) {
1699 no_processor_redisplay = true;
1701 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
1703 Window* w = get_processor_ui (*i);
1709 _route->remove_processor(*i);
1712 no_processor_redisplay = false;
1713 redisplay_processors ();
1717 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
1719 list<boost::shared_ptr<Processor> >::const_iterator x;
1721 no_processor_redisplay = true;
1722 for (x = procs.begin(); x != procs.end(); ++x) {
1724 Window* w = get_processor_ui (*x);
1730 _route->remove_processor(*x);
1733 no_processor_redisplay = false;
1734 redisplay_processors ();
1738 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
1740 boost::shared_ptr<Processor> processor (weak_processor.lock());
1746 /* NOT copied to _mixer.selection() */
1748 no_processor_redisplay = true;
1749 _route->remove_processor (processor);
1750 no_processor_redisplay = false;
1751 redisplay_processors ();
1757 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
1759 ArdourPrompter name_prompter (true);
1761 name_prompter.set_title (_("Rename Processor"));
1762 name_prompter.set_prompt (_("New name:"));
1763 name_prompter.set_initial_text (processor->name());
1764 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
1765 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
1766 name_prompter.show_all ();
1768 switch (name_prompter.run ()) {
1770 case Gtk::RESPONSE_ACCEPT:
1771 name_prompter.get_result (result);
1772 if (result.length()) {
1775 string test = result;
1777 while (tries < 100) {
1778 if (_session->io_name_is_legal (test)) {
1784 test = string_compose ("%1-%2", result, tries);
1788 processor->set_name (result);
1791 ARDOUR_UI::instance()->popup_error
1792 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
1802 ProcessorBox::paste_processors ()
1804 if (_rr_selection.processors.empty()) {
1808 paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
1812 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
1815 if (_rr_selection.processors.empty()) {
1819 paste_processor_state (_rr_selection.processors.get_node().children(), before);
1823 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
1825 XMLNodeConstIterator niter;
1826 list<boost::shared_ptr<Processor> > copies;
1828 if (nlist.empty()) {
1832 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1834 XMLProperty const * type = (*niter)->property ("type");
1837 boost::shared_ptr<Processor> p;
1839 if (type->value() == "meter" ||
1840 type->value() == "main-outs" ||
1841 type->value() == "amp" ||
1842 type->value() == "intsend" || type->value() == "intreturn") {
1843 /* do not paste meter, main outs, amp or internal send/returns */
1846 } else if (type->value() == "send") {
1848 XMLNode n (**niter);
1849 Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
1851 IOProcessor::prepare_for_reset (n, s->name());
1853 if (s->set_state (n, Stateful::loading_state_version)) {
1860 } else if (type->value() == "return") {
1862 XMLNode n (**niter);
1863 Return* r = new Return (*_session);
1865 IOProcessor::prepare_for_reset (n, r->name());
1867 if (r->set_state (n, Stateful::loading_state_version)) {
1874 } else if (type->value() == "port") {
1876 XMLNode n (**niter);
1877 PortInsert* pi = new PortInsert (*_session, _route->pannable (), _route->mute_master ());
1879 IOProcessor::prepare_for_reset (n, pi->name());
1881 if (pi->set_state (n, Stateful::loading_state_version)) {
1888 /* XXX its a bit limiting to assume that everything else
1892 p.reset (new PluginInsert (*_session));
1893 p->set_state (**niter, Stateful::current_state_version);
1896 copies.push_back (p);
1900 error << _("plugin insert constructor failed") << endmsg;
1904 if (copies.empty()) {
1908 if (_route->add_processors (copies, p)) {
1911 "Copying the set of processors on the clipboard failed,\n\
1912 probably because the I/O configuration of the plugins\n\
1913 could not match the configuration of this track.");
1914 MessageDialog am (msg);
1920 ProcessorBox::get_selected_processors (ProcSelection& processors) const
1922 const list<ProcessorEntry*> selection = processor_display.selection ();
1923 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
1924 processors.push_back ((*i)->processor ());
1929 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
1931 list<ProcessorEntry*> selection = processor_display.selection ();
1932 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
1933 (this->*method) ((*i)->processor ());
1938 ProcessorBox::all_visible_processors_active (bool state)
1940 _route->all_visible_processors_active (state);
1944 ProcessorBox::ab_plugins ()
1946 _route->ab_plugins (ab_direction);
1947 ab_direction = !ab_direction;
1952 ProcessorBox::clear_processors ()
1955 vector<string> choices;
1957 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
1958 "(this cannot be undone)"), _route->name());
1960 choices.push_back (_("Cancel"));
1961 choices.push_back (_("Yes, remove them all"));
1963 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1965 if (prompter.run () == 1) {
1966 _route->clear_processors (PreFader);
1967 _route->clear_processors (PostFader);
1972 ProcessorBox::clear_processors (Placement p)
1975 vector<string> choices;
1977 if (p == PreFader) {
1978 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
1979 "(this cannot be undone)"), _route->name());
1981 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
1982 "(this cannot be undone)"), _route->name());
1985 choices.push_back (_("Cancel"));
1986 choices.push_back (_("Yes, remove them all"));
1988 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1990 if (prompter.run () == 1) {
1991 _route->clear_processors (p);
1996 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
1998 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
1999 if (at && at->freeze_state() == AudioTrack::Frozen) {
2004 (boost::dynamic_pointer_cast<Send> (processor) && !boost::dynamic_pointer_cast<InternalSend> (processor))||
2005 boost::dynamic_pointer_cast<Return> (processor) ||
2006 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
2007 boost::dynamic_pointer_cast<PortInsert> (processor)
2016 ProcessorBox::one_processor_can_be_edited ()
2018 list<ProcessorEntry*> selection = processor_display.selection ();
2019 list<ProcessorEntry*>::iterator i = selection.begin();
2020 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
2024 return (i != selection.end());
2028 ProcessorBox::toggle_edit_processor (boost::shared_ptr<Processor> processor)
2030 boost::shared_ptr<Send> send;
2031 boost::shared_ptr<InternalSend> internal_send;
2032 boost::shared_ptr<Return> retrn;
2033 boost::shared_ptr<PluginInsert> plugin_insert;
2034 boost::shared_ptr<PortInsert> port_insert;
2037 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
2039 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
2044 if (boost::dynamic_pointer_cast<Amp> (processor)) {
2046 if (_parent_strip) {
2047 _parent_strip->revert_to_default_display ();
2050 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
2052 if (!_session->engine().connected()) {
2056 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
2057 SendUIWindow* w = new SendUIWindow (send, _session);
2060 /* assign internal send to main fader */
2061 if (_parent_strip) {
2062 if (_parent_strip->current_delivery() == send) {
2063 _parent_strip->revert_to_default_display ();
2065 _parent_strip->show_send(send);
2070 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
2072 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
2073 /* no GUI for these */
2077 if (!_session->engine().connected()) {
2081 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
2083 ReturnUIWindow *return_ui;
2084 Window* w = get_processor_ui (retrn);
2088 return_ui = new ReturnUIWindow (retrn, _session);
2089 return_ui->set_title (retrn->name ());
2090 set_processor_ui (send, return_ui);
2093 return_ui = dynamic_cast<ReturnUIWindow *> (w);
2098 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
2100 PluginUIWindow *plugin_ui;
2102 /* these are both allowed to be null */
2104 Container* toplevel = get_toplevel();
2105 Window* win = dynamic_cast<Gtk::Window*>(toplevel);
2107 Window* w = get_processor_ui (plugin_insert);
2111 plugin_ui = new PluginUIWindow (win, plugin_insert);
2112 plugin_ui->set_title (generate_processor_title (plugin_insert));
2113 set_processor_ui (plugin_insert, plugin_ui);
2116 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
2117 plugin_ui->set_parent (win);
2122 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
2124 if (!_session->engine().connected()) {
2125 MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible"));
2130 PortInsertWindow *io_selector;
2132 Window* w = get_processor_ui (port_insert);
2135 io_selector = new PortInsertWindow (_session, port_insert);
2136 set_processor_ui (port_insert, io_selector);
2139 io_selector = dynamic_cast<PortInsertWindow *> (w);
2142 gidget = io_selector;
2146 if (gidget->is_visible()) {
2149 gidget->show_all ();
2155 /** Toggle a generic (Ardour-generated) plugin UI */
2157 ProcessorBox::toggle_edit_generic_processor (boost::shared_ptr<Processor> processor)
2159 boost::shared_ptr<PluginInsert> plugin_insert
2160 = boost::dynamic_pointer_cast<PluginInsert>(processor);
2161 if (!plugin_insert) {
2165 Container* toplevel = get_toplevel();
2166 Window* win = dynamic_cast<Gtk::Window*>(toplevel);
2167 PluginUIWindow* plugin_ui = new PluginUIWindow(win, plugin_insert, true, false);
2168 plugin_ui->set_title(generate_processor_title (plugin_insert));
2170 if (plugin_ui->is_visible()) {
2173 plugin_ui->show_all();
2174 plugin_ui->present();
2179 ProcessorBox::register_actions ()
2181 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("ProcessorMenu"));
2182 Glib::RefPtr<Action> act;
2185 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin"),
2186 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
2188 act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"),
2189 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
2190 ActionManager::jack_sensitive_actions.push_back (act);
2191 act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New External Send ..."),
2192 sigc::ptr_fun (ProcessorBox::rb_choose_send));
2193 ActionManager::jack_sensitive_actions.push_back (act);
2195 ActionManager::register_action (popup_act_grp, X_("newaux"), _("New Aux Send ..."));
2197 ActionManager::register_action (popup_act_grp, X_("controls"), _("Controls"));
2199 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear (all)"),
2200 sigc::ptr_fun (ProcessorBox::rb_clear));
2201 ActionManager::register_action (popup_act_grp, X_("clear_pre"), _("Clear (pre-fader)"),
2202 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
2203 ActionManager::register_action (popup_act_grp, X_("clear_post"), _("Clear (post-fader)"),
2204 sigc::ptr_fun (ProcessorBox::rb_clear_post));
2206 /* standard editing stuff */
2207 cut_action = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"),
2208 sigc::ptr_fun (ProcessorBox::rb_cut));
2209 ActionManager::plugin_selection_sensitive_actions.push_back(cut_action);
2210 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),
2211 sigc::ptr_fun (ProcessorBox::rb_copy));
2212 ActionManager::plugin_selection_sensitive_actions.push_back(act);
2214 act = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"),
2215 sigc::ptr_fun (ProcessorBox::rb_delete));
2216 ActionManager::plugin_selection_sensitive_actions.push_back(act); // ??
2218 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"),
2219 sigc::ptr_fun (ProcessorBox::rb_paste));
2220 rename_action = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"),
2221 sigc::ptr_fun (ProcessorBox::rb_rename));
2222 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"),
2223 sigc::ptr_fun (ProcessorBox::rb_select_all));
2224 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"),
2225 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
2227 /* activation etc. */
2229 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate All"),
2230 sigc::ptr_fun (ProcessorBox::rb_activate_all));
2231 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate All"),
2232 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
2233 ActionManager::register_action (popup_act_grp, X_("ab_plugins"), _("A/B Plugins"),
2234 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
2237 edit_action = ActionManager::register_action (
2238 popup_act_grp, X_("edit"), _("Edit..."),
2239 sigc::ptr_fun (ProcessorBox::rb_edit));
2241 edit_generic_action = ActionManager::register_action (
2242 popup_act_grp, X_("edit-generic"), _("Edit with basic controls..."),
2243 sigc::ptr_fun (ProcessorBox::rb_edit_generic));
2245 ActionManager::add_action_group (popup_act_grp);
2249 ProcessorBox::rb_edit_generic ()
2251 if (_current_processor_box == 0) {
2255 _current_processor_box->for_selected_processors (&ProcessorBox::toggle_edit_generic_processor);
2259 ProcessorBox::rb_ab_plugins ()
2261 if (_current_processor_box == 0) {
2265 _current_processor_box->ab_plugins ();
2269 ProcessorBox::rb_choose_plugin ()
2271 if (_current_processor_box == 0) {
2274 _current_processor_box->choose_plugin ();
2278 ProcessorBox::rb_choose_insert ()
2280 if (_current_processor_box == 0) {
2283 _current_processor_box->choose_insert ();
2287 ProcessorBox::rb_choose_send ()
2289 if (_current_processor_box == 0) {
2292 _current_processor_box->choose_send ();
2296 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
2298 if (_current_processor_box == 0) {
2302 _current_processor_box->choose_aux (wr);
2306 ProcessorBox::rb_clear ()
2308 if (_current_processor_box == 0) {
2312 _current_processor_box->clear_processors ();
2317 ProcessorBox::rb_clear_pre ()
2319 if (_current_processor_box == 0) {
2323 _current_processor_box->clear_processors (PreFader);
2328 ProcessorBox::rb_clear_post ()
2330 if (_current_processor_box == 0) {
2334 _current_processor_box->clear_processors (PostFader);
2338 ProcessorBox::rb_cut ()
2340 if (_current_processor_box == 0) {
2344 _current_processor_box->processor_operation (ProcessorsCut);
2348 ProcessorBox::rb_delete ()
2350 if (_current_processor_box == 0) {
2354 _current_processor_box->processor_operation (ProcessorsDelete);
2358 ProcessorBox::rb_copy ()
2360 if (_current_processor_box == 0) {
2363 _current_processor_box->processor_operation (ProcessorsCopy);
2367 ProcessorBox::rb_paste ()
2369 if (_current_processor_box == 0) {
2373 _current_processor_box->processor_operation (ProcessorsPaste);
2377 ProcessorBox::rb_rename ()
2379 if (_current_processor_box == 0) {
2382 _current_processor_box->rename_processors ();
2386 ProcessorBox::rb_select_all ()
2388 if (_current_processor_box == 0) {
2392 _current_processor_box->processor_operation (ProcessorsSelectAll);
2396 ProcessorBox::rb_deselect_all ()
2398 if (_current_processor_box == 0) {
2402 _current_processor_box->deselect_all_processors ();
2406 ProcessorBox::rb_activate_all ()
2408 if (_current_processor_box == 0) {
2412 _current_processor_box->all_visible_processors_active (true);
2416 ProcessorBox::rb_deactivate_all ()
2418 if (_current_processor_box == 0) {
2421 _current_processor_box->all_visible_processors_active (false);
2425 ProcessorBox::rb_edit ()
2427 if (_current_processor_box == 0) {
2431 _current_processor_box->for_selected_processors (&ProcessorBox::toggle_edit_processor);
2435 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
2437 if (!what_changed.contains (ARDOUR::Properties::name)) {
2441 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
2443 boost::shared_ptr<Processor> processor;
2444 boost::shared_ptr<PluginInsert> plugin_insert;
2445 boost::shared_ptr<Send> send;
2447 list<ProcessorEntry*> children = processor_display.children();
2449 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
2451 processor = (*iter)->processor ();
2457 Window* w = get_processor_ui (processor);
2463 /* rename editor windows for sends and plugins */
2465 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
2466 w->set_title (send->name ());
2467 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
2468 w->set_title (generate_processor_title (plugin_insert));
2474 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
2476 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
2477 string::size_type email_pos;
2479 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
2480 maker = maker.substr (0, email_pos - 1);
2483 if (maker.length() > 32) {
2484 maker = maker.substr (0, 32);
2488 return string_compose(_("%1: %2 (by %3)"), _route->name(), pi->name(), maker);
2492 ProcessorBox::on_size_allocate (Allocation& a)
2494 HBox::on_size_allocate (a);
2496 list<ProcessorEntry*> children = processor_display.children ();
2497 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
2498 (*i)->set_pixel_width (a.get_width ());
2502 /** @param p Processor.
2503 * @return the UI window for \a p.
2506 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
2508 list<ProcessorWindowProxy*>::const_iterator i = _processor_window_proxies.begin ();
2509 while (i != _processor_window_proxies.end()) {
2510 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2512 return (*i)->get ();
2521 /** Make a note of the UI window that a processor is using.
2522 * @param p Processor.
2523 * @param w UI window.
2526 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
2528 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin ();
2532 while (i != _processor_window_proxies.end()) {
2533 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2542 /* we shouldn't get here, because the ProcessorUIList should always contain
2543 an entry for each processor.
2549 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
2551 boost::shared_ptr<Delivery> d = w.lock ();
2556 list<ProcessorEntry*> children = processor_display.children ();
2557 list<ProcessorEntry*>::const_iterator i = children.begin();
2558 while (i != children.end() && (*i)->processor() != d) {
2562 if (i == children.end()) {
2563 processor_display.set_active (0);
2565 processor_display.set_active (*i);
2569 /** Called to repair the damage of Editor::show_window doing a show_all() */
2571 ProcessorBox::hide_things ()
2573 list<ProcessorEntry*> c = processor_display.children ();
2574 for (list<ProcessorEntry*>::iterator i = c.begin(); i != c.end(); ++i) {
2575 (*i)->hide_things ();
2580 ProcessorBox::processor_menu_unmapped ()
2582 processor_display.remove_placeholder ();
2586 ProcessorBox::entry_gui_object_state (ProcessorEntry* entry)
2588 if (!_parent_strip) {
2592 GUIObjectState& st = _parent_strip->gui_object_state ();
2594 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
2596 return st.get_or_add_node (strip, entry->state_id());
2600 ProcessorBox::update_gui_object_state (ProcessorEntry* entry)
2602 XMLNode* proc = entry_gui_object_state (entry);
2607 /* XXX: this is a bit inefficient; we just remove all child nodes and re-add them */
2608 proc->remove_nodes_and_delete (X_("Object"));
2609 entry->add_control_state (proc);
2612 ProcessorWindowProxy::ProcessorWindowProxy (
2613 string const & name,
2614 XMLNode const * node,
2616 boost::weak_ptr<Processor> processor
2618 : WindowProxy<Gtk::Window> (name, node)
2620 , _processor_box (box)
2621 , _processor (processor)
2628 ProcessorWindowProxy::show ()
2630 boost::shared_ptr<Processor> p = _processor.lock ();
2635 _processor_box->toggle_edit_processor (p);