2 Copyright (C) 2000-2004 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "gtk2ardour-config.h"
28 #include <sigc++/bind.h>
30 #include "pbd/convert.h"
32 #include <glibmm/miscutils.h>
34 #include <gtkmm/messagedialog.h>
36 #include <gtkmm2ext/gtk_ui.h>
37 #include <gtkmm2ext/utils.h>
38 #include <gtkmm2ext/choice.h>
39 #include <gtkmm2ext/utils.h>
40 #include <gtkmm2ext/doi.h>
42 #include "ardour/amp.h"
43 #include "ardour/ardour.h"
44 #include "ardour/audio_track.h"
45 #include "ardour/audioengine.h"
46 #include "ardour/internal_send.h"
47 #include "ardour/internal_return.h"
48 #include "ardour/ladspa_plugin.h"
49 #include "ardour/meter.h"
50 #include "ardour/plugin_insert.h"
51 #include "ardour/port_insert.h"
52 #include "ardour/profile.h"
53 #include "ardour/return.h"
54 #include "ardour/route.h"
55 #include "ardour/send.h"
56 #include "ardour/session.h"
57 #include "ardour/dB.h"
60 #include "ardour_dialog.h"
61 #include "ardour_ui.h"
62 #include "gui_thread.h"
63 #include "io_selector.h"
66 #include "mixer_strip.h"
67 #include "plugin_selector.h"
68 #include "plugin_ui.h"
69 #include "port_insert_ui.h"
70 #include "processor_box.h"
71 #include "public_editor.h"
72 #include "return_ui.h"
73 #include "route_processor_selection.h"
79 #ifdef AUDIOUNIT_SUPPORT
84 using namespace ARDOUR;
88 using namespace Gtkmm2ext;
90 ProcessorBox* ProcessorBox::_current_processor_box = 0;
91 RefPtr<Action> ProcessorBox::paste_action;
92 RefPtr<Action> ProcessorBox::cut_action;
93 RefPtr<Action> ProcessorBox::rename_action;
94 RefPtr<Action> ProcessorBox::edit_action;
95 RefPtr<Action> ProcessorBox::controls_action;
96 Glib::RefPtr<Gdk::Pixbuf> SendProcessorEntry::_slider;
98 ProcessorEntry::ProcessorEntry (boost::shared_ptr<Processor> p, Width w)
99 : _button (ArdourButton::led_default_elements)
100 , _position (PreFader)
103 , _visual_state (Gtk::STATE_NORMAL)
105 _vbox.pack_start (_button, true, true);
108 if (_processor->active()) {
109 _button.set_active_state (Gtkmm2ext::Active);
111 _button.set_diameter (3);
112 _button.set_distinct_led_click (true);
113 _button.set_led_left (true);
114 _button.signal_led_clicked.connect (sigc::mem_fun (*this, &ProcessorEntry::led_clicked));
115 _button.set_text (name (_width));
118 _processor->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_active_changed, this), gui_context());
119 _processor->PropertyChanged.connect (name_connection, invalidator (*this), ui_bind (&ProcessorEntry::processor_property_changed, this, _1), gui_context());
126 ProcessorEntry::action_widget ()
132 ProcessorEntry::widget ()
138 ProcessorEntry::drag_text () const
144 ProcessorEntry::set_position (Position p)
151 ProcessorEntry::set_visual_state (Gtkmm2ext::VisualState s, bool yn)
154 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() | s));
156 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() & ~s));
161 ProcessorEntry::setup_visuals ()
165 _button.set_name ("processor prefader");
169 _button.set_name ("processor fader");
173 _button.set_name ("processor postfader");
179 boost::shared_ptr<Processor>
180 ProcessorEntry::processor () const
186 ProcessorEntry::set_enum_width (Width w)
192 ProcessorEntry::led_clicked()
194 if (_button.active_state() == Gtkmm2ext::Active) {
195 _processor->deactivate ();
197 _processor->activate ();
202 ProcessorEntry::processor_active_changed ()
204 if (_processor->active()) {
205 _button.set_active_state (Gtkmm2ext::Active);
207 _button.unset_active_state ();
212 ProcessorEntry::processor_property_changed (const PropertyChange& what_changed)
214 if (what_changed.contains (ARDOUR::Properties::name)) {
215 _button.set_text (name (_width));
221 ProcessorEntry::setup_tooltip ()
223 ARDOUR_UI::instance()->set_tip (_button, name (Wide));
227 ProcessorEntry::name (Width w) const
229 boost::shared_ptr<Send> send;
232 if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
233 !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
237 /* grab the send name out of its overall name */
239 string::size_type lbracket, rbracket;
240 lbracket = send->name().find ('[');
241 rbracket = send->name().find (']');
245 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
248 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
256 name_display += _processor->display_name();
259 name_display += PBD::short_version (_processor->display_name(), 5);
268 SendProcessorEntry::SendProcessorEntry (boost::shared_ptr<Send> s, Width w)
269 : ProcessorEntry (s, w)
271 , _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1)
272 , _fader (_slider, &_adjustment, 0, false)
273 , _ignore_gain_change (false)
274 , _data_type (DataType::AUDIO)
276 _fader.set_name ("SendFader");
277 _fader.set_controllable (_send->amp()->gain_control ());
278 _vbox.pack_start (_fader);
282 _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &SendProcessorEntry::gain_adjusted));
284 _send->amp()->gain_control()->Changed.connect (
285 _send_connections, invalidator (*this), boost::bind (&SendProcessorEntry::show_gain, this), gui_context()
288 _send->amp()->ConfigurationChanged.connect (
289 _send_connections, invalidator (*this), ui_bind (&SendProcessorEntry::setup_gain_adjustment, this), gui_context ()
292 setup_gain_adjustment ();
297 SendProcessorEntry::setup_gain_adjustment ()
299 if (_send->amp()->output_streams().n_midi() == 0) {
300 _data_type = DataType::AUDIO;
301 _adjustment.set_lower (0);
302 _adjustment.set_upper (1);
303 _adjustment.set_step_increment (0.01);
304 _adjustment.set_page_increment (0.1);
305 _fader.set_default_value (gain_to_slider_position (1));
307 _data_type = DataType::MIDI;
308 _adjustment.set_lower (0);
309 _adjustment.set_upper (2);
310 _adjustment.set_step_increment (0.05);
311 _adjustment.set_page_increment (0.1);
312 _fader.set_default_value (1);
317 SendProcessorEntry::setup_slider_pix ()
319 _slider = ::get_icon ("fader_belt_h_thin");
324 SendProcessorEntry::show_gain ()
328 switch (_data_type) {
329 case DataType::AUDIO:
330 value = gain_to_slider_position_with_max (_send->amp()->gain (), Config->get_max_gain());
333 value = _send->amp()->gain ();
337 if (_adjustment.get_value() != value) {
338 _ignore_gain_change = true;
339 _adjustment.set_value (value);
340 _ignore_gain_change = false;
344 s.setf (ios::fixed, ios::floatfield);
345 s << accurate_coefficient_to_dB (_send->amp()->gain ());
346 if (_data_type == DataType::AUDIO) {
350 _fader.set_tooltip_text (s.str ());
355 SendProcessorEntry::gain_adjusted ()
357 if (_ignore_gain_change) {
363 switch (_data_type) {
364 case DataType::AUDIO:
365 value = slider_position_to_gain_with_max (_adjustment.get_value(), Config->get_max_gain());
368 value = _adjustment.get_value ();
371 _send->amp()->set_gain (value, this);
375 SendProcessorEntry::set_pixel_width (int p)
377 _fader.set_fader_length (p);
380 PluginInsertProcessorEntry::PluginInsertProcessorEntry (boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
381 : ProcessorEntry (p, w)
384 p->SplittingChanged.connect (
385 _splitting_connection, invalidator (*this), ui_bind (&PluginInsertProcessorEntry::plugin_insert_splitting_changed, this), gui_context()
388 _splitting_icon.set_size_request (-1, 12);
390 _vbox.pack_start (_splitting_icon);
391 _vbox.reorder_child (_splitting_icon, 0);
393 plugin_insert_splitting_changed ();
397 PluginInsertProcessorEntry::plugin_insert_splitting_changed ()
399 if (_plugin_insert->splitting ()) {
400 _splitting_icon.show ();
402 _splitting_icon.hide ();
407 PluginInsertProcessorEntry::hide_things ()
409 plugin_insert_splitting_changed ();
413 PluginInsertProcessorEntry::setup_visuals ()
417 _splitting_icon.set_name ("ProcessorPreFader");
421 _splitting_icon.set_name ("ProcessorFader");
425 _splitting_icon.set_name ("ProcessorPostFader");
429 ProcessorEntry::setup_visuals ();
433 PluginInsertProcessorEntry::SplittingIcon::on_expose_event (GdkEventExpose* ev)
435 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
437 cairo_set_line_width (cr, 1);
439 double const width = ev->area.width;
440 double const height = ev->area.height;
442 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
443 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
445 cairo_rectangle (cr, 0, 0, width, height);
448 Gdk::Color const fg = get_style()->get_fg (STATE_NORMAL);
449 cairo_set_source_rgb (cr, fg.get_red_p (), fg.get_green_p (), fg.get_blue_p ());
451 cairo_move_to (cr, width * 0.3, height);
452 cairo_line_to (cr, width * 0.3, height * 0.5);
453 cairo_line_to (cr, width * 0.7, height * 0.5);
454 cairo_line_to (cr, width * 0.7, height);
455 cairo_move_to (cr, width * 0.5, height * 0.5);
456 cairo_line_to (cr, width * 0.5, 0);
462 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
463 RouteRedirectSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
464 : _parent_strip (parent)
465 , _owner_is_mixer (owner_is_mixer)
466 , ab_direction (true)
467 , _get_plugin_selector (get_plugin_selector)
469 , _rr_selection(rsel)
475 send_action_menu = 0;
476 no_processor_redisplay = false;
478 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
479 processor_scroller.add (processor_display);
480 pack_start (processor_scroller, true, true);
482 processor_display.set_flags (CAN_FOCUS);
483 processor_display.set_name ("ProcessorList");
484 processor_display.set_size_request (48, -1);
485 processor_display.set_data ("processorbox", this);
486 processor_display.set_spacing (2);
488 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
489 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
491 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
492 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
494 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
495 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
496 processor_display.SelectionChanged.connect (sigc::mem_fun (*this, &ProcessorBox::selection_changed));
498 processor_scroller.show ();
499 processor_display.show ();
502 parent->DeliveryChanged.connect (
503 _mixer_strip_connections, invalidator (*this), ui_bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
508 ProcessorBox::~ProcessorBox ()
513 ProcessorBox::set_route (boost::shared_ptr<Route> r)
519 _route_connections.drop_connections();
521 /* new route: any existing block on processor redisplay must be meaningless */
522 no_processor_redisplay = false;
525 _route->processors_changed.connect (
526 _route_connections, invalidator (*this), ui_bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
529 _route->DropReferences.connect (
530 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
533 _route->PropertyChanged.connect (
534 _route_connections, invalidator (*this), ui_bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
537 redisplay_processors ();
541 ProcessorBox::route_going_away ()
543 /* don't keep updating display as processors are deleted */
544 no_processor_redisplay = true;
549 ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
551 boost::shared_ptr<Processor> p;
553 p = position->processor ();
556 list<ProcessorEntry*> children = source->selection ();
557 list<boost::shared_ptr<Processor> > procs;
558 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
559 procs.push_back ((*i)->processor ());
562 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
563 XMLNode& state = (*i)->get_state ();
565 nlist.push_back (&state);
566 paste_processor_state (nlist, p);
570 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
574 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
575 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
577 cerr << "source was another processor box, delete the selected items\n";
578 other->delete_dragged_processors (procs);
584 ProcessorBox::update()
586 redisplay_processors ();
590 ProcessorBox::set_width (Width w)
598 list<ProcessorEntry*> children = processor_display.children ();
599 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
600 (*i)->set_enum_width (w);
603 redisplay_processors ();
607 ProcessorBox::build_send_action_menu ()
609 using namespace Menu_Helpers;
611 send_action_menu = new Menu;
612 send_action_menu->set_name ("ArdourContextMenu");
613 MenuList& items = send_action_menu->items();
615 items.push_back (MenuElem (_("New send"), sigc::mem_fun(*this, &ProcessorBox::new_send)));
616 items.push_back (MenuElem (_("Show send controls"), sigc::mem_fun(*this, &ProcessorBox::show_send_controls)));
620 ProcessorBox::build_possible_aux_menu ()
622 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
628 using namespace Menu_Helpers;
629 Menu* menu = manage (new Menu);
630 MenuList& items = menu->items();
632 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
633 if (!_route->internal_send_for (*r) && *r != _route) {
634 items.push_back (MenuElem ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
642 ProcessorBox::show_send_controls ()
647 ProcessorBox::new_send ()
652 ProcessorBox::show_processor_menu (int arg)
654 if (processor_menu == 0) {
655 processor_menu = build_processor_menu ();
656 processor_menu->signal_unmap().connect (sigc::mem_fun (*this, &ProcessorBox::processor_menu_unmapped));
659 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newplugin"));
661 if (plugin_menu_item) {
662 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
665 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newaux"));
668 Menu* m = build_possible_aux_menu();
669 if (m && !m->items().empty()) {
670 aux_menu_item->set_submenu (*m);
671 aux_menu_item->set_sensitive (true);
673 /* stupid gtkmm: we need to pass a null reference here */
674 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
675 aux_menu_item->set_sensitive (false);
679 cut_action->set_sensitive (can_cut());
680 paste_action->set_sensitive (!_rr_selection.processors.empty());
682 processor_menu->popup (1, arg);
684 /* Add a placeholder gap to the processor list to indicate where a processor would be
685 inserted were one chosen from the menu.
688 processor_display.get_pointer (x, y);
689 _placement = processor_display.add_placeholder (y);
693 ProcessorBox::enter_notify (GdkEventCrossing*)
695 _current_processor_box = this;
700 ProcessorBox::leave_notify (GdkEventCrossing* ev)
706 ProcessorBox::processor_operation (ProcessorOperation op)
710 ProcSelection targets;
712 get_selected_processors (targets);
714 if (targets.empty()) {
717 processor_display.get_pointer (x, y);
719 pair<ProcessorEntry *, double> const pointer = processor_display.get_child_at_position (y);
722 targets.push_back (pointer.first->processor ());
727 case ProcessorsSelectAll:
728 processor_display.select_all ();
732 copy_processors (targets);
736 cut_processors (targets);
739 case ProcessorsPaste:
740 if (targets.empty()) {
743 paste_processors (targets.front());
747 case ProcessorsDelete:
748 delete_processors (targets);
751 case ProcessorsToggleActive:
752 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
753 if ((*i)->active()) {
772 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
774 boost::shared_ptr<Processor> processor;
776 processor = child->processor ();
780 bool selected = processor_display.selected (child);
782 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
784 if (_session->engine().connected()) {
785 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
786 toggle_edit_processor (processor);
790 } else if (processor && ev->button == 1 && selected) {
792 // this is purely informational but necessary for route params UI
793 ProcessorSelected (processor); // emit
795 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
798 _get_plugin_selector()->show_manager ();
805 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
807 boost::shared_ptr<Processor> processor;
809 processor = child->processor ();
812 if (processor && Keyboard::is_delete_event (ev)) {
814 Glib::signal_idle().connect (sigc::bind (
815 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
816 boost::weak_ptr<Processor>(processor)));
818 } else if (Keyboard::is_context_menu_event (ev)) {
820 show_processor_menu (ev->time);
822 } else if (processor && Keyboard::is_button2_event (ev)
824 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
828 /* button2-click with no/appropriate modifiers */
830 if (processor->active()) {
831 processor->deactivate ();
833 processor->activate ();
841 ProcessorBox::build_processor_menu ()
843 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/ProcessorMenu") );
844 processor_menu->set_name ("ArdourContextMenu");
845 return processor_menu;
849 ProcessorBox::selection_changed ()
851 const bool sensitive = !processor_display.selection().empty();
852 ActionManager::set_sensitive(ActionManager::plugin_selection_sensitive_actions,
854 edit_action->set_sensitive(one_processor_can_be_edited());
856 const bool single_selection = (processor_display.selection().size() == 1);
858 boost::shared_ptr<PluginInsert> pi;
859 if (single_selection) {
860 pi = boost::dynamic_pointer_cast<PluginInsert>(
861 processor_display.selection().front()->processor());
864 /* enable gui for plugin inserts with editors */
865 controls_action->set_sensitive(pi && pi->plugin()->has_editor());
867 /* disallow rename for multiple selections and for plugin inserts */
868 rename_action->set_sensitive(single_selection && pi);
872 ProcessorBox::select_all_processors ()
874 processor_display.select_all ();
878 ProcessorBox::deselect_all_processors ()
880 processor_display.select_none ();
884 ProcessorBox::choose_plugin ()
886 _get_plugin_selector()->set_interested_object (*this);
889 /** @return true if an error occurred, otherwise false */
891 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
893 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
895 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
897 Route::ProcessorStreams err_streams;
899 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
900 weird_plugin_dialog (**p, err_streams);
902 // XXX SHAREDPTR delete plugin here .. do we even need to care?
905 if (Profile->get_sae()) {
906 processor->activate ();
915 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
917 ArdourDialog dialog (_("Plugin Incompatibility"));
920 string text = string_compose(_("You attempted to add the plugin \"%1\" in slot %2.\n"),
921 p.name(), streams.index);
923 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
924 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
926 text += _("\nThis plugin has:\n");
928 uint32_t const n = p.get_info()->n_inputs.n_midi ();
929 text += string_compose (ngettext ("\t%1 MIDI input\n", "\t%1 MIDI inputs\n", n), n);
932 uint32_t const n = p.get_info()->n_inputs.n_audio ();
933 text += string_compose (ngettext ("\t%1 audio input\n", "\t%1 audio inputs\n", n), n);
936 text += _("\nbut at the insertion point, there are:\n");
938 uint32_t const n = streams.count.n_midi ();
939 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
942 uint32_t const n = streams.count.n_audio ();
943 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
946 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
947 label.set_text(text);
949 dialog.get_vbox()->pack_start (label);
950 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
952 dialog.set_name (X_("PluginIODialog"));
953 dialog.set_position (Gtk::WIN_POS_MOUSE);
954 dialog.set_modal (true);
961 ProcessorBox::choose_insert ()
963 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->pannable(), _route->mute_master()));
964 _route->add_processor_by_index (processor, _placement);
967 /* Caller must not hold process lock */
969 ProcessorBox::choose_send ()
971 boost::shared_ptr<Send> send (new Send (*_session, _route->pannable(), _route->mute_master()));
973 /* make an educated guess at the initial number of outputs for the send */
974 ChanCount outs = (_session->master_out())
975 ? _session->master_out()->n_outputs()
976 : _route->n_outputs();
978 /* XXX need processor lock on route */
980 Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock());
981 send->output()->ensure_io (outs, false, this);
982 } catch (AudioEngine::PortRegistrationFailure& err) {
983 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
987 /* let the user adjust the IO setup before creation.
989 Note: this dialog is NOT modal - we just leave it to run and it will
990 return when its Finished signal is emitted - typically when the window
994 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
997 /* keep a reference to the send so it doesn't get deleted while
998 the IOSelectorWindow is doing its stuff
1000 _processor_being_created = send;
1002 ios->selector().Finished.connect (sigc::bind (
1003 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
1004 boost::weak_ptr<Processor>(send), ios));
1009 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1011 boost::shared_ptr<Processor> processor (weak_processor.lock());
1013 /* drop our temporary reference to the new send */
1014 _processor_being_created.reset ();
1021 case IOSelector::Cancelled:
1022 // processor will go away when all shared_ptrs to it vanish
1025 case IOSelector::Accepted:
1026 _route->add_processor_by_index (processor, _placement);
1027 if (Profile->get_sae()) {
1028 processor->activate ();
1033 delete_when_idle (ios);
1037 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1039 boost::shared_ptr<Processor> processor (weak_processor.lock());
1041 /* drop our temporary reference to the new return */
1042 _processor_being_created.reset ();
1049 case IOSelector::Cancelled:
1050 // processor will go away when all shared_ptrs to it vanish
1053 case IOSelector::Accepted:
1054 _route->add_processor_by_index (processor, _placement);
1055 if (Profile->get_sae()) {
1056 processor->activate ();
1061 delete_when_idle (ios);
1065 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
1071 boost::shared_ptr<Route> target = wr.lock();
1077 boost::shared_ptr<RouteList> rlist (new RouteList);
1078 rlist->push_back (_route);
1080 _session->add_internal_sends (target, PreFader, rlist);
1084 ProcessorBox::route_processors_changed (RouteProcessorChange c)
1086 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
1087 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
1091 redisplay_processors ();
1095 ProcessorBox::redisplay_processors ()
1097 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors)
1099 if (no_processor_redisplay) {
1103 processor_display.clear ();
1105 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
1107 for (list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin(); i != _processor_window_proxies.end(); ++i) {
1108 (*i)->marked = false;
1111 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
1113 /* trim dead wood from the processor window proxy list */
1115 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin();
1116 while (i != _processor_window_proxies.end()) {
1117 list<ProcessorWindowProxy*>::iterator j = i;
1120 if (!(*i)->marked) {
1121 ARDOUR_UI::instance()->remove_window_proxy (*i);
1123 _processor_window_proxies.erase (i);
1129 setup_entry_positions ();
1132 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
1133 * not already have one.
1136 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
1138 boost::shared_ptr<Processor> p = w.lock ();
1143 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin ();
1144 while (i != _processor_window_proxies.end()) {
1146 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
1149 /* this processor is already on the list; done */
1150 (*i)->marked = true;
1157 /* not on the list; add it */
1160 if (_parent_strip) {
1161 if (_parent_strip->mixer_owned()) {
1170 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
1171 string_compose ("%1-%2-%3", loc, _route->id(), p->id()),
1172 _session->extra_xml (X_("UI")),
1178 /* if the processor already has an existing UI,
1179 note that so that we don't recreate it
1182 void* existing_ui = p->get_ui ();
1185 wp->set (static_cast<Gtk::Window*>(existing_ui));
1188 _processor_window_proxies.push_back (wp);
1189 ARDOUR_UI::instance()->add_window_proxy (wp);
1193 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
1195 boost::shared_ptr<Processor> processor (p.lock ());
1197 if (!processor || !processor->display_to_user()) {
1201 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
1202 boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
1203 ProcessorEntry* e = 0;
1205 e = new SendProcessorEntry (send, _width);
1206 } else if (plugin_insert) {
1207 e = new PluginInsertProcessorEntry (plugin_insert, _width);
1209 e = new ProcessorEntry (processor, _width);
1212 e->set_pixel_width (get_allocation().get_width());
1213 processor_display.add_child (e);
1218 ProcessorBox::build_processor_tooltip (EventBox& box, string start)
1222 list<ProcessorEntry*> children = processor_display.children ();
1223 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1225 tip += (*i)->processor()->name();
1228 ARDOUR_UI::instance()->set_tip (box, tip);
1232 ProcessorBox::reordered ()
1234 compute_processor_sort_keys ();
1235 setup_entry_positions ();
1239 ProcessorBox::setup_entry_positions ()
1241 list<ProcessorEntry*> children = processor_display.children ();
1242 bool pre_fader = true;
1244 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1245 if (boost::dynamic_pointer_cast<Amp>((*i)->processor())) {
1247 (*i)->set_position (ProcessorEntry::Fader);
1250 (*i)->set_position (ProcessorEntry::PreFader);
1252 (*i)->set_position (ProcessorEntry::PostFader);
1259 ProcessorBox::compute_processor_sort_keys ()
1261 list<ProcessorEntry*> children = processor_display.children ();
1262 Route::ProcessorList our_processors;
1264 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
1265 our_processors.push_back ((*iter)->processor ());
1268 if (_route->reorder_processors (our_processors)) {
1269 /* Reorder failed, so report this to the user. As far as I can see this must be done
1270 in an idle handler: it seems that the redisplay_processors() that happens below destroys
1271 widgets that were involved in the drag-and-drop on the processor list, which causes problems
1272 when the drag is torn down after this handler function is finished.
1274 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
1279 ProcessorBox::report_failed_reorder ()
1281 /* reorder failed, so redisplay */
1283 redisplay_processors ();
1285 /* now tell them about the problem */
1287 ArdourDialog dialog (_("Plugin Incompatibility"));
1290 label.set_text (_("\
1291 You cannot reorder these plugins/sends/inserts\n\
1292 in that way because the inputs and\n\
1293 outputs will not work correctly."));
1295 dialog.get_vbox()->set_border_width (12);
1296 dialog.get_vbox()->pack_start (label);
1297 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1299 dialog.set_name (X_("PluginIODialog"));
1300 dialog.set_position (Gtk::WIN_POS_MOUSE);
1301 dialog.set_modal (true);
1308 ProcessorBox::rename_processors ()
1310 ProcSelection to_be_renamed;
1312 get_selected_processors (to_be_renamed);
1314 if (to_be_renamed.empty()) {
1318 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
1319 rename_processor (*i);
1324 ProcessorBox::can_cut () const
1326 vector<boost::shared_ptr<Processor> > sel;
1328 get_selected_processors (sel);
1330 /* cut_processors () does not cut inserts */
1332 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
1334 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1335 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1336 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1345 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
1347 if (to_be_removed.empty()) {
1351 XMLNode* node = new XMLNode (X_("cut"));
1352 Route::ProcessorList to_cut;
1354 no_processor_redisplay = true;
1355 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
1356 // Cut only plugins, sends and returns
1357 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1358 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1359 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1361 Window* w = get_processor_ui (*i);
1367 XMLNode& child ((*i)->get_state());
1368 node->add_child_nocopy (child);
1369 to_cut.push_back (*i);
1373 if (_route->remove_processors (to_cut) != 0) {
1375 no_processor_redisplay = false;
1379 _rr_selection.set (node);
1381 no_processor_redisplay = false;
1382 redisplay_processors ();
1386 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
1388 if (to_be_copied.empty()) {
1392 XMLNode* node = new XMLNode (X_("copy"));
1394 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
1395 // Copy only plugins, sends, returns
1396 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1397 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1398 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1399 node->add_child_nocopy ((*i)->get_state());
1403 _rr_selection.set (node);
1407 ProcessorBox::processors_up ()
1413 ProcessorBox::processors_down ()
1420 ProcessorBox::delete_processors (const ProcSelection& targets)
1422 if (targets.empty()) {
1426 no_processor_redisplay = true;
1428 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
1430 Window* w = get_processor_ui (*i);
1436 _route->remove_processor(*i);
1439 no_processor_redisplay = false;
1440 redisplay_processors ();
1444 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
1446 list<boost::shared_ptr<Processor> >::const_iterator x;
1448 no_processor_redisplay = true;
1449 for (x = procs.begin(); x != procs.end(); ++x) {
1451 Window* w = get_processor_ui (*x);
1457 _route->remove_processor(*x);
1460 no_processor_redisplay = false;
1461 redisplay_processors ();
1465 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
1467 boost::shared_ptr<Processor> processor (weak_processor.lock());
1473 /* NOT copied to _mixer.selection() */
1475 no_processor_redisplay = true;
1476 _route->remove_processor (processor);
1477 no_processor_redisplay = false;
1478 redisplay_processors ();
1484 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
1486 ArdourPrompter name_prompter (true);
1488 name_prompter.set_title (_("Rename Processor"));
1489 name_prompter.set_prompt (_("New name:"));
1490 name_prompter.set_initial_text (processor->name());
1491 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
1492 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
1493 name_prompter.show_all ();
1495 switch (name_prompter.run ()) {
1497 case Gtk::RESPONSE_ACCEPT:
1498 name_prompter.get_result (result);
1499 if (result.length()) {
1502 string test = result;
1504 while (tries < 100) {
1505 if (_session->io_name_is_legal (test)) {
1511 test = string_compose ("%1-%2", result, tries);
1515 processor->set_name (result);
1518 ARDOUR_UI::instance()->popup_error
1519 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
1529 ProcessorBox::paste_processors ()
1531 if (_rr_selection.processors.empty()) {
1535 paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
1539 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
1542 if (_rr_selection.processors.empty()) {
1546 paste_processor_state (_rr_selection.processors.get_node().children(), before);
1550 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
1552 XMLNodeConstIterator niter;
1553 list<boost::shared_ptr<Processor> > copies;
1555 if (nlist.empty()) {
1559 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1561 XMLProperty const * type = (*niter)->property ("type");
1564 boost::shared_ptr<Processor> p;
1566 if (type->value() == "meter" ||
1567 type->value() == "main-outs" ||
1568 type->value() == "amp" ||
1569 type->value() == "intsend" || type->value() == "intreturn") {
1570 /* do not paste meter, main outs, amp or internal send/returns */
1573 } else if (type->value() == "send") {
1575 XMLNode n (**niter);
1576 Send::make_unique (n, *_session);
1577 Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
1578 if (s->set_state (n, Stateful::loading_state_version)) {
1586 } else if (type->value() == "return") {
1588 XMLNode n (**niter);
1589 Return::make_unique (n, *_session);
1590 Return* r = new Return (*_session);
1592 if (r->set_state (n, Stateful::loading_state_version)) {
1599 } else if (type->value() == "port") {
1601 XMLNode n (**niter);
1602 p.reset (new PortInsert (*_session, _route->pannable (), _route->mute_master ()));
1603 if (p->set_state (n, Stateful::loading_state_version)) {
1608 /* XXX its a bit limiting to assume that everything else
1612 p.reset (new PluginInsert (*_session));
1613 p->set_state (**niter, Stateful::current_state_version);
1616 copies.push_back (p);
1620 cerr << "plugin insert constructor failed\n";
1624 if (copies.empty()) {
1628 if (_route->add_processors (copies, p)) {
1631 "Copying the set of processors on the clipboard failed,\n\
1632 probably because the I/O configuration of the plugins\n\
1633 could not match the configuration of this track.");
1634 MessageDialog am (msg);
1640 ProcessorBox::activate_processor (boost::shared_ptr<Processor> r)
1646 ProcessorBox::deactivate_processor (boost::shared_ptr<Processor> r)
1652 ProcessorBox::get_selected_processors (ProcSelection& processors) const
1654 const list<ProcessorEntry*> selection = processor_display.selection ();
1655 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
1656 processors.push_back ((*i)->processor ());
1661 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
1663 list<ProcessorEntry*> selection = processor_display.selection ();
1664 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
1665 (this->*method) ((*i)->processor ());
1670 ProcessorBox::all_processors_active (bool state)
1672 _route->all_processors_active (PreFader, state);
1673 _route->all_processors_active (PostFader, state);
1677 ProcessorBox::ab_plugins ()
1679 _route->ab_plugins (ab_direction);
1680 ab_direction = !ab_direction;
1685 ProcessorBox::clear_processors ()
1688 vector<string> choices;
1690 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
1691 "(this cannot be undone)"), _route->name());
1693 choices.push_back (_("Cancel"));
1694 choices.push_back (_("Yes, remove them all"));
1696 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1698 if (prompter.run () == 1) {
1699 _route->clear_processors (PreFader);
1700 _route->clear_processors (PostFader);
1705 ProcessorBox::clear_processors (Placement p)
1708 vector<string> choices;
1710 if (p == PreFader) {
1711 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
1712 "(this cannot be undone)"), _route->name());
1714 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
1715 "(this cannot be undone)"), _route->name());
1718 choices.push_back (_("Cancel"));
1719 choices.push_back (_("Yes, remove them all"));
1721 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1723 if (prompter.run () == 1) {
1724 _route->clear_processors (p);
1729 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
1731 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
1732 if (at && at->freeze_state() == AudioTrack::Frozen) {
1737 (boost::dynamic_pointer_cast<Send> (processor) && !boost::dynamic_pointer_cast<InternalSend> (processor))||
1738 boost::dynamic_pointer_cast<Return> (processor) ||
1739 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
1740 boost::dynamic_pointer_cast<PortInsert> (processor)
1749 ProcessorBox::one_processor_can_be_edited ()
1751 list<ProcessorEntry*> selection = processor_display.selection ();
1752 list<ProcessorEntry*>::iterator i = selection.begin();
1753 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
1757 return (i != selection.end());
1761 ProcessorBox::toggle_edit_processor (boost::shared_ptr<Processor> processor)
1763 boost::shared_ptr<Send> send;
1764 boost::shared_ptr<InternalSend> internal_send;
1765 boost::shared_ptr<Return> retrn;
1766 boost::shared_ptr<PluginInsert> plugin_insert;
1767 boost::shared_ptr<PortInsert> port_insert;
1770 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
1772 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
1777 if (boost::dynamic_pointer_cast<Amp> (processor)) {
1779 if (_parent_strip) {
1780 _parent_strip->revert_to_default_display ();
1783 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
1785 if (!_session->engine().connected()) {
1789 SendUIWindow* w = new SendUIWindow (send, _session);
1792 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
1794 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
1795 /* no GUI for these */
1799 if (!_session->engine().connected()) {
1803 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
1805 ReturnUIWindow *return_ui;
1806 Window* w = get_processor_ui (retrn);
1810 return_ui = new ReturnUIWindow (retrn, _session);
1811 return_ui->set_title (retrn->name ());
1812 set_processor_ui (send, return_ui);
1815 return_ui = dynamic_cast<ReturnUIWindow *> (w);
1820 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
1822 PluginUIWindow *plugin_ui;
1824 /* these are both allowed to be null */
1826 Container* toplevel = get_toplevel();
1827 Window* win = dynamic_cast<Gtk::Window*>(toplevel);
1829 Window* w = get_processor_ui (plugin_insert);
1833 plugin_ui = new PluginUIWindow (win, plugin_insert);
1834 plugin_ui->set_title (generate_processor_title (plugin_insert));
1835 set_processor_ui (plugin_insert, plugin_ui);
1838 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
1839 plugin_ui->set_parent (win);
1844 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
1846 if (!_session->engine().connected()) {
1847 MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible"));
1852 PortInsertWindow *io_selector;
1854 Window* w = get_processor_ui (port_insert);
1857 io_selector = new PortInsertWindow (_session, port_insert);
1858 set_processor_ui (port_insert, io_selector);
1861 io_selector = dynamic_cast<PortInsertWindow *> (w);
1864 gidget = io_selector;
1868 if (gidget->is_visible()) {
1871 gidget->show_all ();
1878 ProcessorBox::toggle_processor_controls (boost::shared_ptr<Processor> processor)
1880 boost::shared_ptr<PluginInsert> plugin_insert
1881 = boost::dynamic_pointer_cast<PluginInsert>(processor);
1882 if (!plugin_insert) {
1886 Container* toplevel = get_toplevel();
1887 Window* win = dynamic_cast<Gtk::Window*>(toplevel);
1888 PluginUIWindow* plugin_ui = new PluginUIWindow(win, plugin_insert, true, false);
1889 plugin_ui->set_title(generate_processor_title (plugin_insert));
1891 if (plugin_ui->is_visible()) {
1894 plugin_ui->show_all();
1895 plugin_ui->present();
1900 ProcessorBox::register_actions ()
1902 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("ProcessorMenu"));
1903 Glib::RefPtr<Action> act;
1906 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin"),
1907 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
1909 act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"),
1910 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
1911 ActionManager::jack_sensitive_actions.push_back (act);
1912 act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New Send ..."),
1913 sigc::ptr_fun (ProcessorBox::rb_choose_send));
1914 ActionManager::jack_sensitive_actions.push_back (act);
1916 ActionManager::register_action (popup_act_grp, X_("newaux"), _("New Aux Send ..."));
1918 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear (all)"),
1919 sigc::ptr_fun (ProcessorBox::rb_clear));
1920 ActionManager::register_action (popup_act_grp, X_("clear_pre"), _("Clear (pre-fader)"),
1921 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
1922 ActionManager::register_action (popup_act_grp, X_("clear_post"), _("Clear (post-fader)"),
1923 sigc::ptr_fun (ProcessorBox::rb_clear_post));
1925 /* standard editing stuff */
1926 cut_action = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"),
1927 sigc::ptr_fun (ProcessorBox::rb_cut));
1928 ActionManager::plugin_selection_sensitive_actions.push_back(cut_action);
1929 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),
1930 sigc::ptr_fun (ProcessorBox::rb_copy));
1931 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1933 act = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"),
1934 sigc::ptr_fun (ProcessorBox::rb_delete));
1935 ActionManager::plugin_selection_sensitive_actions.push_back(act); // ??
1937 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"),
1938 sigc::ptr_fun (ProcessorBox::rb_paste));
1939 rename_action = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"),
1940 sigc::ptr_fun (ProcessorBox::rb_rename));
1941 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"),
1942 sigc::ptr_fun (ProcessorBox::rb_select_all));
1943 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"),
1944 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
1946 /* activation etc. */
1948 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate all"),
1949 sigc::ptr_fun (ProcessorBox::rb_activate_all));
1950 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate all"),
1951 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
1952 ActionManager::register_action (popup_act_grp, X_("ab_plugins"), _("A/B Plugins"),
1953 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
1956 edit_action = ActionManager::register_action (
1957 popup_act_grp, X_("edit"), _("Edit..."),
1958 sigc::ptr_fun (ProcessorBox::rb_edit));
1960 /* show plugin GUI */
1961 controls_action = ActionManager::register_action (
1962 popup_act_grp, X_("controls"), _("Controls..."),
1963 sigc::ptr_fun (ProcessorBox::rb_controls));
1965 ActionManager::add_action_group (popup_act_grp);
1969 ProcessorBox::rb_ab_plugins ()
1971 if (_current_processor_box == 0) {
1975 _current_processor_box->ab_plugins ();
1979 ProcessorBox::rb_choose_plugin ()
1981 if (_current_processor_box == 0) {
1984 _current_processor_box->choose_plugin ();
1988 ProcessorBox::rb_choose_insert ()
1990 if (_current_processor_box == 0) {
1993 _current_processor_box->choose_insert ();
1997 ProcessorBox::rb_choose_send ()
1999 if (_current_processor_box == 0) {
2002 _current_processor_box->choose_send ();
2006 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
2008 if (_current_processor_box == 0) {
2012 _current_processor_box->choose_aux (wr);
2016 ProcessorBox::rb_clear ()
2018 if (_current_processor_box == 0) {
2022 _current_processor_box->clear_processors ();
2027 ProcessorBox::rb_clear_pre ()
2029 if (_current_processor_box == 0) {
2033 _current_processor_box->clear_processors (PreFader);
2038 ProcessorBox::rb_clear_post ()
2040 if (_current_processor_box == 0) {
2044 _current_processor_box->clear_processors (PostFader);
2048 ProcessorBox::rb_cut ()
2050 if (_current_processor_box == 0) {
2054 _current_processor_box->processor_operation (ProcessorsCut);
2058 ProcessorBox::rb_delete ()
2060 if (_current_processor_box == 0) {
2064 _current_processor_box->processor_operation (ProcessorsDelete);
2068 ProcessorBox::rb_copy ()
2070 if (_current_processor_box == 0) {
2073 _current_processor_box->processor_operation (ProcessorsCopy);
2077 ProcessorBox::rb_paste ()
2079 if (_current_processor_box == 0) {
2083 _current_processor_box->processor_operation (ProcessorsPaste);
2087 ProcessorBox::rb_rename ()
2089 if (_current_processor_box == 0) {
2092 _current_processor_box->rename_processors ();
2096 ProcessorBox::rb_select_all ()
2098 if (_current_processor_box == 0) {
2102 _current_processor_box->processor_operation (ProcessorsSelectAll);
2106 ProcessorBox::rb_deselect_all ()
2108 if (_current_processor_box == 0) {
2112 _current_processor_box->deselect_all_processors ();
2116 ProcessorBox::rb_activate_all ()
2118 if (_current_processor_box == 0) {
2122 _current_processor_box->all_processors_active (true);
2126 ProcessorBox::rb_deactivate_all ()
2128 if (_current_processor_box == 0) {
2131 _current_processor_box->all_processors_active (false);
2135 ProcessorBox::rb_edit ()
2137 if (_current_processor_box == 0) {
2141 _current_processor_box->for_selected_processors (&ProcessorBox::toggle_edit_processor);
2145 ProcessorBox::rb_controls ()
2147 if (_current_processor_box == 0) {
2151 _current_processor_box->for_selected_processors (&ProcessorBox::toggle_processor_controls);
2155 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
2157 if (!what_changed.contains (ARDOUR::Properties::name)) {
2161 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
2163 boost::shared_ptr<Processor> processor;
2164 boost::shared_ptr<PluginInsert> plugin_insert;
2165 boost::shared_ptr<Send> send;
2167 list<ProcessorEntry*> children = processor_display.children();
2169 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
2171 processor = (*iter)->processor ();
2173 Window* w = get_processor_ui (processor);
2179 /* rename editor windows for sends and plugins */
2181 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
2182 w->set_title (send->name ());
2183 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
2184 w->set_title (generate_processor_title (plugin_insert));
2190 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
2192 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
2193 string::size_type email_pos;
2195 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
2196 maker = maker.substr (0, email_pos - 1);
2199 if (maker.length() > 32) {
2200 maker = maker.substr (0, 32);
2204 return string_compose(_("%1: %2 (by %3)"), _route->name(), pi->name(), maker);
2208 ProcessorBox::on_size_allocate (Allocation& a)
2210 HBox::on_size_allocate (a);
2212 list<ProcessorEntry*> children = processor_display.children ();
2213 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
2214 (*i)->set_pixel_width (a.get_width ());
2218 /** @param p Processor.
2219 * @return the UI window for \a p.
2222 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
2224 list<ProcessorWindowProxy*>::const_iterator i = _processor_window_proxies.begin ();
2225 while (i != _processor_window_proxies.end()) {
2226 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2228 return (*i)->get ();
2234 /* we shouldn't get here, because the ProcessorUIList should always contain
2235 an entry for each processor.
2241 /** Make a note of the UI window that a processor is using.
2242 * @param p Processor.
2243 * @param w UI window.
2246 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
2248 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin ();
2252 while (i != _processor_window_proxies.end()) {
2253 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2262 /* we shouldn't get here, because the ProcessorUIList should always contain
2263 an entry for each processor.
2269 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
2271 boost::shared_ptr<Delivery> d = w.lock ();
2276 list<ProcessorEntry*> children = processor_display.children ();
2277 list<ProcessorEntry*>::const_iterator i = children.begin();
2278 while (i != children.end() && (*i)->processor() != d) {
2282 if (i == children.end()) {
2283 processor_display.set_active (0);
2285 processor_display.set_active (*i);
2290 ProcessorBox::hide_things ()
2292 list<ProcessorEntry*> c = processor_display.children ();
2293 for (list<ProcessorEntry*>::iterator i = c.begin(); i != c.end(); ++i) {
2294 (*i)->hide_things ();
2299 ProcessorBox::processor_menu_unmapped ()
2301 processor_display.remove_placeholder ();
2304 ProcessorWindowProxy::ProcessorWindowProxy (
2305 string const & name,
2306 XMLNode const * node,
2308 boost::weak_ptr<Processor> processor
2310 : WindowProxy<Gtk::Window> (name, node)
2312 , _processor_box (box)
2313 , _processor (processor)
2320 ProcessorWindowProxy::show ()
2322 boost::shared_ptr<Processor> p = _processor.lock ();
2327 _processor_box->toggle_edit_processor (p);