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::edit_generic_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 , _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 ());
458 ProcessorEntry::Control::set_pixel_width (int p)
460 _slider.set_fader_length (p);
464 ProcessorEntry::Control::slider_adjusted ()
466 if (_ignore_ui_adjustment) {
470 boost::shared_ptr<AutomationControl> c = _control.lock ();
476 c->set_value (c->interface_to_internal (_adjustment.get_value ()));
480 ProcessorEntry::Control::button_clicked ()
482 boost::shared_ptr<AutomationControl> c = _control.lock ();
488 bool const n = _button.active_state() == Gtkmm2ext::Active ? false : true;
490 c->set_value (n ? 1 : 0);
491 _button.set_active_state (n ? Gtkmm2ext::Active : Gtkmm2ext::ActiveState (0));
495 ProcessorEntry::Control::control_changed ()
497 boost::shared_ptr<AutomationControl> c = _control.lock ();
502 _ignore_ui_adjustment = true;
506 _button.set_active_state (c->get_value() > 0.5 ? Gtkmm2ext::Active : Gtkmm2ext::ActiveState (0));
510 _adjustment.set_value (c->internal_to_interface (c->get_value ()));
514 s.setf (ios::fixed, ios::floatfield);
515 s << c->internal_to_user (c->get_value ());
517 _slider.set_tooltip_text (s.str ());
520 _ignore_ui_adjustment = false;
524 ProcessorEntry::Control::add_state (XMLNode* node) const
526 XMLNode* c = new XMLNode (X_("Object"));
527 c->add_property (X_("id"), state_id ());
528 c->add_property (X_("visible"), _visible);
529 node->add_child_nocopy (*c);
533 ProcessorEntry::Control::set_state (XMLNode const * node)
535 XMLNode* n = GUIObjectState::get_node (node, state_id ());
537 XMLProperty* p = n->property (X_("visible"));
538 set_visible (p && string_is_affirmative (p->value ()));
545 ProcessorEntry::Control::set_visible (bool v)
556 /** Called when the Editor might have re-shown things that
560 ProcessorEntry::Control::hide_things ()
568 ProcessorEntry::Control::hide_label ()
574 ProcessorEntry::Control::state_id () const
576 boost::shared_ptr<AutomationControl> c = _control.lock ();
579 return string_compose (X_("control %1"), c->id().to_s ());
582 BlankProcessorEntry::BlankProcessorEntry (ProcessorBox* b, Width w)
583 : ProcessorEntry (b, boost::shared_ptr<Processor>(), w)
587 PluginInsertProcessorEntry::PluginInsertProcessorEntry (ProcessorBox* b, boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
588 : ProcessorEntry (b, p, w)
591 p->SplittingChanged.connect (
592 _splitting_connection, invalidator (*this), ui_bind (&PluginInsertProcessorEntry::plugin_insert_splitting_changed, this), gui_context()
595 _splitting_icon.set_size_request (-1, 12);
597 _vbox.pack_start (_splitting_icon);
598 _vbox.reorder_child (_splitting_icon, 0);
600 plugin_insert_splitting_changed ();
604 PluginInsertProcessorEntry::plugin_insert_splitting_changed ()
606 if (_plugin_insert->splitting ()) {
607 _splitting_icon.show ();
609 _splitting_icon.hide ();
614 PluginInsertProcessorEntry::hide_things ()
616 ProcessorEntry::hide_things ();
617 plugin_insert_splitting_changed ();
621 PluginInsertProcessorEntry::setup_visuals ()
625 _splitting_icon.set_name ("ProcessorPreFader");
629 _splitting_icon.set_name ("ProcessorFader");
633 _splitting_icon.set_name ("ProcessorPostFader");
637 ProcessorEntry::setup_visuals ();
641 PluginInsertProcessorEntry::SplittingIcon::on_expose_event (GdkEventExpose* ev)
643 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
645 cairo_set_line_width (cr, 1);
647 double const width = ev->area.width;
648 double const height = ev->area.height;
650 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
651 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
653 cairo_rectangle (cr, 0, 0, width, height);
656 Gdk::Color const fg = get_style()->get_fg (STATE_NORMAL);
657 cairo_set_source_rgb (cr, fg.get_red_p (), fg.get_green_p (), fg.get_blue_p ());
659 cairo_move_to (cr, width * 0.3, height);
660 cairo_line_to (cr, width * 0.3, height * 0.5);
661 cairo_line_to (cr, width * 0.7, height * 0.5);
662 cairo_line_to (cr, width * 0.7, height);
663 cairo_move_to (cr, width * 0.5, height * 0.5);
664 cairo_line_to (cr, width * 0.5, 0);
670 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
671 RouteProcessorSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
672 : _parent_strip (parent)
673 , _owner_is_mixer (owner_is_mixer)
674 , ab_direction (true)
675 , _get_plugin_selector (get_plugin_selector)
677 , _visible_prefader_processors (0)
678 , _rr_selection(rsel)
684 no_processor_redisplay = false;
686 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
687 processor_scroller.add (processor_display);
688 pack_start (processor_scroller, true, true);
690 processor_display.set_flags (CAN_FOCUS);
691 processor_display.set_name ("ProcessorList");
692 processor_display.set_size_request (48, -1);
693 processor_display.set_data ("processorbox", this);
694 processor_display.set_spacing (2);
696 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
697 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
699 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
700 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
702 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
703 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
705 processor_scroller.show ();
706 processor_display.show ();
709 parent->DeliveryChanged.connect (
710 _mixer_strip_connections, invalidator (*this), ui_bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
714 ARDOUR_UI::instance()->set_tip (processor_display, _("Right-click to add/remove/edit\nplugins,inserts,sends and more"));
717 ProcessorBox::~ProcessorBox ()
719 /* it may appear as if we should delete processor_menu but that is a
720 * pointer to a widget owned by the UI Manager, and has potentially
721 * be returned to many other ProcessorBoxes. GTK doesn't really make
722 * clear the ownership of this widget, which is a menu and thus is
723 * never packed into any container other than an implict GtkWindow.
725 * For now, until or if we ever get clarification over the ownership
726 * story just let it continue to exist. At worst, its a small memory leak.
731 ProcessorBox::set_route (boost::shared_ptr<Route> r)
737 _route_connections.drop_connections();
739 /* new route: any existing block on processor redisplay must be meaningless */
740 no_processor_redisplay = false;
743 _route->processors_changed.connect (
744 _route_connections, invalidator (*this), ui_bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
747 _route->DropReferences.connect (
748 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
751 _route->PropertyChanged.connect (
752 _route_connections, invalidator (*this), ui_bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
755 redisplay_processors ();
759 ProcessorBox::route_going_away ()
761 /* don't keep updating display as processors are deleted */
762 no_processor_redisplay = true;
767 ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
769 boost::shared_ptr<Processor> p;
771 p = position->processor ();
774 list<ProcessorEntry*> children = source->selection ();
775 list<boost::shared_ptr<Processor> > procs;
776 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
777 if ((*i)->processor ()) {
778 procs.push_back ((*i)->processor ());
782 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
783 XMLNode& state = (*i)->get_state ();
785 nlist.push_back (&state);
786 paste_processor_state (nlist, p);
790 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
794 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
795 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
797 other->delete_dragged_processors (procs);
803 ProcessorBox::update()
805 redisplay_processors ();
809 ProcessorBox::set_width (Width w)
817 list<ProcessorEntry*> children = processor_display.children ();
818 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
819 (*i)->set_enum_width (w);
822 redisplay_processors ();
826 ProcessorBox::build_possible_aux_menu ()
828 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
834 using namespace Menu_Helpers;
835 Menu* menu = manage (new Menu);
836 MenuList& items = menu->items();
838 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
839 if (!_route->internal_send_for (*r) && *r != _route) {
840 items.push_back (MenuElem ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
848 ProcessorBox::show_processor_menu (int arg)
850 if (processor_menu == 0) {
851 processor_menu = build_processor_menu ();
852 processor_menu->signal_unmap().connect (sigc::mem_fun (*this, &ProcessorBox::processor_menu_unmapped));
855 /* Sort out the plugin submenu */
857 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newplugin"));
859 if (plugin_menu_item) {
860 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
863 /* And the aux submenu */
865 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newaux"));
868 Menu* m = build_possible_aux_menu();
869 if (m && !m->items().empty()) {
870 aux_menu_item->set_submenu (*m);
871 aux_menu_item->set_sensitive (true);
873 /* stupid gtkmm: we need to pass a null reference here */
874 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
875 aux_menu_item->set_sensitive (false);
879 ProcessorEntry* single_selection = 0;
880 if (processor_display.selection().size() == 1) {
881 single_selection = processor_display.selection().front();
884 /* And the controls submenu */
886 Gtk::MenuItem* controls_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/controls"));
888 if (controls_menu_item) {
889 if (single_selection) {
890 Menu* m = single_selection->build_controls_menu ();
891 if (m && !m->items().empty()) {
892 controls_menu_item->set_submenu (*m);
893 controls_menu_item->set_sensitive (true);
895 gtk_menu_item_set_submenu (controls_menu_item->gobj(), 0);
896 controls_menu_item->set_sensitive (false);
901 /* Sensitise actions as approprioate */
903 cut_action->set_sensitive (can_cut());
904 paste_action->set_sensitive (!_rr_selection.processors.empty());
906 const bool sensitive = !processor_display.selection().empty();
907 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
908 edit_action->set_sensitive (one_processor_can_be_edited ());
910 boost::shared_ptr<PluginInsert> pi;
911 if (single_selection) {
912 pi = boost::dynamic_pointer_cast<PluginInsert> (single_selection->processor ());
915 /* allow editing with an Ardour-generated UI for plugin inserts with editors */
916 edit_generic_action->set_sensitive (pi && pi->plugin()->has_editor ());
918 /* disallow rename for multiple selections, for plugin inserts and for the fader */
919 rename_action->set_sensitive (single_selection && !pi && !boost::dynamic_pointer_cast<Amp> (single_selection->processor ()));
921 processor_menu->popup (1, arg);
923 /* Add a placeholder gap to the processor list to indicate where a processor would be
924 inserted were one chosen from the menu.
927 processor_display.get_pointer (x, y);
928 _placement = processor_display.add_placeholder (y);
930 if (_visible_prefader_processors == 0) {
931 if (_placement == 1) {
938 ProcessorBox::enter_notify (GdkEventCrossing*)
940 _current_processor_box = this;
945 ProcessorBox::leave_notify (GdkEventCrossing* ev)
951 ProcessorBox::processor_operation (ProcessorOperation op)
953 ProcSelection targets;
955 get_selected_processors (targets);
957 if (targets.empty()) {
960 processor_display.get_pointer (x, y);
962 pair<ProcessorEntry *, double> const pointer = processor_display.get_child_at_position (y);
964 if (pointer.first && pointer.first->processor()) {
965 targets.push_back (pointer.first->processor ());
970 case ProcessorsSelectAll:
971 processor_display.select_all ();
975 copy_processors (targets);
979 cut_processors (targets);
982 case ProcessorsPaste:
983 if (targets.empty()) {
986 paste_processors (targets.front());
990 case ProcessorsDelete:
991 delete_processors (targets);
994 case ProcessorsToggleActive:
995 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
996 if ((*i)->active()) {
1014 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
1016 boost::shared_ptr<Processor> processor;
1018 processor = child->processor ();
1022 bool selected = processor_display.selected (child);
1024 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
1026 if (_session->engine().connected()) {
1027 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
1028 if (Config->get_use_plugin_own_gui ()) {
1029 toggle_edit_processor (processor);
1031 toggle_edit_generic_processor (processor);
1036 } else if (processor && ev->button == 1 && selected) {
1038 // this is purely informational but necessary for route params UI
1039 ProcessorSelected (processor); // emit
1041 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
1044 _get_plugin_selector()->show_manager ();
1051 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
1053 boost::shared_ptr<Processor> processor;
1055 processor = child->processor ();
1058 if (processor && Keyboard::is_delete_event (ev)) {
1060 Glib::signal_idle().connect (sigc::bind (
1061 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
1062 boost::weak_ptr<Processor>(processor)));
1064 } else if (Keyboard::is_context_menu_event (ev)) {
1066 show_processor_menu (ev->time);
1068 } else if (processor && Keyboard::is_button2_event (ev)
1070 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
1074 /* button2-click with no/appropriate modifiers */
1076 if (processor->active()) {
1077 processor->deactivate ();
1079 processor->activate ();
1087 ProcessorBox::build_processor_menu ()
1089 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/ProcessorMenu") );
1090 processor_menu->set_name ("ArdourContextMenu");
1091 return processor_menu;
1095 ProcessorBox::select_all_processors ()
1097 processor_display.select_all ();
1101 ProcessorBox::deselect_all_processors ()
1103 processor_display.select_none ();
1107 ProcessorBox::choose_plugin ()
1109 _get_plugin_selector()->set_interested_object (*this);
1112 /** @return true if an error occurred, otherwise false */
1114 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
1116 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
1118 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
1120 Route::ProcessorStreams err_streams;
1122 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
1123 weird_plugin_dialog (**p, err_streams);
1125 // XXX SHAREDPTR delete plugin here .. do we even need to care?
1128 if (Profile->get_sae()) {
1129 processor->activate ();
1138 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
1140 ArdourDialog dialog (_("Plugin Incompatibility"));
1143 string text = string_compose(_("You attempted to add the plugin \"%1\" in slot %2.\n"),
1144 p.name(), streams.index);
1146 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
1147 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
1149 text += _("\nThis plugin has:\n");
1151 uint32_t const n = p.get_info()->n_inputs.n_midi ();
1152 text += string_compose (ngettext ("\t%1 MIDI input\n", "\t%1 MIDI inputs\n", n), n);
1155 uint32_t const n = p.get_info()->n_inputs.n_audio ();
1156 text += string_compose (ngettext ("\t%1 audio input\n", "\t%1 audio inputs\n", n), n);
1159 text += _("\nbut at the insertion point, there are:\n");
1161 uint32_t const n = streams.count.n_midi ();
1162 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
1165 uint32_t const n = streams.count.n_audio ();
1166 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
1169 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
1170 label.set_text(text);
1172 dialog.get_vbox()->pack_start (label);
1173 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1175 dialog.set_name (X_("PluginIODialog"));
1176 dialog.set_position (Gtk::WIN_POS_MOUSE);
1177 dialog.set_modal (true);
1184 ProcessorBox::choose_insert ()
1186 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->pannable(), _route->mute_master()));
1187 _route->add_processor_by_index (processor, _placement);
1190 /* Caller must not hold process lock */
1192 ProcessorBox::choose_send ()
1194 boost::shared_ptr<Send> send (new Send (*_session, _route->pannable(), _route->mute_master()));
1196 /* make an educated guess at the initial number of outputs for the send */
1197 ChanCount outs = (_session->master_out())
1198 ? _session->master_out()->n_outputs()
1199 : _route->n_outputs();
1201 /* XXX need processor lock on route */
1203 Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock());
1204 send->output()->ensure_io (outs, false, this);
1205 } catch (AudioEngine::PortRegistrationFailure& err) {
1206 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
1210 /* let the user adjust the IO setup before creation.
1212 Note: this dialog is NOT modal - we just leave it to run and it will
1213 return when its Finished signal is emitted - typically when the window
1217 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
1220 /* keep a reference to the send so it doesn't get deleted while
1221 the IOSelectorWindow is doing its stuff
1223 _processor_being_created = send;
1225 ios->selector().Finished.connect (sigc::bind (
1226 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
1227 boost::weak_ptr<Processor>(send), ios));
1232 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1234 boost::shared_ptr<Processor> processor (weak_processor.lock());
1236 /* drop our temporary reference to the new send */
1237 _processor_being_created.reset ();
1244 case IOSelector::Cancelled:
1245 // processor will go away when all shared_ptrs to it vanish
1248 case IOSelector::Accepted:
1249 _route->add_processor_by_index (processor, _placement);
1250 if (Profile->get_sae()) {
1251 processor->activate ();
1256 delete_when_idle (ios);
1260 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1262 boost::shared_ptr<Processor> processor (weak_processor.lock());
1264 /* drop our temporary reference to the new return */
1265 _processor_being_created.reset ();
1272 case IOSelector::Cancelled:
1273 // processor will go away when all shared_ptrs to it vanish
1276 case IOSelector::Accepted:
1277 _route->add_processor_by_index (processor, _placement);
1278 if (Profile->get_sae()) {
1279 processor->activate ();
1284 delete_when_idle (ios);
1288 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
1294 boost::shared_ptr<Route> target = wr.lock();
1300 boost::shared_ptr<RouteList> rlist (new RouteList);
1301 rlist->push_back (_route);
1303 _session->add_internal_sends (target, PreFader, rlist);
1307 ProcessorBox::route_processors_changed (RouteProcessorChange c)
1309 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
1310 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
1314 redisplay_processors ();
1318 ProcessorBox::redisplay_processors ()
1320 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors);
1323 if (no_processor_redisplay) {
1327 processor_display.clear ();
1329 _visible_prefader_processors = 0;
1332 _route->foreach_processor (sigc::bind (sigc::mem_fun (*this, &ProcessorBox::help_count_visible_prefader_processors),
1333 &_visible_prefader_processors, &fader_seen));
1335 if (_visible_prefader_processors == 0) { // fader only
1336 BlankProcessorEntry* bpe = new BlankProcessorEntry (this, _width);
1337 bpe->set_pixel_width (get_allocation().get_width());
1338 processor_display.add_child (bpe);
1341 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
1343 for (list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin(); i != _processor_window_proxies.end(); ++i) {
1344 (*i)->marked = false;
1347 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
1349 /* trim dead wood from the processor window proxy list */
1351 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin();
1352 while (i != _processor_window_proxies.end()) {
1353 list<ProcessorWindowProxy*>::iterator j = i;
1356 if (!(*i)->marked) {
1357 ARDOUR_UI::instance()->remove_window_proxy (*i);
1359 _processor_window_proxies.erase (i);
1365 setup_entry_positions ();
1368 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
1369 * not already have one.
1372 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
1374 boost::shared_ptr<Processor> p = w.lock ();
1379 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin ();
1380 while (i != _processor_window_proxies.end()) {
1382 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
1385 /* this processor is already on the list; done */
1386 (*i)->marked = true;
1393 /* not on the list; add it */
1396 if (_parent_strip) {
1397 if (_parent_strip->mixer_owned()) {
1406 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
1407 string_compose ("%1-%2-%3", loc, _route->id(), p->id()),
1408 _session->extra_xml (X_("UI")),
1414 /* if the processor already has an existing UI,
1415 note that so that we don't recreate it
1418 void* existing_ui = p->get_ui ();
1421 wp->set (static_cast<Gtk::Window*>(existing_ui));
1424 _processor_window_proxies.push_back (wp);
1425 ARDOUR_UI::instance()->add_window_proxy (wp);
1429 ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor> p, uint32_t* cnt, bool* amp_seen)
1431 boost::shared_ptr<Processor> processor (p.lock ());
1433 if (processor && processor->display_to_user()) {
1435 if (boost::dynamic_pointer_cast<Amp>(processor)) {
1446 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
1448 boost::shared_ptr<Processor> processor (p.lock ());
1450 if (!processor || !processor->display_to_user()) {
1454 boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
1455 ProcessorEntry* e = 0;
1456 if (plugin_insert) {
1457 e = new PluginInsertProcessorEntry (this, plugin_insert, _width);
1459 e = new ProcessorEntry (this, processor, _width);
1462 e->set_pixel_width (get_allocation().get_width());
1464 /* Set up this entry's state from the GUIObjectState */
1465 XMLNode* proc = entry_gui_object_state (e);
1467 e->set_control_state (proc);
1470 if (boost::dynamic_pointer_cast<Send> (processor)) {
1471 /* Always show send controls */
1472 e->show_all_controls ();
1475 processor_display.add_child (e);
1479 ProcessorBox::reordered ()
1481 compute_processor_sort_keys ();
1482 setup_entry_positions ();
1486 ProcessorBox::setup_entry_positions ()
1488 list<ProcessorEntry*> children = processor_display.children ();
1489 bool pre_fader = true;
1491 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1492 if (boost::dynamic_pointer_cast<Amp>((*i)->processor())) {
1494 (*i)->set_position (ProcessorEntry::Fader);
1497 (*i)->set_position (ProcessorEntry::PreFader);
1499 (*i)->set_position (ProcessorEntry::PostFader);
1506 ProcessorBox::compute_processor_sort_keys ()
1508 list<ProcessorEntry*> children = processor_display.children ();
1509 Route::ProcessorList our_processors;
1511 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1512 if ((*i)->processor()) {
1513 our_processors.push_back ((*i)->processor ());
1517 if (_route->reorder_processors (our_processors)) {
1518 /* Reorder failed, so report this to the user. As far as I can see this must be done
1519 in an idle handler: it seems that the redisplay_processors() that happens below destroys
1520 widgets that were involved in the drag-and-drop on the processor list, which causes problems
1521 when the drag is torn down after this handler function is finished.
1523 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
1528 ProcessorBox::report_failed_reorder ()
1530 /* reorder failed, so redisplay */
1532 redisplay_processors ();
1534 /* now tell them about the problem */
1536 ArdourDialog dialog (_("Plugin Incompatibility"));
1539 label.set_text (_("\
1540 You cannot reorder these plugins/sends/inserts\n\
1541 in that way because the inputs and\n\
1542 outputs will not work correctly."));
1544 dialog.get_vbox()->set_border_width (12);
1545 dialog.get_vbox()->pack_start (label);
1546 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1548 dialog.set_name (X_("PluginIODialog"));
1549 dialog.set_position (Gtk::WIN_POS_MOUSE);
1550 dialog.set_modal (true);
1557 ProcessorBox::rename_processors ()
1559 ProcSelection to_be_renamed;
1561 get_selected_processors (to_be_renamed);
1563 if (to_be_renamed.empty()) {
1567 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
1568 rename_processor (*i);
1573 ProcessorBox::can_cut () const
1575 vector<boost::shared_ptr<Processor> > sel;
1577 get_selected_processors (sel);
1579 /* cut_processors () does not cut inserts */
1581 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
1583 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1584 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1585 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1594 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
1596 if (to_be_removed.empty()) {
1600 XMLNode* node = new XMLNode (X_("cut"));
1601 Route::ProcessorList to_cut;
1603 no_processor_redisplay = true;
1604 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
1605 // Cut only plugins, sends and returns
1606 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1607 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1608 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1610 Window* w = get_processor_ui (*i);
1616 XMLNode& child ((*i)->get_state());
1617 node->add_child_nocopy (child);
1618 to_cut.push_back (*i);
1622 if (_route->remove_processors (to_cut) != 0) {
1624 no_processor_redisplay = false;
1628 _rr_selection.set (node);
1630 no_processor_redisplay = false;
1631 redisplay_processors ();
1635 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
1637 if (to_be_copied.empty()) {
1641 XMLNode* node = new XMLNode (X_("copy"));
1643 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
1644 // Copy only plugins, sends, returns
1645 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1646 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1647 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1648 node->add_child_nocopy ((*i)->get_state());
1652 _rr_selection.set (node);
1656 ProcessorBox::processors_up ()
1662 ProcessorBox::processors_down ()
1669 ProcessorBox::delete_processors (const ProcSelection& targets)
1671 if (targets.empty()) {
1675 no_processor_redisplay = true;
1677 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
1679 Window* w = get_processor_ui (*i);
1685 _route->remove_processor(*i);
1688 no_processor_redisplay = false;
1689 redisplay_processors ();
1693 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
1695 list<boost::shared_ptr<Processor> >::const_iterator x;
1697 no_processor_redisplay = true;
1698 for (x = procs.begin(); x != procs.end(); ++x) {
1700 Window* w = get_processor_ui (*x);
1706 _route->remove_processor(*x);
1709 no_processor_redisplay = false;
1710 redisplay_processors ();
1714 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
1716 boost::shared_ptr<Processor> processor (weak_processor.lock());
1722 /* NOT copied to _mixer.selection() */
1724 no_processor_redisplay = true;
1725 _route->remove_processor (processor);
1726 no_processor_redisplay = false;
1727 redisplay_processors ();
1733 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
1735 ArdourPrompter name_prompter (true);
1737 name_prompter.set_title (_("Rename Processor"));
1738 name_prompter.set_prompt (_("New name:"));
1739 name_prompter.set_initial_text (processor->name());
1740 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
1741 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
1742 name_prompter.show_all ();
1744 switch (name_prompter.run ()) {
1746 case Gtk::RESPONSE_ACCEPT:
1747 name_prompter.get_result (result);
1748 if (result.length()) {
1751 string test = result;
1753 while (tries < 100) {
1754 if (_session->io_name_is_legal (test)) {
1760 test = string_compose ("%1-%2", result, tries);
1764 processor->set_name (result);
1767 ARDOUR_UI::instance()->popup_error
1768 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
1778 ProcessorBox::paste_processors ()
1780 if (_rr_selection.processors.empty()) {
1784 paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
1788 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
1791 if (_rr_selection.processors.empty()) {
1795 paste_processor_state (_rr_selection.processors.get_node().children(), before);
1799 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
1801 XMLNodeConstIterator niter;
1802 list<boost::shared_ptr<Processor> > copies;
1804 if (nlist.empty()) {
1808 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1810 XMLProperty const * type = (*niter)->property ("type");
1813 boost::shared_ptr<Processor> p;
1815 if (type->value() == "meter" ||
1816 type->value() == "main-outs" ||
1817 type->value() == "amp" ||
1818 type->value() == "intsend" || type->value() == "intreturn") {
1819 /* do not paste meter, main outs, amp or internal send/returns */
1822 } else if (type->value() == "send") {
1824 XMLNode n (**niter);
1825 Send::make_unique (n, *_session);
1826 Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
1827 if (s->set_state (n, Stateful::loading_state_version)) {
1835 } else if (type->value() == "return") {
1837 XMLNode n (**niter);
1838 Return::make_unique (n, *_session);
1839 Return* r = new Return (*_session);
1841 if (r->set_state (n, Stateful::loading_state_version)) {
1848 } else if (type->value() == "port") {
1850 XMLNode n (**niter);
1851 p.reset (new PortInsert (*_session, _route->pannable (), _route->mute_master ()));
1852 if (p->set_state (n, Stateful::loading_state_version)) {
1857 /* XXX its a bit limiting to assume that everything else
1861 p.reset (new PluginInsert (*_session));
1862 p->set_state (**niter, Stateful::current_state_version);
1865 copies.push_back (p);
1869 cerr << "plugin insert constructor failed\n";
1873 if (copies.empty()) {
1877 if (_route->add_processors (copies, p)) {
1880 "Copying the set of processors on the clipboard failed,\n\
1881 probably because the I/O configuration of the plugins\n\
1882 could not match the configuration of this track.");
1883 MessageDialog am (msg);
1889 ProcessorBox::activate_processor (boost::shared_ptr<Processor> r)
1895 ProcessorBox::deactivate_processor (boost::shared_ptr<Processor> r)
1901 ProcessorBox::get_selected_processors (ProcSelection& processors) const
1903 const list<ProcessorEntry*> selection = processor_display.selection ();
1904 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
1905 processors.push_back ((*i)->processor ());
1910 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
1912 list<ProcessorEntry*> selection = processor_display.selection ();
1913 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
1914 (this->*method) ((*i)->processor ());
1919 ProcessorBox::all_visible_processors_active (bool state)
1921 _route->all_visible_processors_active (state);
1925 ProcessorBox::ab_plugins ()
1927 _route->ab_plugins (ab_direction);
1928 ab_direction = !ab_direction;
1933 ProcessorBox::clear_processors ()
1936 vector<string> choices;
1938 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
1939 "(this cannot be undone)"), _route->name());
1941 choices.push_back (_("Cancel"));
1942 choices.push_back (_("Yes, remove them all"));
1944 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1946 if (prompter.run () == 1) {
1947 _route->clear_processors (PreFader);
1948 _route->clear_processors (PostFader);
1953 ProcessorBox::clear_processors (Placement p)
1956 vector<string> choices;
1958 if (p == PreFader) {
1959 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
1960 "(this cannot be undone)"), _route->name());
1962 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
1963 "(this cannot be undone)"), _route->name());
1966 choices.push_back (_("Cancel"));
1967 choices.push_back (_("Yes, remove them all"));
1969 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1971 if (prompter.run () == 1) {
1972 _route->clear_processors (p);
1977 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
1979 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
1980 if (at && at->freeze_state() == AudioTrack::Frozen) {
1985 (boost::dynamic_pointer_cast<Send> (processor) && !boost::dynamic_pointer_cast<InternalSend> (processor))||
1986 boost::dynamic_pointer_cast<Return> (processor) ||
1987 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
1988 boost::dynamic_pointer_cast<PortInsert> (processor)
1997 ProcessorBox::one_processor_can_be_edited ()
1999 list<ProcessorEntry*> selection = processor_display.selection ();
2000 list<ProcessorEntry*>::iterator i = selection.begin();
2001 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
2005 return (i != selection.end());
2009 ProcessorBox::toggle_edit_processor (boost::shared_ptr<Processor> processor)
2011 boost::shared_ptr<Send> send;
2012 boost::shared_ptr<InternalSend> internal_send;
2013 boost::shared_ptr<Return> retrn;
2014 boost::shared_ptr<PluginInsert> plugin_insert;
2015 boost::shared_ptr<PortInsert> port_insert;
2018 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
2020 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
2025 if (boost::dynamic_pointer_cast<Amp> (processor)) {
2027 if (_parent_strip) {
2028 _parent_strip->revert_to_default_display ();
2031 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
2033 if (!_session->engine().connected()) {
2037 if (boost::dynamic_pointer_cast<InternalSend> (processor) == 0) {
2038 SendUIWindow* w = new SendUIWindow (send, _session);
2041 /* assign internal send to main fader */
2042 if (_parent_strip) {
2043 if (_parent_strip->current_delivery() == send) {
2044 _parent_strip->revert_to_default_display ();
2046 _parent_strip->show_send(send);
2051 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
2053 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
2054 /* no GUI for these */
2058 if (!_session->engine().connected()) {
2062 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
2064 ReturnUIWindow *return_ui;
2065 Window* w = get_processor_ui (retrn);
2069 return_ui = new ReturnUIWindow (retrn, _session);
2070 return_ui->set_title (retrn->name ());
2071 set_processor_ui (send, return_ui);
2074 return_ui = dynamic_cast<ReturnUIWindow *> (w);
2079 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
2081 PluginUIWindow *plugin_ui;
2083 /* these are both allowed to be null */
2085 Container* toplevel = get_toplevel();
2086 Window* win = dynamic_cast<Gtk::Window*>(toplevel);
2088 Window* w = get_processor_ui (plugin_insert);
2092 plugin_ui = new PluginUIWindow (win, plugin_insert);
2093 plugin_ui->set_title (generate_processor_title (plugin_insert));
2094 set_processor_ui (plugin_insert, plugin_ui);
2097 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
2098 plugin_ui->set_parent (win);
2103 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
2105 if (!_session->engine().connected()) {
2106 MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible"));
2111 PortInsertWindow *io_selector;
2113 Window* w = get_processor_ui (port_insert);
2116 io_selector = new PortInsertWindow (_session, port_insert);
2117 set_processor_ui (port_insert, io_selector);
2120 io_selector = dynamic_cast<PortInsertWindow *> (w);
2123 gidget = io_selector;
2127 if (gidget->is_visible()) {
2130 gidget->show_all ();
2136 /** Toggle a generic (Ardour-generated) plugin UI */
2138 ProcessorBox::toggle_edit_generic_processor (boost::shared_ptr<Processor> processor)
2140 boost::shared_ptr<PluginInsert> plugin_insert
2141 = boost::dynamic_pointer_cast<PluginInsert>(processor);
2142 if (!plugin_insert) {
2146 Container* toplevel = get_toplevel();
2147 Window* win = dynamic_cast<Gtk::Window*>(toplevel);
2148 PluginUIWindow* plugin_ui = new PluginUIWindow(win, plugin_insert, true, false);
2149 plugin_ui->set_title(generate_processor_title (plugin_insert));
2151 if (plugin_ui->is_visible()) {
2154 plugin_ui->show_all();
2155 plugin_ui->present();
2160 ProcessorBox::register_actions ()
2162 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("ProcessorMenu"));
2163 Glib::RefPtr<Action> act;
2166 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin"),
2167 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
2169 act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"),
2170 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
2171 ActionManager::jack_sensitive_actions.push_back (act);
2172 act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New External Send ..."),
2173 sigc::ptr_fun (ProcessorBox::rb_choose_send));
2174 ActionManager::jack_sensitive_actions.push_back (act);
2176 ActionManager::register_action (popup_act_grp, X_("newaux"), _("New Aux Send ..."));
2178 ActionManager::register_action (popup_act_grp, X_("controls"), _("Controls"));
2180 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear (all)"),
2181 sigc::ptr_fun (ProcessorBox::rb_clear));
2182 ActionManager::register_action (popup_act_grp, X_("clear_pre"), _("Clear (pre-fader)"),
2183 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
2184 ActionManager::register_action (popup_act_grp, X_("clear_post"), _("Clear (post-fader)"),
2185 sigc::ptr_fun (ProcessorBox::rb_clear_post));
2187 /* standard editing stuff */
2188 cut_action = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"),
2189 sigc::ptr_fun (ProcessorBox::rb_cut));
2190 ActionManager::plugin_selection_sensitive_actions.push_back(cut_action);
2191 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),
2192 sigc::ptr_fun (ProcessorBox::rb_copy));
2193 ActionManager::plugin_selection_sensitive_actions.push_back(act);
2195 act = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"),
2196 sigc::ptr_fun (ProcessorBox::rb_delete));
2197 ActionManager::plugin_selection_sensitive_actions.push_back(act); // ??
2199 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"),
2200 sigc::ptr_fun (ProcessorBox::rb_paste));
2201 rename_action = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"),
2202 sigc::ptr_fun (ProcessorBox::rb_rename));
2203 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"),
2204 sigc::ptr_fun (ProcessorBox::rb_select_all));
2205 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"),
2206 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
2208 /* activation etc. */
2210 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate All"),
2211 sigc::ptr_fun (ProcessorBox::rb_activate_all));
2212 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate All"),
2213 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
2214 ActionManager::register_action (popup_act_grp, X_("ab_plugins"), _("A/B Plugins"),
2215 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
2218 edit_action = ActionManager::register_action (
2219 popup_act_grp, X_("edit"), _("Edit..."),
2220 sigc::ptr_fun (ProcessorBox::rb_edit));
2222 edit_generic_action = ActionManager::register_action (
2223 popup_act_grp, X_("edit-generic"), _("Edit with basic controls..."),
2224 sigc::ptr_fun (ProcessorBox::rb_edit_generic));
2226 ActionManager::add_action_group (popup_act_grp);
2230 ProcessorBox::rb_edit_generic ()
2232 if (_current_processor_box == 0) {
2236 _current_processor_box->for_selected_processors (&ProcessorBox::toggle_edit_generic_processor);
2240 ProcessorBox::rb_ab_plugins ()
2242 if (_current_processor_box == 0) {
2246 _current_processor_box->ab_plugins ();
2250 ProcessorBox::rb_choose_plugin ()
2252 if (_current_processor_box == 0) {
2255 _current_processor_box->choose_plugin ();
2259 ProcessorBox::rb_choose_insert ()
2261 if (_current_processor_box == 0) {
2264 _current_processor_box->choose_insert ();
2268 ProcessorBox::rb_choose_send ()
2270 if (_current_processor_box == 0) {
2273 _current_processor_box->choose_send ();
2277 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
2279 if (_current_processor_box == 0) {
2283 _current_processor_box->choose_aux (wr);
2287 ProcessorBox::rb_clear ()
2289 if (_current_processor_box == 0) {
2293 _current_processor_box->clear_processors ();
2298 ProcessorBox::rb_clear_pre ()
2300 if (_current_processor_box == 0) {
2304 _current_processor_box->clear_processors (PreFader);
2309 ProcessorBox::rb_clear_post ()
2311 if (_current_processor_box == 0) {
2315 _current_processor_box->clear_processors (PostFader);
2319 ProcessorBox::rb_cut ()
2321 if (_current_processor_box == 0) {
2325 _current_processor_box->processor_operation (ProcessorsCut);
2329 ProcessorBox::rb_delete ()
2331 if (_current_processor_box == 0) {
2335 _current_processor_box->processor_operation (ProcessorsDelete);
2339 ProcessorBox::rb_copy ()
2341 if (_current_processor_box == 0) {
2344 _current_processor_box->processor_operation (ProcessorsCopy);
2348 ProcessorBox::rb_paste ()
2350 if (_current_processor_box == 0) {
2354 _current_processor_box->processor_operation (ProcessorsPaste);
2358 ProcessorBox::rb_rename ()
2360 if (_current_processor_box == 0) {
2363 _current_processor_box->rename_processors ();
2367 ProcessorBox::rb_select_all ()
2369 if (_current_processor_box == 0) {
2373 _current_processor_box->processor_operation (ProcessorsSelectAll);
2377 ProcessorBox::rb_deselect_all ()
2379 if (_current_processor_box == 0) {
2383 _current_processor_box->deselect_all_processors ();
2387 ProcessorBox::rb_activate_all ()
2389 if (_current_processor_box == 0) {
2393 _current_processor_box->all_visible_processors_active (true);
2397 ProcessorBox::rb_deactivate_all ()
2399 if (_current_processor_box == 0) {
2402 _current_processor_box->all_visible_processors_active (false);
2406 ProcessorBox::rb_edit ()
2408 if (_current_processor_box == 0) {
2412 _current_processor_box->for_selected_processors (&ProcessorBox::toggle_edit_processor);
2416 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
2418 if (!what_changed.contains (ARDOUR::Properties::name)) {
2422 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
2424 boost::shared_ptr<Processor> processor;
2425 boost::shared_ptr<PluginInsert> plugin_insert;
2426 boost::shared_ptr<Send> send;
2428 list<ProcessorEntry*> children = processor_display.children();
2430 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
2432 processor = (*iter)->processor ();
2438 Window* w = get_processor_ui (processor);
2444 /* rename editor windows for sends and plugins */
2446 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
2447 w->set_title (send->name ());
2448 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
2449 w->set_title (generate_processor_title (plugin_insert));
2455 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
2457 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
2458 string::size_type email_pos;
2460 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
2461 maker = maker.substr (0, email_pos - 1);
2464 if (maker.length() > 32) {
2465 maker = maker.substr (0, 32);
2469 return string_compose(_("%1: %2 (by %3)"), _route->name(), pi->name(), maker);
2473 ProcessorBox::on_size_allocate (Allocation& a)
2475 HBox::on_size_allocate (a);
2477 list<ProcessorEntry*> children = processor_display.children ();
2478 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
2479 (*i)->set_pixel_width (a.get_width ());
2483 /** @param p Processor.
2484 * @return the UI window for \a p.
2487 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
2489 list<ProcessorWindowProxy*>::const_iterator i = _processor_window_proxies.begin ();
2490 while (i != _processor_window_proxies.end()) {
2491 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2493 return (*i)->get ();
2502 /** Make a note of the UI window that a processor is using.
2503 * @param p Processor.
2504 * @param w UI window.
2507 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
2509 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin ();
2513 while (i != _processor_window_proxies.end()) {
2514 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2523 /* we shouldn't get here, because the ProcessorUIList should always contain
2524 an entry for each processor.
2530 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
2532 boost::shared_ptr<Delivery> d = w.lock ();
2537 list<ProcessorEntry*> children = processor_display.children ();
2538 list<ProcessorEntry*>::const_iterator i = children.begin();
2539 while (i != children.end() && (*i)->processor() != d) {
2543 if (i == children.end()) {
2544 processor_display.set_active (0);
2546 processor_display.set_active (*i);
2550 /** Called to repair the damage of Editor::show_window doing a show_all() */
2552 ProcessorBox::hide_things ()
2554 list<ProcessorEntry*> c = processor_display.children ();
2555 for (list<ProcessorEntry*>::iterator i = c.begin(); i != c.end(); ++i) {
2556 (*i)->hide_things ();
2561 ProcessorBox::processor_menu_unmapped ()
2563 processor_display.remove_placeholder ();
2567 ProcessorBox::entry_gui_object_state (ProcessorEntry* entry)
2569 if (!_parent_strip) {
2573 GUIObjectState& st = _parent_strip->gui_object_state ();
2575 XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
2577 return st.get_or_add_node (strip, entry->state_id());
2581 ProcessorBox::update_gui_object_state (ProcessorEntry* entry)
2583 XMLNode* proc = entry_gui_object_state (entry);
2588 /* XXX: this is a bit inefficient; we just remove all child nodes and re-add them */
2589 proc->remove_nodes_and_delete (X_("Object"));
2590 entry->add_control_state (proc);
2593 ProcessorWindowProxy::ProcessorWindowProxy (
2594 string const & name,
2595 XMLNode const * node,
2597 boost::weak_ptr<Processor> processor
2599 : WindowProxy<Gtk::Window> (name, node)
2601 , _processor_box (box)
2602 , _processor (processor)
2609 ProcessorWindowProxy::show ()
2611 boost::shared_ptr<Processor> p = _processor.lock ();
2616 _processor_box->toggle_edit_processor (p);