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 box.pack_start (_label);
437 _label.set_text (_name);
438 box.pack_start (_slider);
441 double const lo = c->internal_to_interface (c->lower ());
442 double const up = c->internal_to_interface (c->upper ());
444 _adjustment.set_lower (lo);
445 _adjustment.set_upper (up);
446 _adjustment.set_step_increment ((up - lo) / 100);
447 _adjustment.set_page_increment ((up - lo) / 10);
448 _slider.set_default_value (c->internal_to_interface (c->normal ()));
450 _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &Control::slider_adjusted));
451 c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
454 ARDOUR_UI::RapidScreenUpdate.connect (sigc::mem_fun (*this, &Control::control_changed));
459 /* We're providing our own PersistentTooltip */
460 set_no_tooltip_whatsoever (_slider);
464 ProcessorEntry::Control::set_tooltip ()
466 boost::shared_ptr<AutomationControl> c = _control.lock ();
475 s << (c->get_value() > 0.5 ? _("on") : _("off"));
477 s << setprecision(2) << fixed;
478 s << c->internal_to_user (c->get_value ());
481 ARDOUR_UI::instance()->set_tip (_label, s.str ());
482 _slider_persistant_tooltip.set_tip (s.str ());
483 ARDOUR_UI::instance()->set_tip (_button, s.str ());
487 ProcessorEntry::Control::set_pixel_width (int p)
489 _slider.set_fader_length (p);
493 ProcessorEntry::Control::slider_adjusted ()
495 if (_ignore_ui_adjustment) {
499 boost::shared_ptr<AutomationControl> c = _control.lock ();
505 c->set_value (c->interface_to_internal (_adjustment.get_value ()));
510 ProcessorEntry::Control::button_clicked ()
512 boost::shared_ptr<AutomationControl> c = _control.lock ();
518 bool const n = _button.get_active ();
520 c->set_value (n ? 0 : 1);
521 _button.set_active (!n);
525 ProcessorEntry::Control::control_changed ()
527 boost::shared_ptr<AutomationControl> c = _control.lock ();
532 _ignore_ui_adjustment = true;
536 _button.set_active (c->get_value() > 0.5);
540 _adjustment.set_value (c->internal_to_interface (c->get_value ()));
544 s.setf (ios::fixed, ios::floatfield);
545 s << c->internal_to_user (c->get_value ());
548 _ignore_ui_adjustment = false;
552 ProcessorEntry::Control::add_state (XMLNode* node) const
554 XMLNode* c = new XMLNode (X_("Object"));
555 c->add_property (X_("id"), state_id ());
556 c->add_property (X_("visible"), _visible);
557 node->add_child_nocopy (*c);
561 ProcessorEntry::Control::set_state (XMLNode const * node)
563 XMLNode* n = GUIObjectState::get_node (node, state_id ());
565 XMLProperty* p = n->property (X_("visible"));
566 set_visible (p && string_is_affirmative (p->value ()));
573 ProcessorEntry::Control::set_visible (bool v)
584 /** Called when the Editor might have re-shown things that
588 ProcessorEntry::Control::hide_things ()
596 ProcessorEntry::Control::hide_label ()
602 ProcessorEntry::Control::state_id () const
604 boost::shared_ptr<AutomationControl> c = _control.lock ();
607 return string_compose (X_("control %1"), c->id().to_s ());
610 BlankProcessorEntry::BlankProcessorEntry (ProcessorBox* b, Width w)
611 : ProcessorEntry (b, boost::shared_ptr<Processor>(), w)
615 PluginInsertProcessorEntry::PluginInsertProcessorEntry (ProcessorBox* b, boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
616 : ProcessorEntry (b, p, w)
619 p->SplittingChanged.connect (
620 _splitting_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::plugin_insert_splitting_changed, this), gui_context()
623 _splitting_icon.set_size_request (-1, 12);
625 _vbox.pack_start (_splitting_icon);
626 _vbox.reorder_child (_splitting_icon, 0);
628 plugin_insert_splitting_changed ();
632 PluginInsertProcessorEntry::plugin_insert_splitting_changed ()
634 if (_plugin_insert->splitting ()) {
635 _splitting_icon.show ();
637 _splitting_icon.hide ();
642 PluginInsertProcessorEntry::hide_things ()
644 ProcessorEntry::hide_things ();
645 plugin_insert_splitting_changed ();
649 PluginInsertProcessorEntry::setup_visuals ()
653 _splitting_icon.set_name ("ProcessorPreFader");
657 _splitting_icon.set_name ("ProcessorFader");
661 _splitting_icon.set_name ("ProcessorPostFader");
665 ProcessorEntry::setup_visuals ();
669 PluginInsertProcessorEntry::SplittingIcon::on_expose_event (GdkEventExpose* ev)
671 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
673 cairo_set_line_width (cr, 1);
675 double const width = ev->area.width;
676 double const height = ev->area.height;
678 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
679 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
681 cairo_rectangle (cr, 0, 0, width, height);
684 Gdk::Color const fg = get_style()->get_fg (STATE_NORMAL);
685 cairo_set_source_rgb (cr, fg.get_red_p (), fg.get_green_p (), fg.get_blue_p ());
687 cairo_move_to (cr, width * 0.3, height);
688 cairo_line_to (cr, width * 0.3, height * 0.5);
689 cairo_line_to (cr, width * 0.7, height * 0.5);
690 cairo_line_to (cr, width * 0.7, height);
691 cairo_move_to (cr, width * 0.5, height * 0.5);
692 cairo_line_to (cr, width * 0.5, 0);
698 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
699 RouteProcessorSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
700 : _parent_strip (parent)
701 , _owner_is_mixer (owner_is_mixer)
702 , ab_direction (true)
703 , _get_plugin_selector (get_plugin_selector)
705 , _visible_prefader_processors (0)
706 , _rr_selection(rsel)
712 no_processor_redisplay = false;
714 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
715 processor_scroller.add (processor_display);
716 pack_start (processor_scroller, true, true);
718 processor_display.set_flags (CAN_FOCUS);
719 processor_display.set_name ("ProcessorList");
720 processor_display.set_size_request (48, -1);
721 processor_display.set_data ("processorbox", this);
722 processor_display.set_spacing (2);
724 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
725 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
727 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
728 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
730 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
731 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
733 processor_scroller.show ();
734 processor_display.show ();
737 parent->DeliveryChanged.connect (
738 _mixer_strip_connections, invalidator (*this), boost::bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
742 ARDOUR_UI::instance()->set_tip (processor_display, _("Right-click to add/remove/edit\nplugins,inserts,sends and more"));
745 ProcessorBox::~ProcessorBox ()
747 /* it may appear as if we should delete processor_menu but that is a
748 * pointer to a widget owned by the UI Manager, and has potentially
749 * be returned to many other ProcessorBoxes. GTK doesn't really make
750 * clear the ownership of this widget, which is a menu and thus is
751 * never packed into any container other than an implict GtkWindow.
753 * For now, until or if we ever get clarification over the ownership
754 * story just let it continue to exist. At worst, its a small memory leak.
759 ProcessorBox::set_route (boost::shared_ptr<Route> r)
765 _route_connections.drop_connections();
767 /* new route: any existing block on processor redisplay must be meaningless */
768 no_processor_redisplay = false;
771 _route->processors_changed.connect (
772 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
775 _route->DropReferences.connect (
776 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
779 _route->PropertyChanged.connect (
780 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
783 redisplay_processors ();
787 ProcessorBox::route_going_away ()
789 /* don't keep updating display as processors are deleted */
790 no_processor_redisplay = true;
795 ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
797 boost::shared_ptr<Processor> p;
799 p = position->processor ();
801 /* dropped on the blank entry (which will be before the
802 fader), so use the first non-blank child as our
803 `dropped on' processor */
804 list<ProcessorEntry*> c = processor_display.children ();
805 list<ProcessorEntry*>::iterator i = c.begin ();
806 while (dynamic_cast<BlankProcessorEntry*> (*i)) {
807 assert (i != c.end ());
811 assert (i != c.end ());
812 p = (*i)->processor ();
817 list<ProcessorEntry*> children = source->selection ();
818 list<boost::shared_ptr<Processor> > procs;
819 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
820 if ((*i)->processor ()) {
821 procs.push_back ((*i)->processor ());
825 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
826 XMLNode& state = (*i)->get_state ();
828 nlist.push_back (&state);
829 paste_processor_state (nlist, p);
833 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
837 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
838 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
840 other->delete_dragged_processors (procs);
846 ProcessorBox::set_width (Width w)
854 list<ProcessorEntry*> children = processor_display.children ();
855 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
856 (*i)->set_enum_width (w);
859 redisplay_processors ();
863 ProcessorBox::build_possible_aux_menu ()
865 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
868 /* No aux sends if there are no busses */
872 using namespace Menu_Helpers;
873 Menu* menu = manage (new Menu);
874 MenuList& items = menu->items();
876 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
877 if (!_route->internal_send_for (*r) && *r != _route) {
878 items.push_back (MenuElem ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
886 ProcessorBox::show_processor_menu (int arg)
888 if (processor_menu == 0) {
889 processor_menu = build_processor_menu ();
890 processor_menu->signal_unmap().connect (sigc::mem_fun (*this, &ProcessorBox::processor_menu_unmapped));
893 /* Sort out the plugin submenu */
895 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newplugin"));
897 if (plugin_menu_item) {
898 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
901 /* And the aux submenu */
903 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newaux"));
906 Menu* m = build_possible_aux_menu();
907 if (m && !m->items().empty()) {
908 aux_menu_item->set_submenu (*m);
909 aux_menu_item->set_sensitive (true);
911 /* stupid gtkmm: we need to pass a null reference here */
912 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
913 aux_menu_item->set_sensitive (false);
917 ProcessorEntry* single_selection = 0;
918 if (processor_display.selection().size() == 1) {
919 single_selection = processor_display.selection().front();
922 /* And the controls submenu */
924 Gtk::MenuItem* controls_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/controls"));
926 if (controls_menu_item) {
927 if (single_selection) {
928 Menu* m = single_selection->build_controls_menu ();
929 if (m && !m->items().empty()) {
930 controls_menu_item->set_submenu (*m);
931 controls_menu_item->set_sensitive (true);
933 gtk_menu_item_set_submenu (controls_menu_item->gobj(), 0);
934 controls_menu_item->set_sensitive (false);
939 /* Sensitise actions as approprioate */
941 cut_action->set_sensitive (can_cut());
942 paste_action->set_sensitive (!_rr_selection.processors.empty());
944 const bool sensitive = !processor_display.selection().empty();
945 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
946 edit_action->set_sensitive (one_processor_can_be_edited ());
948 boost::shared_ptr<PluginInsert> pi;
949 if (single_selection) {
950 pi = boost::dynamic_pointer_cast<PluginInsert> (single_selection->processor ());
953 /* allow editing with an Ardour-generated UI for plugin inserts with editors */
954 edit_generic_action->set_sensitive (pi && pi->plugin()->has_editor ());
956 /* disallow rename for multiple selections, for plugin inserts and for the fader */
957 rename_action->set_sensitive (single_selection && !pi && !boost::dynamic_pointer_cast<Amp> (single_selection->processor ()));
959 processor_menu->popup (1, arg);
961 /* Add a placeholder gap to the processor list to indicate where a processor would be
962 inserted were one chosen from the menu.
965 processor_display.get_pointer (x, y);
966 _placement = processor_display.add_placeholder (y);
968 if (_visible_prefader_processors == 0 && _placement > 0) {
974 ProcessorBox::enter_notify (GdkEventCrossing*)
976 _current_processor_box = this;
981 ProcessorBox::leave_notify (GdkEventCrossing*)
987 ProcessorBox::processor_operation (ProcessorOperation op)
989 ProcSelection targets;
991 get_selected_processors (targets);
993 if (targets.empty()) {
996 processor_display.get_pointer (x, y);
998 pair<ProcessorEntry *, double> const pointer = processor_display.get_child_at_position (y);
1000 if (pointer.first && pointer.first->processor()) {
1001 targets.push_back (pointer.first->processor ());
1006 case ProcessorsSelectAll:
1007 processor_display.select_all ();
1010 case ProcessorsCopy:
1011 copy_processors (targets);
1015 cut_processors (targets);
1018 case ProcessorsPaste:
1019 if (targets.empty()) {
1020 paste_processors ();
1022 paste_processors (targets.front());
1026 case ProcessorsDelete:
1027 delete_processors (targets);
1030 case ProcessorsToggleActive:
1031 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
1032 if ((*i)->active()) {
1033 (*i)->deactivate ();
1050 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
1052 boost::shared_ptr<Processor> processor;
1054 processor = child->processor ();
1058 bool selected = processor_display.selected (child);
1060 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
1062 if (_session->engine().connected()) {
1063 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
1064 if (Config->get_use_plugin_own_gui ()) {
1065 toggle_edit_processor (processor);
1067 toggle_edit_generic_processor (processor);
1072 } else if (processor && ev->button == 1 && selected) {
1074 // this is purely informational but necessary for route params UI
1075 ProcessorSelected (processor); // emit
1077 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
1080 _get_plugin_selector()->show_manager ();
1087 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
1089 boost::shared_ptr<Processor> processor;
1091 processor = child->processor ();
1094 if (processor && Keyboard::is_delete_event (ev)) {
1096 Glib::signal_idle().connect (sigc::bind (
1097 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
1098 boost::weak_ptr<Processor>(processor)));
1100 } else if (Keyboard::is_context_menu_event (ev)) {
1102 show_processor_menu (ev->time);
1104 } else if (processor && Keyboard::is_button2_event (ev)
1106 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
1110 /* button2-click with no/appropriate modifiers */
1112 if (processor->active()) {
1113 processor->deactivate ();
1115 processor->activate ();
1123 ProcessorBox::build_processor_menu ()
1125 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/ProcessorMenu") );
1126 processor_menu->set_name ("ArdourContextMenu");
1127 return processor_menu;
1131 ProcessorBox::select_all_processors ()
1133 processor_display.select_all ();
1137 ProcessorBox::deselect_all_processors ()
1139 processor_display.select_none ();
1143 ProcessorBox::choose_plugin ()
1145 _get_plugin_selector()->set_interested_object (*this);
1148 /** @return true if an error occurred, otherwise false */
1150 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
1152 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
1154 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
1156 Route::ProcessorStreams err_streams;
1158 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
1159 weird_plugin_dialog (**p, err_streams);
1161 // XXX SHAREDPTR delete plugin here .. do we even need to care?
1164 if (Profile->get_sae()) {
1165 processor->activate ();
1174 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
1176 ArdourDialog dialog (_("Plugin Incompatibility"));
1179 string text = string_compose(_("You attempted to add the plugin \"%1\" in slot %2.\n"),
1180 p.name(), streams.index);
1182 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
1183 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
1185 text += _("\nThis plugin has:\n");
1187 uint32_t const n = p.get_info()->n_inputs.n_midi ();
1188 text += string_compose (ngettext ("\t%1 MIDI input\n", "\t%1 MIDI inputs\n", n), n);
1191 uint32_t const n = p.get_info()->n_inputs.n_audio ();
1192 text += string_compose (ngettext ("\t%1 audio input\n", "\t%1 audio inputs\n", n), n);
1195 text += _("\nbut at the insertion point, there are:\n");
1197 uint32_t const n = streams.count.n_midi ();
1198 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
1201 uint32_t const n = streams.count.n_audio ();
1202 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
1205 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
1206 label.set_text(text);
1208 dialog.get_vbox()->pack_start (label);
1209 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1211 dialog.set_name (X_("PluginIODialog"));
1212 dialog.set_position (Gtk::WIN_POS_MOUSE);
1213 dialog.set_modal (true);
1220 ProcessorBox::choose_insert ()
1222 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->pannable(), _route->mute_master()));
1223 _route->add_processor_by_index (processor, _placement);
1226 /* Caller must not hold process lock */
1228 ProcessorBox::choose_send ()
1230 boost::shared_ptr<Send> send (new Send (*_session, _route->pannable(), _route->mute_master()));
1232 /* make an educated guess at the initial number of outputs for the send */
1233 ChanCount outs = (_session->master_out())
1234 ? _session->master_out()->n_outputs()
1235 : _route->n_outputs();
1237 /* XXX need processor lock on route */
1239 Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock());
1240 send->output()->ensure_io (outs, false, this);
1241 } catch (AudioEngine::PortRegistrationFailure& err) {
1242 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
1246 /* let the user adjust the IO setup before creation.
1248 Note: this dialog is NOT modal - we just leave it to run and it will
1249 return when its Finished signal is emitted - typically when the window
1253 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
1256 /* keep a reference to the send so it doesn't get deleted while
1257 the IOSelectorWindow is doing its stuff
1259 _processor_being_created = send;
1261 ios->selector().Finished.connect (sigc::bind (
1262 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
1263 boost::weak_ptr<Processor>(send), ios));
1268 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1270 boost::shared_ptr<Processor> processor (weak_processor.lock());
1272 /* drop our temporary reference to the new send */
1273 _processor_being_created.reset ();
1280 case IOSelector::Cancelled:
1281 // processor will go away when all shared_ptrs to it vanish
1284 case IOSelector::Accepted:
1285 _route->add_processor_by_index (processor, _placement);
1286 if (Profile->get_sae()) {
1287 processor->activate ();
1292 delete_when_idle (ios);
1296 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1298 boost::shared_ptr<Processor> processor (weak_processor.lock());
1300 /* drop our temporary reference to the new return */
1301 _processor_being_created.reset ();
1308 case IOSelector::Cancelled:
1309 // processor will go away when all shared_ptrs to it vanish
1312 case IOSelector::Accepted:
1313 _route->add_processor_by_index (processor, _placement);
1314 if (Profile->get_sae()) {
1315 processor->activate ();
1320 delete_when_idle (ios);
1324 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
1330 boost::shared_ptr<Route> target = wr.lock();
1336 _session->add_internal_send (target, _placement, _route);
1340 ProcessorBox::route_processors_changed (RouteProcessorChange c)
1342 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
1343 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
1347 redisplay_processors ();
1351 ProcessorBox::redisplay_processors ()
1353 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors);
1356 if (no_processor_redisplay) {
1360 processor_display.clear ();
1362 _visible_prefader_processors = 0;
1365 _route->foreach_processor (sigc::bind (sigc::mem_fun (*this, &ProcessorBox::help_count_visible_prefader_processors),
1366 &_visible_prefader_processors, &fader_seen));
1368 if (_visible_prefader_processors == 0) { // fader only
1369 BlankProcessorEntry* bpe = new BlankProcessorEntry (this, _width);
1370 bpe->set_pixel_width (get_allocation().get_width());
1371 processor_display.add_child (bpe);
1374 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
1376 for (list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin(); i != _processor_window_proxies.end(); ++i) {
1377 (*i)->marked = false;
1380 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
1382 /* trim dead wood from the processor window proxy list */
1384 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin();
1385 while (i != _processor_window_proxies.end()) {
1386 list<ProcessorWindowProxy*>::iterator j = i;
1389 if (!(*i)->marked) {
1390 ARDOUR_UI::instance()->remove_window_proxy (*i);
1392 _processor_window_proxies.erase (i);
1398 setup_entry_positions ();
1401 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
1402 * not already have one.
1405 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
1407 boost::shared_ptr<Processor> p = w.lock ();
1412 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin ();
1413 while (i != _processor_window_proxies.end()) {
1415 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
1418 /* this processor is already on the list; done */
1419 (*i)->marked = true;
1426 /* not on the list; add it */
1429 if (_parent_strip) {
1430 if (_parent_strip->mixer_owned()) {
1439 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
1440 string_compose ("%1-%2-%3", loc, _route->id(), p->id()),
1441 _session->extra_xml (X_("UI")),
1447 /* if the processor already has an existing UI,
1448 note that so that we don't recreate it
1451 void* existing_ui = p->get_ui ();
1454 wp->set (static_cast<Gtk::Window*>(existing_ui));
1457 _processor_window_proxies.push_back (wp);
1458 ARDOUR_UI::instance()->add_window_proxy (wp);
1462 ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor> p, uint32_t* cnt, bool* amp_seen)
1464 boost::shared_ptr<Processor> processor (p.lock ());
1466 if (processor && processor->display_to_user()) {
1468 if (boost::dynamic_pointer_cast<Amp>(processor)) {
1479 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
1481 boost::shared_ptr<Processor> processor (p.lock ());
1483 if (!processor || !processor->display_to_user()) {
1487 boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
1488 ProcessorEntry* e = 0;
1489 if (plugin_insert) {
1490 e = new PluginInsertProcessorEntry (this, plugin_insert, _width);
1492 e = new ProcessorEntry (this, processor, _width);
1495 e->set_pixel_width (get_allocation().get_width());
1497 /* Set up this entry's state from the GUIObjectState */
1498 XMLNode* proc = entry_gui_object_state (e);
1500 e->set_control_state (proc);
1503 if (boost::dynamic_pointer_cast<Send> (processor)) {
1504 /* Always show send controls */
1505 e->show_all_controls ();
1508 processor_display.add_child (e);
1512 ProcessorBox::reordered ()
1514 compute_processor_sort_keys ();
1515 setup_entry_positions ();
1519 ProcessorBox::setup_entry_positions ()
1521 list<ProcessorEntry*> children = processor_display.children ();
1522 bool pre_fader = true;
1524 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1525 if (boost::dynamic_pointer_cast<Amp>((*i)->processor())) {
1527 (*i)->set_position (ProcessorEntry::Fader);
1530 (*i)->set_position (ProcessorEntry::PreFader);
1532 (*i)->set_position (ProcessorEntry::PostFader);
1539 ProcessorBox::compute_processor_sort_keys ()
1541 list<ProcessorEntry*> children = processor_display.children ();
1542 Route::ProcessorList our_processors;
1544 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1545 if ((*i)->processor()) {
1546 our_processors.push_back ((*i)->processor ());
1550 if (_route->reorder_processors (our_processors)) {
1551 /* Reorder failed, so report this to the user. As far as I can see this must be done
1552 in an idle handler: it seems that the redisplay_processors() that happens below destroys
1553 widgets that were involved in the drag-and-drop on the processor list, which causes problems
1554 when the drag is torn down after this handler function is finished.
1556 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
1561 ProcessorBox::report_failed_reorder ()
1563 /* reorder failed, so redisplay */
1565 redisplay_processors ();
1567 /* now tell them about the problem */
1569 ArdourDialog dialog (_("Plugin Incompatibility"));
1572 label.set_text (_("\
1573 You cannot reorder these plugins/sends/inserts\n\
1574 in that way because the inputs and\n\
1575 outputs will not work correctly."));
1577 dialog.get_vbox()->set_border_width (12);
1578 dialog.get_vbox()->pack_start (label);
1579 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1581 dialog.set_name (X_("PluginIODialog"));
1582 dialog.set_position (Gtk::WIN_POS_MOUSE);
1583 dialog.set_modal (true);
1590 ProcessorBox::rename_processors ()
1592 ProcSelection to_be_renamed;
1594 get_selected_processors (to_be_renamed);
1596 if (to_be_renamed.empty()) {
1600 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
1601 rename_processor (*i);
1606 ProcessorBox::can_cut () const
1608 vector<boost::shared_ptr<Processor> > sel;
1610 get_selected_processors (sel);
1612 /* cut_processors () does not cut inserts */
1614 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
1616 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1617 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1618 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1627 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
1629 if (to_be_removed.empty()) {
1633 XMLNode* node = new XMLNode (X_("cut"));
1634 Route::ProcessorList to_cut;
1636 no_processor_redisplay = true;
1637 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
1638 // Cut only plugins, sends and returns
1639 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1640 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1641 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1643 Window* w = get_processor_ui (*i);
1649 XMLNode& child ((*i)->get_state());
1650 node->add_child_nocopy (child);
1651 to_cut.push_back (*i);
1655 if (_route->remove_processors (to_cut) != 0) {
1657 no_processor_redisplay = false;
1661 _rr_selection.set (node);
1663 no_processor_redisplay = false;
1664 redisplay_processors ();
1668 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
1670 if (to_be_copied.empty()) {
1674 XMLNode* node = new XMLNode (X_("copy"));
1676 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
1677 // Copy only plugins, sends, returns
1678 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1679 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1680 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1681 node->add_child_nocopy ((*i)->get_state());
1685 _rr_selection.set (node);
1689 ProcessorBox::delete_processors (const ProcSelection& targets)
1691 if (targets.empty()) {
1695 no_processor_redisplay = true;
1697 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
1699 Window* w = get_processor_ui (*i);
1705 _route->remove_processor(*i);
1708 no_processor_redisplay = false;
1709 redisplay_processors ();
1713 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
1715 list<boost::shared_ptr<Processor> >::const_iterator x;
1717 no_processor_redisplay = true;
1718 for (x = procs.begin(); x != procs.end(); ++x) {
1720 Window* w = get_processor_ui (*x);
1726 _route->remove_processor(*x);
1729 no_processor_redisplay = false;
1730 redisplay_processors ();
1734 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
1736 boost::shared_ptr<Processor> processor (weak_processor.lock());
1742 /* NOT copied to _mixer.selection() */
1744 no_processor_redisplay = true;
1745 _route->remove_processor (processor);
1746 no_processor_redisplay = false;
1747 redisplay_processors ();
1753 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
1755 ArdourPrompter name_prompter (true);
1757 name_prompter.set_title (_("Rename Processor"));
1758 name_prompter.set_prompt (_("New name:"));
1759 name_prompter.set_initial_text (processor->name());
1760 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
1761 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
1762 name_prompter.show_all ();
1764 switch (name_prompter.run ()) {
1766 case Gtk::RESPONSE_ACCEPT:
1767 name_prompter.get_result (result);
1768 if (result.length()) {
1771 string test = result;
1773 while (tries < 100) {
1774 if (_session->io_name_is_legal (test)) {
1780 test = string_compose ("%1-%2", result, tries);
1784 processor->set_name (result);
1787 ARDOUR_UI::instance()->popup_error
1788 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
1798 ProcessorBox::paste_processors ()
1800 if (_rr_selection.processors.empty()) {
1804 paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
1808 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
1811 if (_rr_selection.processors.empty()) {
1815 paste_processor_state (_rr_selection.processors.get_node().children(), before);
1819 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
1821 XMLNodeConstIterator niter;
1822 list<boost::shared_ptr<Processor> > copies;
1824 if (nlist.empty()) {
1828 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1830 XMLProperty const * type = (*niter)->property ("type");
1833 boost::shared_ptr<Processor> p;
1835 if (type->value() == "meter" ||
1836 type->value() == "main-outs" ||
1837 type->value() == "amp" ||
1838 type->value() == "intsend" || type->value() == "intreturn") {
1839 /* do not paste meter, main outs, amp or internal send/returns */
1842 } else if (type->value() == "send") {
1844 XMLNode n (**niter);
1845 Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
1847 IOProcessor::prepare_for_reset (n, s->name());
1849 if (s->set_state (n, Stateful::loading_state_version)) {
1856 } else if (type->value() == "return") {
1858 XMLNode n (**niter);
1859 Return* r = new Return (*_session);
1861 IOProcessor::prepare_for_reset (n, r->name());
1863 if (r->set_state (n, Stateful::loading_state_version)) {
1870 } else if (type->value() == "port") {
1872 XMLNode n (**niter);
1873 PortInsert* pi = new PortInsert (*_session, _route->pannable (), _route->mute_master ());
1875 IOProcessor::prepare_for_reset (n, pi->name());
1877 if (pi->set_state (n, Stateful::loading_state_version)) {
1884 /* XXX its a bit limiting to assume that everything else
1888 p.reset (new PluginInsert (*_session));
1889 p->set_state (**niter, Stateful::current_state_version);
1892 copies.push_back (p);
1896 error << _("plugin insert constructor failed") << endmsg;
1900 if (copies.empty()) {
1904 if (_route->add_processors (copies, p)) {
1907 "Copying the set of processors on the clipboard failed,\n\
1908 probably because the I/O configuration of the plugins\n\
1909 could not match the configuration of this track.");
1910 MessageDialog am (msg);
1916 ProcessorBox::get_selected_processors (ProcSelection& processors) const
1918 const list<ProcessorEntry*> selection = processor_display.selection ();
1919 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
1920 processors.push_back ((*i)->processor ());
1925 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
1927 list<ProcessorEntry*> selection = processor_display.selection ();
1928 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
1929 (this->*method) ((*i)->processor ());
1934 ProcessorBox::all_visible_processors_active (bool state)
1936 _route->all_visible_processors_active (state);
1940 ProcessorBox::ab_plugins ()
1942 _route->ab_plugins (ab_direction);
1943 ab_direction = !ab_direction;
1948 ProcessorBox::clear_processors ()
1951 vector<string> choices;
1953 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
1954 "(this cannot be undone)"), _route->name());
1956 choices.push_back (_("Cancel"));
1957 choices.push_back (_("Yes, remove them all"));
1959 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1961 if (prompter.run () == 1) {
1962 _route->clear_processors (PreFader);
1963 _route->clear_processors (PostFader);
1968 ProcessorBox::clear_processors (Placement p)
1971 vector<string> choices;
1973 if (p == PreFader) {
1974 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
1975 "(this cannot be undone)"), _route->name());
1977 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
1978 "(this cannot be undone)"), _route->name());
1981 choices.push_back (_("Cancel"));
1982 choices.push_back (_("Yes, remove them all"));
1984 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1986 if (prompter.run () == 1) {
1987 _route->clear_processors (p);
1992 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
1994 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
1995 if (at && at->freeze_state() == AudioTrack::Frozen) {
2000 (boost::dynamic_pointer_cast<Send> (processor) && !boost::dynamic_pointer_cast<InternalSend> (processor))||
2001 boost::dynamic_pointer_cast<Return> (processor) ||
2002 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
2003 boost::dynamic_pointer_cast<PortInsert> (processor)
2012 ProcessorBox::one_processor_can_be_edited ()
2014 list<ProcessorEntry*> selection = processor_display.selection ();
2015 list<ProcessorEntry*>::iterator i = selection.begin();
2016 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
2020 return (i != selection.end());
2024 ProcessorBox::toggle_edit_processor (boost::shared_ptr<Processor> processor)
2026 boost::shared_ptr<Send> send;
2027 boost::shared_ptr<InternalSend> internal_send;
2028 boost::shared_ptr<Return> retrn;
2029 boost::shared_ptr<PluginInsert> plugin_insert;
2030 boost::shared_ptr<PortInsert> port_insert;
2033 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
2035 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
2040 if (boost::dynamic_pointer_cast<Amp> (processor)) {
2042 if (_parent_strip) {
2043 _parent_strip->revert_to_default_display ();
2046 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
2048 if (!_session->engine().connected()) {
2052 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
2053 SendUIWindow* w = new SendUIWindow (send, _session);
2056 /* assign internal send to main fader */
2057 if (_parent_strip) {
2058 if (_parent_strip->current_delivery() == send) {
2059 _parent_strip->revert_to_default_display ();
2061 _parent_strip->show_send(send);
2066 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
2068 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
2069 /* no GUI for these */
2073 if (!_session->engine().connected()) {
2077 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
2079 ReturnUIWindow *return_ui;
2080 Window* w = get_processor_ui (retrn);
2084 return_ui = new ReturnUIWindow (retrn, _session);
2085 return_ui->set_title (retrn->name ());
2086 set_processor_ui (send, return_ui);
2089 return_ui = dynamic_cast<ReturnUIWindow *> (w);
2094 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
2096 PluginUIWindow *plugin_ui;
2098 /* these are both allowed to be null */
2100 Container* toplevel = get_toplevel();
2101 Window* win = dynamic_cast<Gtk::Window*>(toplevel);
2103 Window* w = get_processor_ui (plugin_insert);
2107 plugin_ui = new PluginUIWindow (win, plugin_insert);
2108 plugin_ui->set_title (generate_processor_title (plugin_insert));
2109 set_processor_ui (plugin_insert, plugin_ui);
2112 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
2113 plugin_ui->set_parent (win);
2118 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
2120 if (!_session->engine().connected()) {
2121 MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible"));
2126 PortInsertWindow *io_selector;
2128 Window* w = get_processor_ui (port_insert);
2131 io_selector = new PortInsertWindow (_session, port_insert);
2132 set_processor_ui (port_insert, io_selector);
2135 io_selector = dynamic_cast<PortInsertWindow *> (w);
2138 gidget = io_selector;
2142 if (gidget->is_visible()) {
2145 gidget->show_all ();
2151 /** Toggle a generic (Ardour-generated) plugin UI */
2153 ProcessorBox::toggle_edit_generic_processor (boost::shared_ptr<Processor> processor)
2155 boost::shared_ptr<PluginInsert> plugin_insert
2156 = boost::dynamic_pointer_cast<PluginInsert>(processor);
2157 if (!plugin_insert) {
2161 Container* toplevel = get_toplevel();
2162 Window* win = dynamic_cast<Gtk::Window*>(toplevel);
2163 PluginUIWindow* plugin_ui = new PluginUIWindow(win, plugin_insert, true, false);
2164 plugin_ui->set_title(generate_processor_title (plugin_insert));
2166 if (plugin_ui->is_visible()) {
2169 plugin_ui->show_all();
2170 plugin_ui->present();
2175 ProcessorBox::register_actions ()
2177 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("ProcessorMenu"));
2178 Glib::RefPtr<Action> act;
2181 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin"),
2182 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
2184 act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"),
2185 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
2186 ActionManager::jack_sensitive_actions.push_back (act);
2187 act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New External Send ..."),
2188 sigc::ptr_fun (ProcessorBox::rb_choose_send));
2189 ActionManager::jack_sensitive_actions.push_back (act);
2191 ActionManager::register_action (popup_act_grp, X_("newaux"), _("New Aux Send ..."));
2193 ActionManager::register_action (popup_act_grp, X_("controls"), _("Controls"));
2195 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear (all)"),
2196 sigc::ptr_fun (ProcessorBox::rb_clear));
2197 ActionManager::register_action (popup_act_grp, X_("clear_pre"), _("Clear (pre-fader)"),
2198 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
2199 ActionManager::register_action (popup_act_grp, X_("clear_post"), _("Clear (post-fader)"),
2200 sigc::ptr_fun (ProcessorBox::rb_clear_post));
2202 /* standard editing stuff */
2203 cut_action = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"),
2204 sigc::ptr_fun (ProcessorBox::rb_cut));
2205 ActionManager::plugin_selection_sensitive_actions.push_back(cut_action);
2206 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),
2207 sigc::ptr_fun (ProcessorBox::rb_copy));
2208 ActionManager::plugin_selection_sensitive_actions.push_back(act);
2210 act = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"),
2211 sigc::ptr_fun (ProcessorBox::rb_delete));
2212 ActionManager::plugin_selection_sensitive_actions.push_back(act); // ??
2214 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"),
2215 sigc::ptr_fun (ProcessorBox::rb_paste));
2216 rename_action = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"),
2217 sigc::ptr_fun (ProcessorBox::rb_rename));
2218 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"),
2219 sigc::ptr_fun (ProcessorBox::rb_select_all));
2220 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"),
2221 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
2223 /* activation etc. */
2225 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate All"),
2226 sigc::ptr_fun (ProcessorBox::rb_activate_all));
2227 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate All"),
2228 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
2229 ActionManager::register_action (popup_act_grp, X_("ab_plugins"), _("A/B Plugins"),
2230 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
2233 edit_action = ActionManager::register_action (
2234 popup_act_grp, X_("edit"), _("Edit..."),
2235 sigc::ptr_fun (ProcessorBox::rb_edit));
2237 edit_generic_action = ActionManager::register_action (
2238 popup_act_grp, X_("edit-generic"), _("Edit with basic controls..."),
2239 sigc::ptr_fun (ProcessorBox::rb_edit_generic));
2241 ActionManager::add_action_group (popup_act_grp);
2245 ProcessorBox::rb_edit_generic ()
2247 if (_current_processor_box == 0) {
2251 _current_processor_box->for_selected_processors (&ProcessorBox::toggle_edit_generic_processor);
2255 ProcessorBox::rb_ab_plugins ()
2257 if (_current_processor_box == 0) {
2261 _current_processor_box->ab_plugins ();
2265 ProcessorBox::rb_choose_plugin ()
2267 if (_current_processor_box == 0) {
2270 _current_processor_box->choose_plugin ();
2274 ProcessorBox::rb_choose_insert ()
2276 if (_current_processor_box == 0) {
2279 _current_processor_box->choose_insert ();
2283 ProcessorBox::rb_choose_send ()
2285 if (_current_processor_box == 0) {
2288 _current_processor_box->choose_send ();
2292 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
2294 if (_current_processor_box == 0) {
2298 _current_processor_box->choose_aux (wr);
2302 ProcessorBox::rb_clear ()
2304 if (_current_processor_box == 0) {
2308 _current_processor_box->clear_processors ();
2313 ProcessorBox::rb_clear_pre ()
2315 if (_current_processor_box == 0) {
2319 _current_processor_box->clear_processors (PreFader);
2324 ProcessorBox::rb_clear_post ()
2326 if (_current_processor_box == 0) {
2330 _current_processor_box->clear_processors (PostFader);
2334 ProcessorBox::rb_cut ()
2336 if (_current_processor_box == 0) {
2340 _current_processor_box->processor_operation (ProcessorsCut);
2344 ProcessorBox::rb_delete ()
2346 if (_current_processor_box == 0) {
2350 _current_processor_box->processor_operation (ProcessorsDelete);
2354 ProcessorBox::rb_copy ()
2356 if (_current_processor_box == 0) {
2359 _current_processor_box->processor_operation (ProcessorsCopy);
2363 ProcessorBox::rb_paste ()
2365 if (_current_processor_box == 0) {
2369 _current_processor_box->processor_operation (ProcessorsPaste);
2373 ProcessorBox::rb_rename ()
2375 if (_current_processor_box == 0) {
2378 _current_processor_box->rename_processors ();
2382 ProcessorBox::rb_select_all ()
2384 if (_current_processor_box == 0) {
2388 _current_processor_box->processor_operation (ProcessorsSelectAll);
2392 ProcessorBox::rb_deselect_all ()
2394 if (_current_processor_box == 0) {
2398 _current_processor_box->deselect_all_processors ();
2402 ProcessorBox::rb_activate_all ()
2404 if (_current_processor_box == 0) {
2408 _current_processor_box->all_visible_processors_active (true);
2412 ProcessorBox::rb_deactivate_all ()
2414 if (_current_processor_box == 0) {
2417 _current_processor_box->all_visible_processors_active (false);
2421 ProcessorBox::rb_edit ()
2423 if (_current_processor_box == 0) {
2427 _current_processor_box->for_selected_processors (&ProcessorBox::toggle_edit_processor);
2431 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
2433 if (!what_changed.contains (ARDOUR::Properties::name)) {
2437 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
2439 boost::shared_ptr<Processor> processor;
2440 boost::shared_ptr<PluginInsert> plugin_insert;
2441 boost::shared_ptr<Send> send;
2443 list<ProcessorEntry*> children = processor_display.children();
2445 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
2447 processor = (*iter)->processor ();
2453 Window* w = get_processor_ui (processor);
2459 /* rename editor windows for sends and plugins */
2461 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
2462 w->set_title (send->name ());
2463 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
2464 w->set_title (generate_processor_title (plugin_insert));
2470 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
2472 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
2473 string::size_type email_pos;
2475 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
2476 maker = maker.substr (0, email_pos - 1);
2479 if (maker.length() > 32) {
2480 maker = maker.substr (0, 32);
2484 return string_compose(_("%1: %2 (by %3)"), _route->name(), pi->name(), maker);
2488 ProcessorBox::on_size_allocate (Allocation& a)
2490 HBox::on_size_allocate (a);
2492 list<ProcessorEntry*> children = processor_display.children ();
2493 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
2494 (*i)->set_pixel_width (a.get_width ());
2498 /** @param p Processor.
2499 * @return the UI window for \a p.
2502 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
2504 list<ProcessorWindowProxy*>::const_iterator i = _processor_window_proxies.begin ();
2505 while (i != _processor_window_proxies.end()) {
2506 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2508 return (*i)->get ();
2517 /** Make a note of the UI window that a processor is using.
2518 * @param p Processor.
2519 * @param w UI window.
2522 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
2524 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin ();
2528 while (i != _processor_window_proxies.end()) {
2529 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2538 /* we shouldn't get here, because the ProcessorUIList should always contain
2539 an entry for each processor.
2545 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
2547 boost::shared_ptr<Delivery> d = w.lock ();
2552 list<ProcessorEntry*> children = processor_display.children ();
2553 list<ProcessorEntry*>::const_iterator i = children.begin();
2554 while (i != children.end() && (*i)->processor() != d) {
2558 if (i == children.end()) {
2559 processor_display.set_active (0);
2561 processor_display.set_active (*i);
2565 /** Called to repair the damage of Editor::show_window doing a show_all() */
2567 ProcessorBox::hide_things ()
2569 list<ProcessorEntry*> c = processor_display.children ();
2570 for (list<ProcessorEntry*>::iterator i = c.begin(); i != c.end(); ++i) {
2571 (*i)->hide_things ();
2576 ProcessorBox::processor_menu_unmapped ()
2578 processor_display.remove_placeholder ();
2582 ProcessorBox::entry_gui_object_state (ProcessorEntry* entry)
2584 if (!_parent_strip) {
2588 GUIObjectState& st = _parent_strip->gui_object_state ();
2590 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
2592 return st.get_or_add_node (strip, entry->state_id());
2596 ProcessorBox::update_gui_object_state (ProcessorEntry* entry)
2598 XMLNode* proc = entry_gui_object_state (entry);
2603 /* XXX: this is a bit inefficient; we just remove all child nodes and re-add them */
2604 proc->remove_nodes_and_delete (X_("Object"));
2605 entry->add_control_state (proc);
2608 ProcessorWindowProxy::ProcessorWindowProxy (
2609 string const & name,
2610 XMLNode const * node,
2612 boost::weak_ptr<Processor> processor
2614 : WindowProxy<Gtk::Window> (name, node)
2616 , _processor_box (box)
2617 , _processor (processor)
2624 ProcessorWindowProxy::show ()
2626 boost::shared_ptr<Processor> p = _processor.lock ();
2631 _processor_box->toggle_edit_processor (p);