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/ardour.h"
44 #include "ardour/audio_track.h"
45 #include "ardour/audioengine.h"
46 #include "ardour/internal_send.h"
47 #include "ardour/internal_return.h"
48 #include "ardour/ladspa_plugin.h"
49 #include "ardour/meter.h"
50 #include "ardour/plugin_insert.h"
51 #include "ardour/port_insert.h"
52 #include "ardour/profile.h"
53 #include "ardour/return.h"
54 #include "ardour/route.h"
55 #include "ardour/send.h"
56 #include "ardour/session.h"
57 #include "ardour/dB.h"
60 #include "ardour_dialog.h"
61 #include "ardour_ui.h"
62 #include "gui_thread.h"
63 #include "io_selector.h"
66 #include "mixer_strip.h"
67 #include "plugin_selector.h"
68 #include "plugin_ui.h"
69 #include "port_insert_ui.h"
70 #include "processor_box.h"
71 #include "public_editor.h"
72 #include "return_ui.h"
73 #include "route_processor_selection.h"
79 #ifdef AUDIOUNIT_SUPPORT
84 using namespace ARDOUR;
88 using namespace Gtkmm2ext;
90 ProcessorBox* ProcessorBox::_current_processor_box = 0;
91 RefPtr<Action> ProcessorBox::paste_action;
92 RefPtr<Action> ProcessorBox::cut_action;
93 RefPtr<Action> ProcessorBox::rename_action;
94 RefPtr<Action> ProcessorBox::edit_action;
95 RefPtr<Action> ProcessorBox::controls_action;
96 Glib::RefPtr<Gdk::Pixbuf> ProcessorEntry::_slider_pixbuf;
98 ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processor> p, Width w)
99 : _button (ArdourButton::led_default_elements)
100 , _position (PreFader)
104 , _visual_state (Gtk::STATE_NORMAL)
108 _button.set_diameter (3);
109 _button.set_distinct_led_click (true);
110 _button.set_led_left (true);
111 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &ProcessorEntry::led_clicked));
112 _button.set_text (name (_width));
116 _vbox.pack_start (_button, true, true);
118 if (_processor->active()) {
119 _button.set_active_state (Gtkmm2ext::Active);
124 _processor->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_active_changed, this), gui_context());
125 _processor->PropertyChanged.connect (name_connection, invalidator (*this), ui_bind (&ProcessorEntry::processor_property_changed, this, _1), gui_context());
127 set<Evoral::Parameter> p = _processor->what_can_be_automated ();
128 for (set<Evoral::Parameter>::iterator i = p.begin(); i != p.end(); ++i) {
130 Control* c = new Control (_slider_pixbuf, _processor->automation_control (*i), _processor->describe_parameter (*i));
131 _controls.push_back (c);
133 if (boost::dynamic_pointer_cast<Amp> (_processor) == 0) {
134 /* Add non-Amp controls to the processor box */
135 _vbox.pack_start (c->box);
138 if (boost::dynamic_pointer_cast<Send> (_processor)) {
139 /* Don't label send faders */
147 _vbox.set_size_request (-1, _button.size_request().height);
151 ProcessorEntry::~ProcessorEntry ()
153 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
159 ProcessorEntry::action_widget ()
165 ProcessorEntry::widget ()
171 ProcessorEntry::drag_text () const
177 ProcessorEntry::set_position (Position p)
184 ProcessorEntry::set_visual_state (Gtkmm2ext::VisualState s, bool yn)
187 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() | s));
189 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() & ~s));
194 ProcessorEntry::setup_visuals ()
198 _button.set_name ("processor prefader");
202 _button.set_name ("processor fader");
206 _button.set_name ("processor postfader");
212 boost::shared_ptr<Processor>
213 ProcessorEntry::processor () const
219 ProcessorEntry::set_enum_width (Width w)
225 ProcessorEntry::led_clicked()
228 if (_button.active_state() == Gtkmm2ext::Active) {
229 _processor->deactivate ();
231 _processor->activate ();
237 ProcessorEntry::processor_active_changed ()
240 if (_processor->active()) {
241 _button.set_active_state (Gtkmm2ext::Active);
243 _button.unset_active_state ();
249 ProcessorEntry::processor_property_changed (const PropertyChange& what_changed)
251 if (what_changed.contains (ARDOUR::Properties::name)) {
252 _button.set_text (name (_width));
258 ProcessorEntry::setup_tooltip ()
260 ARDOUR_UI::instance()->set_tip (_button, name (Wide));
264 ProcessorEntry::name (Width w) const
266 boost::shared_ptr<Send> send;
273 if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
274 !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
278 /* grab the send name out of its overall name */
280 string::size_type lbracket, rbracket;
281 lbracket = send->name().find ('[');
282 rbracket = send->name().find (']');
286 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
289 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
297 name_display += _processor->display_name();
300 name_display += PBD::short_version (_processor->display_name(), 5);
310 ProcessorEntry::setup_slider_pix ()
312 _slider_pixbuf = ::get_icon ("fader_belt_h_thin");
313 assert (_slider_pixbuf);
317 ProcessorEntry::set_pixel_width (int p)
319 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
320 (*i)->set_pixel_width (p);
325 ProcessorEntry::show_all_controls ()
327 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
328 (*i)->set_visible (true);
331 _parent->update_gui_object_state (this);
335 ProcessorEntry::hide_all_controls ()
337 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
338 (*i)->set_visible (false);
341 _parent->update_gui_object_state (this);
345 ProcessorEntry::add_control_state (XMLNode* node) const
347 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
348 (*i)->add_state (node);
353 ProcessorEntry::set_control_state (XMLNode const * node)
355 for (list<Control*>::const_iterator i = _controls.begin(); i != _controls.end(); ++i) {
356 (*i)->set_state (node);
361 ProcessorEntry::state_id () const
363 return string_compose ("processor %1", _processor->id().to_s());
367 ProcessorEntry::hide_things ()
369 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
370 (*i)->hide_things ();
376 ProcessorEntry::build_controls_menu ()
378 using namespace Menu_Helpers;
379 Menu* menu = manage (new Menu);
380 MenuList& items = menu->items ();
383 MenuElem (_("Show All Controls"), sigc::mem_fun (*this, &ProcessorEntry::show_all_controls))
387 MenuElem (_("Hide All Controls"), sigc::mem_fun (*this, &ProcessorEntry::hide_all_controls))
390 if (!_controls.empty ()) {
391 items.push_back (SeparatorElem ());
394 for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
395 items.push_back (CheckMenuElem ((*i)->name ()));
396 CheckMenuItem* c = dynamic_cast<CheckMenuItem*> (&items.back ());
397 c->set_active ((*i)->visible ());
398 c->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &ProcessorEntry::toggle_control_visibility), *i));
405 ProcessorEntry::toggle_control_visibility (Control* c)
407 c->set_visible (!c->visible ());
408 _parent->update_gui_object_state (this);
411 ProcessorEntry::Control::Control (Glib::RefPtr<Gdk::Pixbuf> s, boost::shared_ptr<AutomationControl> c, string const & n)
413 , _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1)
414 , _slider (s, &_adjustment, 0, false)
415 , _ignore_slider_adjustment (false)
419 _slider.set_controllable (c);
421 box.pack_start (_label);
423 _label.set_text (_name);
425 box.pack_start (_slider);
428 double const lo = c->internal_to_interface (c->lower ());
429 double const up = c->internal_to_interface (c->upper ());
431 _adjustment.set_lower (lo);
432 _adjustment.set_upper (up);
433 _adjustment.set_step_increment ((up - lo) / 100);
434 _adjustment.set_page_increment ((up - lo) / 10);
435 _slider.set_default_value (c->internal_to_interface (c->normal ()));
437 _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &Control::slider_adjusted));
438 c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
444 ProcessorEntry::Control::set_pixel_width (int p)
446 _slider.set_fader_length (p);
450 ProcessorEntry::Control::slider_adjusted ()
452 if (_ignore_slider_adjustment) {
456 boost::shared_ptr<AutomationControl> c = _control.lock ();
462 c->set_value (c->interface_to_internal (_adjustment.get_value ()));
466 ProcessorEntry::Control::control_changed ()
468 boost::shared_ptr<AutomationControl> c = _control.lock ();
473 _ignore_slider_adjustment = true;
475 _adjustment.set_value (c->internal_to_interface (c->get_value ()));
479 s.setf (ios::fixed, ios::floatfield);
480 s << c->internal_to_user (c->get_value ());
482 _slider.set_tooltip_text (s.str ());
484 _ignore_slider_adjustment = false;
488 ProcessorEntry::Control::add_state (XMLNode* node) const
490 XMLNode* c = new XMLNode (X_("Object"));
491 c->add_property (X_("id"), state_id ());
492 c->add_property (X_("visible"), _visible);
493 node->add_child_nocopy (*c);
497 ProcessorEntry::Control::set_state (XMLNode const * node)
499 XMLNode* n = GUIObjectState::get_node (node, state_id ());
501 XMLProperty* p = n->property (X_("visible"));
502 set_visible (p && string_is_affirmative (p->value ()));
509 ProcessorEntry::Control::set_visible (bool v)
520 /** Called when the Editor might have re-shown things that
524 ProcessorEntry::Control::hide_things ()
532 ProcessorEntry::Control::hide_label ()
538 ProcessorEntry::Control::state_id () const
540 boost::shared_ptr<AutomationControl> c = _control.lock ();
543 return string_compose (X_("control %1"), c->id().to_s ());
546 BlankProcessorEntry::BlankProcessorEntry (ProcessorBox* b, Width w)
547 : ProcessorEntry (b, boost::shared_ptr<Processor>(), w)
551 PluginInsertProcessorEntry::PluginInsertProcessorEntry (ProcessorBox* b, boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
552 : ProcessorEntry (b, p, w)
555 p->SplittingChanged.connect (
556 _splitting_connection, invalidator (*this), ui_bind (&PluginInsertProcessorEntry::plugin_insert_splitting_changed, this), gui_context()
559 _splitting_icon.set_size_request (-1, 12);
561 _vbox.pack_start (_splitting_icon);
562 _vbox.reorder_child (_splitting_icon, 0);
564 plugin_insert_splitting_changed ();
568 PluginInsertProcessorEntry::plugin_insert_splitting_changed ()
570 if (_plugin_insert->splitting ()) {
571 _splitting_icon.show ();
573 _splitting_icon.hide ();
578 PluginInsertProcessorEntry::hide_things ()
580 ProcessorEntry::hide_things ();
581 plugin_insert_splitting_changed ();
585 PluginInsertProcessorEntry::setup_visuals ()
589 _splitting_icon.set_name ("ProcessorPreFader");
593 _splitting_icon.set_name ("ProcessorFader");
597 _splitting_icon.set_name ("ProcessorPostFader");
601 ProcessorEntry::setup_visuals ();
605 PluginInsertProcessorEntry::SplittingIcon::on_expose_event (GdkEventExpose* ev)
607 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
609 cairo_set_line_width (cr, 1);
611 double const width = ev->area.width;
612 double const height = ev->area.height;
614 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
615 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
617 cairo_rectangle (cr, 0, 0, width, height);
620 Gdk::Color const fg = get_style()->get_fg (STATE_NORMAL);
621 cairo_set_source_rgb (cr, fg.get_red_p (), fg.get_green_p (), fg.get_blue_p ());
623 cairo_move_to (cr, width * 0.3, height);
624 cairo_line_to (cr, width * 0.3, height * 0.5);
625 cairo_line_to (cr, width * 0.7, height * 0.5);
626 cairo_line_to (cr, width * 0.7, height);
627 cairo_move_to (cr, width * 0.5, height * 0.5);
628 cairo_line_to (cr, width * 0.5, 0);
634 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
635 RouteProcessorSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
636 : _parent_strip (parent)
637 , _owner_is_mixer (owner_is_mixer)
638 , ab_direction (true)
639 , _get_plugin_selector (get_plugin_selector)
641 , _visible_prefader_processors (0)
642 , _rr_selection(rsel)
648 no_processor_redisplay = false;
650 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
651 processor_scroller.add (processor_display);
652 pack_start (processor_scroller, true, true);
654 processor_display.set_flags (CAN_FOCUS);
655 processor_display.set_name ("ProcessorList");
656 processor_display.set_size_request (48, -1);
657 processor_display.set_data ("processorbox", this);
658 processor_display.set_spacing (2);
660 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
661 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
663 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
664 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
666 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
667 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
669 processor_scroller.show ();
670 processor_display.show ();
673 parent->DeliveryChanged.connect (
674 _mixer_strip_connections, invalidator (*this), ui_bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
678 ARDOUR_UI::instance()->set_tip (processor_display, _("Right-click to add/remove/edit\nplugins,inserts,sends and more"));
681 ProcessorBox::~ProcessorBox ()
683 /* it may appear as if we should delete processor_menu but that is a
684 * pointer to a widget owned by the UI Manager, and has potentially
685 * be returned to many other ProcessorBoxes. GTK doesn't really make
686 * clear the ownership of this widget, which is a menu and thus is
687 * never packed into any container other than an implict GtkWindow.
689 * For now, until or if we ever get clarification over the ownership
690 * story just let it continue to exist. At worst, its a small memory leak.
695 ProcessorBox::set_route (boost::shared_ptr<Route> r)
701 _route_connections.drop_connections();
703 /* new route: any existing block on processor redisplay must be meaningless */
704 no_processor_redisplay = false;
707 _route->processors_changed.connect (
708 _route_connections, invalidator (*this), ui_bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
711 _route->DropReferences.connect (
712 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
715 _route->PropertyChanged.connect (
716 _route_connections, invalidator (*this), ui_bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
719 redisplay_processors ();
723 ProcessorBox::route_going_away ()
725 /* don't keep updating display as processors are deleted */
726 no_processor_redisplay = true;
731 ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
733 boost::shared_ptr<Processor> p;
735 p = position->processor ();
738 list<ProcessorEntry*> children = source->selection ();
739 list<boost::shared_ptr<Processor> > procs;
740 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
741 if ((*i)->processor ()) {
742 procs.push_back ((*i)->processor ());
746 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
747 XMLNode& state = (*i)->get_state ();
749 nlist.push_back (&state);
750 paste_processor_state (nlist, p);
754 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
758 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
759 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
761 other->delete_dragged_processors (procs);
767 ProcessorBox::update()
769 redisplay_processors ();
773 ProcessorBox::set_width (Width w)
781 list<ProcessorEntry*> children = processor_display.children ();
782 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
783 (*i)->set_enum_width (w);
786 redisplay_processors ();
790 ProcessorBox::build_possible_aux_menu ()
792 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
798 using namespace Menu_Helpers;
799 Menu* menu = manage (new Menu);
800 MenuList& items = menu->items();
802 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
803 if (!_route->internal_send_for (*r) && *r != _route) {
804 items.push_back (MenuElem ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
812 ProcessorBox::show_processor_menu (int arg)
814 if (processor_menu == 0) {
815 processor_menu = build_processor_menu ();
816 processor_menu->signal_unmap().connect (sigc::mem_fun (*this, &ProcessorBox::processor_menu_unmapped));
819 /* Sort out the plugin submenu */
821 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newplugin"));
823 if (plugin_menu_item) {
824 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
827 /* And the aux submenu */
829 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newaux"));
832 Menu* m = build_possible_aux_menu();
833 if (m && !m->items().empty()) {
834 aux_menu_item->set_submenu (*m);
835 aux_menu_item->set_sensitive (true);
837 /* stupid gtkmm: we need to pass a null reference here */
838 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
839 aux_menu_item->set_sensitive (false);
843 ProcessorEntry* single_selection = 0;
844 if (processor_display.selection().size() == 1) {
845 single_selection = processor_display.selection().front();
848 /* And the controls submenu */
850 Gtk::MenuItem* controls_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/controls"));
852 if (controls_menu_item) {
853 if (single_selection) {
854 Menu* m = single_selection->build_controls_menu ();
855 if (m && !m->items().empty()) {
856 controls_menu_item->set_submenu (*m);
857 controls_menu_item->set_sensitive (true);
859 gtk_menu_item_set_submenu (controls_menu_item->gobj(), 0);
860 controls_menu_item->set_sensitive (false);
865 /* Sensitise actions as approprioate */
867 cut_action->set_sensitive (can_cut());
868 paste_action->set_sensitive (!_rr_selection.processors.empty());
870 const bool sensitive = !processor_display.selection().empty();
871 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
872 edit_action->set_sensitive (one_processor_can_be_edited ());
874 boost::shared_ptr<PluginInsert> pi;
875 if (single_selection) {
876 pi = boost::dynamic_pointer_cast<PluginInsert> (single_selection->processor ());
879 /* disallow rename for multiple selections, for plugin inserts and for the fader */
880 rename_action->set_sensitive (single_selection && !pi && !boost::dynamic_pointer_cast<Amp> (single_selection->processor ()));
882 processor_menu->popup (1, arg);
884 /* Add a placeholder gap to the processor list to indicate where a processor would be
885 inserted were one chosen from the menu.
888 processor_display.get_pointer (x, y);
889 _placement = processor_display.add_placeholder (y);
891 if (_visible_prefader_processors == 0) {
892 if (_placement == 1) {
899 ProcessorBox::enter_notify (GdkEventCrossing*)
901 _current_processor_box = this;
906 ProcessorBox::leave_notify (GdkEventCrossing* ev)
912 ProcessorBox::processor_operation (ProcessorOperation op)
914 ProcSelection targets;
916 get_selected_processors (targets);
918 if (targets.empty()) {
921 processor_display.get_pointer (x, y);
923 pair<ProcessorEntry *, double> const pointer = processor_display.get_child_at_position (y);
925 if (pointer.first && pointer.first->processor()) {
926 targets.push_back (pointer.first->processor ());
931 case ProcessorsSelectAll:
932 processor_display.select_all ();
936 copy_processors (targets);
940 cut_processors (targets);
943 case ProcessorsPaste:
944 if (targets.empty()) {
947 paste_processors (targets.front());
951 case ProcessorsDelete:
952 delete_processors (targets);
955 case ProcessorsToggleActive:
956 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
957 if ((*i)->active()) {
975 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
977 boost::shared_ptr<Processor> processor;
979 processor = child->processor ();
983 bool selected = processor_display.selected (child);
985 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
987 if (_session->engine().connected()) {
988 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
989 toggle_edit_processor (processor);
993 } else if (processor && ev->button == 1 && selected) {
995 // this is purely informational but necessary for route params UI
996 ProcessorSelected (processor); // emit
998 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
1001 _get_plugin_selector()->show_manager ();
1008 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
1010 boost::shared_ptr<Processor> processor;
1012 processor = child->processor ();
1015 if (processor && Keyboard::is_delete_event (ev)) {
1017 Glib::signal_idle().connect (sigc::bind (
1018 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
1019 boost::weak_ptr<Processor>(processor)));
1021 } else if (Keyboard::is_context_menu_event (ev)) {
1023 show_processor_menu (ev->time);
1025 } else if (processor && Keyboard::is_button2_event (ev)
1027 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
1031 /* button2-click with no/appropriate modifiers */
1033 if (processor->active()) {
1034 processor->deactivate ();
1036 processor->activate ();
1044 ProcessorBox::build_processor_menu ()
1046 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/ProcessorMenu") );
1047 processor_menu->set_name ("ArdourContextMenu");
1048 return processor_menu;
1052 ProcessorBox::select_all_processors ()
1054 processor_display.select_all ();
1058 ProcessorBox::deselect_all_processors ()
1060 processor_display.select_none ();
1064 ProcessorBox::choose_plugin ()
1066 _get_plugin_selector()->set_interested_object (*this);
1069 /** @return true if an error occurred, otherwise false */
1071 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
1073 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
1075 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
1077 Route::ProcessorStreams err_streams;
1079 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
1080 weird_plugin_dialog (**p, err_streams);
1082 // XXX SHAREDPTR delete plugin here .. do we even need to care?
1085 if (Profile->get_sae()) {
1086 processor->activate ();
1095 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
1097 ArdourDialog dialog (_("Plugin Incompatibility"));
1100 string text = string_compose(_("You attempted to add the plugin \"%1\" in slot %2.\n"),
1101 p.name(), streams.index);
1103 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
1104 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
1106 text += _("\nThis plugin has:\n");
1108 uint32_t const n = p.get_info()->n_inputs.n_midi ();
1109 text += string_compose (ngettext ("\t%1 MIDI input\n", "\t%1 MIDI inputs\n", n), n);
1112 uint32_t const n = p.get_info()->n_inputs.n_audio ();
1113 text += string_compose (ngettext ("\t%1 audio input\n", "\t%1 audio inputs\n", n), n);
1116 text += _("\nbut at the insertion point, there are:\n");
1118 uint32_t const n = streams.count.n_midi ();
1119 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
1122 uint32_t const n = streams.count.n_audio ();
1123 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
1126 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
1127 label.set_text(text);
1129 dialog.get_vbox()->pack_start (label);
1130 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1132 dialog.set_name (X_("PluginIODialog"));
1133 dialog.set_position (Gtk::WIN_POS_MOUSE);
1134 dialog.set_modal (true);
1141 ProcessorBox::choose_insert ()
1143 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->pannable(), _route->mute_master()));
1144 _route->add_processor_by_index (processor, _placement);
1147 /* Caller must not hold process lock */
1149 ProcessorBox::choose_send ()
1151 boost::shared_ptr<Send> send (new Send (*_session, _route->pannable(), _route->mute_master()));
1153 /* make an educated guess at the initial number of outputs for the send */
1154 ChanCount outs = (_session->master_out())
1155 ? _session->master_out()->n_outputs()
1156 : _route->n_outputs();
1158 /* XXX need processor lock on route */
1160 Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock());
1161 send->output()->ensure_io (outs, false, this);
1162 } catch (AudioEngine::PortRegistrationFailure& err) {
1163 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
1167 /* let the user adjust the IO setup before creation.
1169 Note: this dialog is NOT modal - we just leave it to run and it will
1170 return when its Finished signal is emitted - typically when the window
1174 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
1177 /* keep a reference to the send so it doesn't get deleted while
1178 the IOSelectorWindow is doing its stuff
1180 _processor_being_created = send;
1182 ios->selector().Finished.connect (sigc::bind (
1183 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
1184 boost::weak_ptr<Processor>(send), ios));
1189 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1191 boost::shared_ptr<Processor> processor (weak_processor.lock());
1193 /* drop our temporary reference to the new send */
1194 _processor_being_created.reset ();
1201 case IOSelector::Cancelled:
1202 // processor will go away when all shared_ptrs to it vanish
1205 case IOSelector::Accepted:
1206 _route->add_processor_by_index (processor, _placement);
1207 if (Profile->get_sae()) {
1208 processor->activate ();
1213 delete_when_idle (ios);
1217 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1219 boost::shared_ptr<Processor> processor (weak_processor.lock());
1221 /* drop our temporary reference to the new return */
1222 _processor_being_created.reset ();
1229 case IOSelector::Cancelled:
1230 // processor will go away when all shared_ptrs to it vanish
1233 case IOSelector::Accepted:
1234 _route->add_processor_by_index (processor, _placement);
1235 if (Profile->get_sae()) {
1236 processor->activate ();
1241 delete_when_idle (ios);
1245 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
1251 boost::shared_ptr<Route> target = wr.lock();
1257 boost::shared_ptr<RouteList> rlist (new RouteList);
1258 rlist->push_back (_route);
1260 _session->add_internal_sends (target, PreFader, rlist);
1264 ProcessorBox::route_processors_changed (RouteProcessorChange c)
1266 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
1267 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
1271 redisplay_processors ();
1275 ProcessorBox::redisplay_processors ()
1277 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors);
1280 if (no_processor_redisplay) {
1284 processor_display.clear ();
1286 _visible_prefader_processors = 0;
1289 _route->foreach_processor (sigc::bind (sigc::mem_fun (*this, &ProcessorBox::help_count_visible_prefader_processors),
1290 &_visible_prefader_processors, &fader_seen));
1292 if (_visible_prefader_processors == 0) { // fader only
1293 BlankProcessorEntry* bpe = new BlankProcessorEntry (this, _width);
1294 bpe->set_pixel_width (get_allocation().get_width());
1295 processor_display.add_child (bpe);
1298 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
1300 for (list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin(); i != _processor_window_proxies.end(); ++i) {
1301 (*i)->marked = false;
1304 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
1306 /* trim dead wood from the processor window proxy list */
1308 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin();
1309 while (i != _processor_window_proxies.end()) {
1310 list<ProcessorWindowProxy*>::iterator j = i;
1313 if (!(*i)->marked) {
1314 ARDOUR_UI::instance()->remove_window_proxy (*i);
1316 _processor_window_proxies.erase (i);
1322 setup_entry_positions ();
1325 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
1326 * not already have one.
1329 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
1331 boost::shared_ptr<Processor> p = w.lock ();
1336 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin ();
1337 while (i != _processor_window_proxies.end()) {
1339 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
1342 /* this processor is already on the list; done */
1343 (*i)->marked = true;
1350 /* not on the list; add it */
1353 if (_parent_strip) {
1354 if (_parent_strip->mixer_owned()) {
1363 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
1364 string_compose ("%1-%2-%3", loc, _route->id(), p->id()),
1365 _session->extra_xml (X_("UI")),
1371 /* if the processor already has an existing UI,
1372 note that so that we don't recreate it
1375 void* existing_ui = p->get_ui ();
1378 wp->set (static_cast<Gtk::Window*>(existing_ui));
1381 _processor_window_proxies.push_back (wp);
1382 ARDOUR_UI::instance()->add_window_proxy (wp);
1386 ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor> p, uint32_t* cnt, bool* amp_seen)
1388 boost::shared_ptr<Processor> processor (p.lock ());
1390 if (processor && processor->display_to_user()) {
1392 if (boost::dynamic_pointer_cast<Amp>(processor)) {
1403 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
1405 boost::shared_ptr<Processor> processor (p.lock ());
1407 if (!processor || !processor->display_to_user()) {
1411 boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
1412 ProcessorEntry* e = 0;
1413 if (plugin_insert) {
1414 e = new PluginInsertProcessorEntry (this, plugin_insert, _width);
1416 e = new ProcessorEntry (this, processor, _width);
1419 e->set_pixel_width (get_allocation().get_width());
1421 /* Set up this entry's state from the GUIObjectState */
1422 XMLNode* proc = entry_gui_object_state (e);
1424 e->set_control_state (proc);
1427 if (boost::dynamic_pointer_cast<Send> (processor)) {
1428 /* Always show send controls */
1429 e->show_all_controls ();
1432 processor_display.add_child (e);
1436 ProcessorBox::reordered ()
1438 compute_processor_sort_keys ();
1439 setup_entry_positions ();
1443 ProcessorBox::setup_entry_positions ()
1445 list<ProcessorEntry*> children = processor_display.children ();
1446 bool pre_fader = true;
1448 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1449 if (boost::dynamic_pointer_cast<Amp>((*i)->processor())) {
1451 (*i)->set_position (ProcessorEntry::Fader);
1454 (*i)->set_position (ProcessorEntry::PreFader);
1456 (*i)->set_position (ProcessorEntry::PostFader);
1463 ProcessorBox::compute_processor_sort_keys ()
1465 list<ProcessorEntry*> children = processor_display.children ();
1466 Route::ProcessorList our_processors;
1468 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1469 if ((*i)->processor()) {
1470 our_processors.push_back ((*i)->processor ());
1474 if (_route->reorder_processors (our_processors)) {
1475 /* Reorder failed, so report this to the user. As far as I can see this must be done
1476 in an idle handler: it seems that the redisplay_processors() that happens below destroys
1477 widgets that were involved in the drag-and-drop on the processor list, which causes problems
1478 when the drag is torn down after this handler function is finished.
1480 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
1485 ProcessorBox::report_failed_reorder ()
1487 /* reorder failed, so redisplay */
1489 redisplay_processors ();
1491 /* now tell them about the problem */
1493 ArdourDialog dialog (_("Plugin Incompatibility"));
1496 label.set_text (_("\
1497 You cannot reorder these plugins/sends/inserts\n\
1498 in that way because the inputs and\n\
1499 outputs will not work correctly."));
1501 dialog.get_vbox()->set_border_width (12);
1502 dialog.get_vbox()->pack_start (label);
1503 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1505 dialog.set_name (X_("PluginIODialog"));
1506 dialog.set_position (Gtk::WIN_POS_MOUSE);
1507 dialog.set_modal (true);
1514 ProcessorBox::rename_processors ()
1516 ProcSelection to_be_renamed;
1518 get_selected_processors (to_be_renamed);
1520 if (to_be_renamed.empty()) {
1524 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
1525 rename_processor (*i);
1530 ProcessorBox::can_cut () const
1532 vector<boost::shared_ptr<Processor> > sel;
1534 get_selected_processors (sel);
1536 /* cut_processors () does not cut inserts */
1538 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
1540 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1541 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1542 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1551 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
1553 if (to_be_removed.empty()) {
1557 XMLNode* node = new XMLNode (X_("cut"));
1558 Route::ProcessorList to_cut;
1560 no_processor_redisplay = true;
1561 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
1562 // Cut only plugins, sends and returns
1563 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1564 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1565 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1567 Window* w = get_processor_ui (*i);
1573 XMLNode& child ((*i)->get_state());
1574 node->add_child_nocopy (child);
1575 to_cut.push_back (*i);
1579 if (_route->remove_processors (to_cut) != 0) {
1581 no_processor_redisplay = false;
1585 _rr_selection.set (node);
1587 no_processor_redisplay = false;
1588 redisplay_processors ();
1592 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
1594 if (to_be_copied.empty()) {
1598 XMLNode* node = new XMLNode (X_("copy"));
1600 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
1601 // Copy only plugins, sends, returns
1602 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1603 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1604 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1605 node->add_child_nocopy ((*i)->get_state());
1609 _rr_selection.set (node);
1613 ProcessorBox::processors_up ()
1619 ProcessorBox::processors_down ()
1626 ProcessorBox::delete_processors (const ProcSelection& targets)
1628 if (targets.empty()) {
1632 no_processor_redisplay = true;
1634 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
1636 Window* w = get_processor_ui (*i);
1642 _route->remove_processor(*i);
1645 no_processor_redisplay = false;
1646 redisplay_processors ();
1650 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
1652 list<boost::shared_ptr<Processor> >::const_iterator x;
1654 no_processor_redisplay = true;
1655 for (x = procs.begin(); x != procs.end(); ++x) {
1657 Window* w = get_processor_ui (*x);
1663 _route->remove_processor(*x);
1666 no_processor_redisplay = false;
1667 redisplay_processors ();
1671 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
1673 boost::shared_ptr<Processor> processor (weak_processor.lock());
1679 /* NOT copied to _mixer.selection() */
1681 no_processor_redisplay = true;
1682 _route->remove_processor (processor);
1683 no_processor_redisplay = false;
1684 redisplay_processors ();
1690 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
1692 ArdourPrompter name_prompter (true);
1694 name_prompter.set_title (_("Rename Processor"));
1695 name_prompter.set_prompt (_("New name:"));
1696 name_prompter.set_initial_text (processor->name());
1697 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
1698 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
1699 name_prompter.show_all ();
1701 switch (name_prompter.run ()) {
1703 case Gtk::RESPONSE_ACCEPT:
1704 name_prompter.get_result (result);
1705 if (result.length()) {
1708 string test = result;
1710 while (tries < 100) {
1711 if (_session->io_name_is_legal (test)) {
1717 test = string_compose ("%1-%2", result, tries);
1721 processor->set_name (result);
1724 ARDOUR_UI::instance()->popup_error
1725 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
1735 ProcessorBox::paste_processors ()
1737 if (_rr_selection.processors.empty()) {
1741 paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
1745 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
1748 if (_rr_selection.processors.empty()) {
1752 paste_processor_state (_rr_selection.processors.get_node().children(), before);
1756 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
1758 XMLNodeConstIterator niter;
1759 list<boost::shared_ptr<Processor> > copies;
1761 if (nlist.empty()) {
1765 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1767 XMLProperty const * type = (*niter)->property ("type");
1770 boost::shared_ptr<Processor> p;
1772 if (type->value() == "meter" ||
1773 type->value() == "main-outs" ||
1774 type->value() == "amp" ||
1775 type->value() == "intsend" || type->value() == "intreturn") {
1776 /* do not paste meter, main outs, amp or internal send/returns */
1779 } else if (type->value() == "send") {
1781 XMLNode n (**niter);
1782 Send::make_unique (n, *_session);
1783 Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
1784 if (s->set_state (n, Stateful::loading_state_version)) {
1792 } else if (type->value() == "return") {
1794 XMLNode n (**niter);
1795 Return::make_unique (n, *_session);
1796 Return* r = new Return (*_session);
1798 if (r->set_state (n, Stateful::loading_state_version)) {
1805 } else if (type->value() == "port") {
1807 XMLNode n (**niter);
1808 p.reset (new PortInsert (*_session, _route->pannable (), _route->mute_master ()));
1809 if (p->set_state (n, Stateful::loading_state_version)) {
1814 /* XXX its a bit limiting to assume that everything else
1818 p.reset (new PluginInsert (*_session));
1819 p->set_state (**niter, Stateful::current_state_version);
1822 copies.push_back (p);
1826 cerr << "plugin insert constructor failed\n";
1830 if (copies.empty()) {
1834 if (_route->add_processors (copies, p)) {
1837 "Copying the set of processors on the clipboard failed,\n\
1838 probably because the I/O configuration of the plugins\n\
1839 could not match the configuration of this track.");
1840 MessageDialog am (msg);
1846 ProcessorBox::activate_processor (boost::shared_ptr<Processor> r)
1852 ProcessorBox::deactivate_processor (boost::shared_ptr<Processor> r)
1858 ProcessorBox::get_selected_processors (ProcSelection& processors) const
1860 const list<ProcessorEntry*> selection = processor_display.selection ();
1861 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
1862 processors.push_back ((*i)->processor ());
1867 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
1869 list<ProcessorEntry*> selection = processor_display.selection ();
1870 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
1871 (this->*method) ((*i)->processor ());
1876 ProcessorBox::all_visible_processors_active (bool state)
1878 _route->all_visible_processors_active (state);
1882 ProcessorBox::ab_plugins ()
1884 _route->ab_plugins (ab_direction);
1885 ab_direction = !ab_direction;
1890 ProcessorBox::clear_processors ()
1893 vector<string> choices;
1895 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
1896 "(this cannot be undone)"), _route->name());
1898 choices.push_back (_("Cancel"));
1899 choices.push_back (_("Yes, remove them all"));
1901 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1903 if (prompter.run () == 1) {
1904 _route->clear_processors (PreFader);
1905 _route->clear_processors (PostFader);
1910 ProcessorBox::clear_processors (Placement p)
1913 vector<string> choices;
1915 if (p == PreFader) {
1916 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
1917 "(this cannot be undone)"), _route->name());
1919 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
1920 "(this cannot be undone)"), _route->name());
1923 choices.push_back (_("Cancel"));
1924 choices.push_back (_("Yes, remove them all"));
1926 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1928 if (prompter.run () == 1) {
1929 _route->clear_processors (p);
1934 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
1936 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
1937 if (at && at->freeze_state() == AudioTrack::Frozen) {
1942 (boost::dynamic_pointer_cast<Send> (processor) && !boost::dynamic_pointer_cast<InternalSend> (processor))||
1943 boost::dynamic_pointer_cast<Return> (processor) ||
1944 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
1945 boost::dynamic_pointer_cast<PortInsert> (processor)
1954 ProcessorBox::one_processor_can_be_edited ()
1956 list<ProcessorEntry*> selection = processor_display.selection ();
1957 list<ProcessorEntry*>::iterator i = selection.begin();
1958 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
1962 return (i != selection.end());
1966 ProcessorBox::toggle_edit_processor (boost::shared_ptr<Processor> processor)
1968 boost::shared_ptr<Send> send;
1969 boost::shared_ptr<InternalSend> internal_send;
1970 boost::shared_ptr<Return> retrn;
1971 boost::shared_ptr<PluginInsert> plugin_insert;
1972 boost::shared_ptr<PortInsert> port_insert;
1975 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
1977 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
1982 if (boost::dynamic_pointer_cast<Amp> (processor)) {
1984 if (_parent_strip) {
1985 _parent_strip->revert_to_default_display ();
1988 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
1990 if (!_session->engine().connected()) {
1994 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
1995 SendUIWindow* w = new SendUIWindow (send, _session);
1998 /* assign internal send to main fader */
1999 if (_parent_strip) {
2000 if (_parent_strip->current_delivery() == send) {
2001 _parent_strip->revert_to_default_display ();
2003 _parent_strip->show_send(send);
2008 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
2010 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
2011 /* no GUI for these */
2015 if (!_session->engine().connected()) {
2019 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
2021 ReturnUIWindow *return_ui;
2022 Window* w = get_processor_ui (retrn);
2026 return_ui = new ReturnUIWindow (retrn, _session);
2027 return_ui->set_title (retrn->name ());
2028 set_processor_ui (send, return_ui);
2031 return_ui = dynamic_cast<ReturnUIWindow *> (w);
2036 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
2038 PluginUIWindow *plugin_ui;
2040 /* these are both allowed to be null */
2042 Container* toplevel = get_toplevel();
2043 Window* win = dynamic_cast<Gtk::Window*>(toplevel);
2045 Window* w = get_processor_ui (plugin_insert);
2049 plugin_ui = new PluginUIWindow (win, plugin_insert);
2050 plugin_ui->set_title (generate_processor_title (plugin_insert));
2051 set_processor_ui (plugin_insert, plugin_ui);
2054 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
2055 plugin_ui->set_parent (win);
2060 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
2062 if (!_session->engine().connected()) {
2063 MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible"));
2068 PortInsertWindow *io_selector;
2070 Window* w = get_processor_ui (port_insert);
2073 io_selector = new PortInsertWindow (_session, port_insert);
2074 set_processor_ui (port_insert, io_selector);
2077 io_selector = dynamic_cast<PortInsertWindow *> (w);
2080 gidget = io_selector;
2084 if (gidget->is_visible()) {
2087 gidget->show_all ();
2094 ProcessorBox::register_actions ()
2096 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("ProcessorMenu"));
2097 Glib::RefPtr<Action> act;
2100 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin"),
2101 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
2103 act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"),
2104 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
2105 ActionManager::jack_sensitive_actions.push_back (act);
2106 act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New External Send ..."),
2107 sigc::ptr_fun (ProcessorBox::rb_choose_send));
2108 ActionManager::jack_sensitive_actions.push_back (act);
2110 ActionManager::register_action (popup_act_grp, X_("newaux"), _("New Aux Send ..."));
2112 ActionManager::register_action (popup_act_grp, X_("controls"), _("Controls"));
2114 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear (all)"),
2115 sigc::ptr_fun (ProcessorBox::rb_clear));
2116 ActionManager::register_action (popup_act_grp, X_("clear_pre"), _("Clear (pre-fader)"),
2117 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
2118 ActionManager::register_action (popup_act_grp, X_("clear_post"), _("Clear (post-fader)"),
2119 sigc::ptr_fun (ProcessorBox::rb_clear_post));
2121 /* standard editing stuff */
2122 cut_action = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"),
2123 sigc::ptr_fun (ProcessorBox::rb_cut));
2124 ActionManager::plugin_selection_sensitive_actions.push_back(cut_action);
2125 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),
2126 sigc::ptr_fun (ProcessorBox::rb_copy));
2127 ActionManager::plugin_selection_sensitive_actions.push_back(act);
2129 act = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"),
2130 sigc::ptr_fun (ProcessorBox::rb_delete));
2131 ActionManager::plugin_selection_sensitive_actions.push_back(act); // ??
2133 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"),
2134 sigc::ptr_fun (ProcessorBox::rb_paste));
2135 rename_action = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"),
2136 sigc::ptr_fun (ProcessorBox::rb_rename));
2137 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"),
2138 sigc::ptr_fun (ProcessorBox::rb_select_all));
2139 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"),
2140 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
2142 /* activation etc. */
2144 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate All"),
2145 sigc::ptr_fun (ProcessorBox::rb_activate_all));
2146 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate All"),
2147 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
2148 ActionManager::register_action (popup_act_grp, X_("ab_plugins"), _("A/B Plugins"),
2149 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
2152 edit_action = ActionManager::register_action (
2153 popup_act_grp, X_("edit"), _("Edit..."),
2154 sigc::ptr_fun (ProcessorBox::rb_edit));
2156 ActionManager::add_action_group (popup_act_grp);
2160 ProcessorBox::rb_ab_plugins ()
2162 if (_current_processor_box == 0) {
2166 _current_processor_box->ab_plugins ();
2170 ProcessorBox::rb_choose_plugin ()
2172 if (_current_processor_box == 0) {
2175 _current_processor_box->choose_plugin ();
2179 ProcessorBox::rb_choose_insert ()
2181 if (_current_processor_box == 0) {
2184 _current_processor_box->choose_insert ();
2188 ProcessorBox::rb_choose_send ()
2190 if (_current_processor_box == 0) {
2193 _current_processor_box->choose_send ();
2197 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
2199 if (_current_processor_box == 0) {
2203 _current_processor_box->choose_aux (wr);
2207 ProcessorBox::rb_clear ()
2209 if (_current_processor_box == 0) {
2213 _current_processor_box->clear_processors ();
2218 ProcessorBox::rb_clear_pre ()
2220 if (_current_processor_box == 0) {
2224 _current_processor_box->clear_processors (PreFader);
2229 ProcessorBox::rb_clear_post ()
2231 if (_current_processor_box == 0) {
2235 _current_processor_box->clear_processors (PostFader);
2239 ProcessorBox::rb_cut ()
2241 if (_current_processor_box == 0) {
2245 _current_processor_box->processor_operation (ProcessorsCut);
2249 ProcessorBox::rb_delete ()
2251 if (_current_processor_box == 0) {
2255 _current_processor_box->processor_operation (ProcessorsDelete);
2259 ProcessorBox::rb_copy ()
2261 if (_current_processor_box == 0) {
2264 _current_processor_box->processor_operation (ProcessorsCopy);
2268 ProcessorBox::rb_paste ()
2270 if (_current_processor_box == 0) {
2274 _current_processor_box->processor_operation (ProcessorsPaste);
2278 ProcessorBox::rb_rename ()
2280 if (_current_processor_box == 0) {
2283 _current_processor_box->rename_processors ();
2287 ProcessorBox::rb_select_all ()
2289 if (_current_processor_box == 0) {
2293 _current_processor_box->processor_operation (ProcessorsSelectAll);
2297 ProcessorBox::rb_deselect_all ()
2299 if (_current_processor_box == 0) {
2303 _current_processor_box->deselect_all_processors ();
2307 ProcessorBox::rb_activate_all ()
2309 if (_current_processor_box == 0) {
2313 _current_processor_box->all_visible_processors_active (true);
2317 ProcessorBox::rb_deactivate_all ()
2319 if (_current_processor_box == 0) {
2322 _current_processor_box->all_visible_processors_active (false);
2326 ProcessorBox::rb_edit ()
2328 if (_current_processor_box == 0) {
2332 _current_processor_box->for_selected_processors (&ProcessorBox::toggle_edit_processor);
2336 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
2338 if (!what_changed.contains (ARDOUR::Properties::name)) {
2342 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
2344 boost::shared_ptr<Processor> processor;
2345 boost::shared_ptr<PluginInsert> plugin_insert;
2346 boost::shared_ptr<Send> send;
2348 list<ProcessorEntry*> children = processor_display.children();
2350 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
2352 processor = (*iter)->processor ();
2358 Window* w = get_processor_ui (processor);
2364 /* rename editor windows for sends and plugins */
2366 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
2367 w->set_title (send->name ());
2368 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
2369 w->set_title (generate_processor_title (plugin_insert));
2375 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
2377 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
2378 string::size_type email_pos;
2380 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
2381 maker = maker.substr (0, email_pos - 1);
2384 if (maker.length() > 32) {
2385 maker = maker.substr (0, 32);
2389 return string_compose(_("%1: %2 (by %3)"), _route->name(), pi->name(), maker);
2393 ProcessorBox::on_size_allocate (Allocation& a)
2395 HBox::on_size_allocate (a);
2397 list<ProcessorEntry*> children = processor_display.children ();
2398 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
2399 (*i)->set_pixel_width (a.get_width ());
2403 /** @param p Processor.
2404 * @return the UI window for \a p.
2407 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
2409 list<ProcessorWindowProxy*>::const_iterator i = _processor_window_proxies.begin ();
2410 while (i != _processor_window_proxies.end()) {
2411 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2413 return (*i)->get ();
2422 /** Make a note of the UI window that a processor is using.
2423 * @param p Processor.
2424 * @param w UI window.
2427 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
2429 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin ();
2433 while (i != _processor_window_proxies.end()) {
2434 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2443 /* we shouldn't get here, because the ProcessorUIList should always contain
2444 an entry for each processor.
2450 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
2452 boost::shared_ptr<Delivery> d = w.lock ();
2457 list<ProcessorEntry*> children = processor_display.children ();
2458 list<ProcessorEntry*>::const_iterator i = children.begin();
2459 while (i != children.end() && (*i)->processor() != d) {
2463 if (i == children.end()) {
2464 processor_display.set_active (0);
2466 processor_display.set_active (*i);
2470 /** Called to repair the damage of Editor::show_window doing a show_all() */
2472 ProcessorBox::hide_things ()
2474 list<ProcessorEntry*> c = processor_display.children ();
2475 for (list<ProcessorEntry*>::iterator i = c.begin(); i != c.end(); ++i) {
2476 (*i)->hide_things ();
2481 ProcessorBox::processor_menu_unmapped ()
2483 processor_display.remove_placeholder ();
2487 ProcessorBox::entry_gui_object_state (ProcessorEntry* entry)
2489 if (!_parent_strip) {
2493 GUIObjectState& st = _parent_strip->gui_object_state ();
2495 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
2497 return st.get_or_add_node (strip, entry->state_id());
2501 ProcessorBox::update_gui_object_state (ProcessorEntry* entry)
2503 XMLNode* proc = entry_gui_object_state (entry);
2508 /* XXX: this is a bit inefficient; we just remove all child nodes and re-add them */
2509 proc->remove_nodes_and_delete (X_("Object"));
2510 entry->add_control_state (proc);
2513 ProcessorWindowProxy::ProcessorWindowProxy (
2514 string const & name,
2515 XMLNode const * node,
2517 boost::weak_ptr<Processor> processor
2519 : WindowProxy<Gtk::Window> (name, node)
2521 , _processor_box (box)
2522 , _processor (processor)
2529 ProcessorWindowProxy::show ()
2531 boost::shared_ptr<Processor> p = _processor.lock ();
2536 _processor_box->toggle_edit_processor (p);