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 (CairoWidget::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());
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());
125 ProcessorEntry::action_widget ()
131 ProcessorEntry::widget ()
137 ProcessorEntry::drag_text () const
143 ProcessorEntry::set_position (Position p)
150 ProcessorEntry::set_visual_state (Gtk::StateType t)
152 /* map from GTK state to CairoWidget */
155 case Gtk::STATE_ACTIVE:
156 _button.set_active_state (CairoWidget::Active);
157 _button.unset_visual_state ();
160 case Gtk::STATE_SELECTED:
161 _button.set_visual_state (CairoWidget::Selected);
164 case Gtk::STATE_NORMAL:
166 _button.unset_visual_state ();
167 _button.unset_active_state ();
173 ProcessorEntry::setup_visuals ()
177 _button.set_name ("processor prefader");
181 _button.set_name ("processor fader");
185 _button.set_name ("processor postfader");
191 boost::shared_ptr<Processor>
192 ProcessorEntry::processor () const
198 ProcessorEntry::set_enum_width (Width w)
204 ProcessorEntry::led_clicked()
206 if (_button.active_state() == CairoWidget::Active) {
207 _processor->deactivate ();
209 _processor->activate ();
214 ProcessorEntry::processor_active_changed ()
216 if (_processor->active()) {
217 _button.set_active_state (CairoWidget::Active);
219 _button.unset_active_state ();
224 ProcessorEntry::processor_property_changed (const PropertyChange& what_changed)
226 if (what_changed.contains (ARDOUR::Properties::name)) {
227 _button.set_text (name ());
232 ProcessorEntry::name () const
234 boost::shared_ptr<Send> send;
237 if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
238 !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
242 /* grab the send name out of its overall name */
244 string::size_type lbracket, rbracket;
245 lbracket = send->name().find ('[');
246 rbracket = send->name().find (']');
250 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
253 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
261 name_display += _processor->display_name();
264 name_display += PBD::short_version (_processor->display_name(), 5);
273 SendProcessorEntry::SendProcessorEntry (boost::shared_ptr<Send> s, Width w)
274 : ProcessorEntry (s, w)
276 , _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1)
277 , _fader (_slider, &_adjustment, 0, false)
278 , _ignore_gain_change (false)
279 , _data_type (DataType::AUDIO)
281 _fader.set_name ("SendFader");
282 _fader.set_controllable (_send->amp()->gain_control ());
283 _vbox.pack_start (_fader);
287 _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &SendProcessorEntry::gain_adjusted));
289 _send->amp()->gain_control()->Changed.connect (
290 _send_connections, invalidator (*this), boost::bind (&SendProcessorEntry::show_gain, this), gui_context()
293 _send->amp()->ConfigurationChanged.connect (
294 _send_connections, invalidator (*this), ui_bind (&SendProcessorEntry::setup_gain_adjustment, this), gui_context ()
297 setup_gain_adjustment ();
302 SendProcessorEntry::setup_gain_adjustment ()
304 if (_send->amp()->output_streams().n_midi() == 0) {
305 _data_type = DataType::AUDIO;
306 _adjustment.set_lower (0);
307 _adjustment.set_upper (1);
308 _adjustment.set_step_increment (0.01);
309 _adjustment.set_page_increment (0.1);
310 _fader.set_default_value (gain_to_slider_position (1));
312 _data_type = DataType::MIDI;
313 _adjustment.set_lower (0);
314 _adjustment.set_upper (2);
315 _adjustment.set_step_increment (0.05);
316 _adjustment.set_page_increment (0.1);
317 _fader.set_default_value (1);
322 SendProcessorEntry::setup_slider_pix ()
324 _slider = ::get_icon ("fader_belt_h_thin");
329 SendProcessorEntry::show_gain ()
333 switch (_data_type) {
334 case DataType::AUDIO:
335 value = gain_to_slider_position_with_max (_send->amp()->gain (), Config->get_max_gain());
338 value = _send->amp()->gain ();
342 if (_adjustment.get_value() != value) {
343 _ignore_gain_change = true;
344 _adjustment.set_value (value);
345 _ignore_gain_change = false;
349 s.setf (ios::fixed, ios::floatfield);
350 s << accurate_coefficient_to_dB (_send->amp()->gain ());
351 if (_data_type == DataType::AUDIO) {
355 _fader.set_tooltip_text (s.str ());
360 SendProcessorEntry::gain_adjusted ()
362 if (_ignore_gain_change) {
368 switch (_data_type) {
369 case DataType::AUDIO:
370 value = slider_position_to_gain_with_max (_adjustment.get_value(), Config->get_max_gain());
373 value = _adjustment.get_value ();
376 _send->amp()->set_gain (value, this);
380 SendProcessorEntry::set_pixel_width (int p)
382 _fader.set_fader_length (p);
385 PluginInsertProcessorEntry::PluginInsertProcessorEntry (boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
386 : ProcessorEntry (p, w)
389 p->SplittingChanged.connect (
390 _splitting_connection, invalidator (*this), ui_bind (&PluginInsertProcessorEntry::plugin_insert_splitting_changed, this), gui_context()
393 _splitting_icon.set_size_request (-1, 12);
395 _vbox.pack_start (_splitting_icon);
396 _vbox.reorder_child (_splitting_icon, 0);
398 plugin_insert_splitting_changed ();
402 PluginInsertProcessorEntry::plugin_insert_splitting_changed ()
404 if (_plugin_insert->splitting ()) {
405 _splitting_icon.show ();
407 _splitting_icon.hide ();
412 PluginInsertProcessorEntry::hide_things ()
414 plugin_insert_splitting_changed ();
418 PluginInsertProcessorEntry::setup_visuals ()
422 _splitting_icon.set_name ("ProcessorPreFader");
426 _splitting_icon.set_name ("ProcessorFader");
430 _splitting_icon.set_name ("ProcessorPostFader");
434 ProcessorEntry::setup_visuals ();
438 PluginInsertProcessorEntry::SplittingIcon::on_expose_event (GdkEventExpose* ev)
440 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
442 cairo_set_line_width (cr, 1);
444 double const width = ev->area.width;
445 double const height = ev->area.height;
447 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
448 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
450 cairo_rectangle (cr, 0, 0, width, height);
453 Gdk::Color const fg = get_style()->get_fg (STATE_NORMAL);
454 cairo_set_source_rgb (cr, fg.get_red_p (), fg.get_green_p (), fg.get_blue_p ());
456 cairo_move_to (cr, width * 0.3, height);
457 cairo_line_to (cr, width * 0.3, height * 0.5);
458 cairo_line_to (cr, width * 0.7, height * 0.5);
459 cairo_line_to (cr, width * 0.7, height);
460 cairo_move_to (cr, width * 0.5, height * 0.5);
461 cairo_line_to (cr, width * 0.5, 0);
467 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
468 RouteRedirectSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
469 : _parent_strip (parent)
470 , _owner_is_mixer (owner_is_mixer)
471 , ab_direction (true)
472 , _get_plugin_selector (get_plugin_selector)
474 , _rr_selection(rsel)
480 send_action_menu = 0;
481 no_processor_redisplay = false;
483 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
484 processor_scroller.add (processor_display);
485 pack_start (processor_scroller, true, true);
487 processor_display.set_flags (CAN_FOCUS);
488 processor_display.set_name ("ProcessorList");
489 processor_display.set_size_request (48, -1);
490 processor_display.set_data ("processorbox", this);
491 processor_display.set_spacing (2);
493 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
494 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
496 processor_display.signal_key_press_event().connect (sigc::mem_fun(*this, &ProcessorBox::processor_key_press_event));
497 processor_display.signal_key_release_event().connect (sigc::mem_fun(*this, &ProcessorBox::processor_key_release_event));
499 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
500 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
502 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
503 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
504 processor_display.SelectionChanged.connect (sigc::mem_fun (*this, &ProcessorBox::selection_changed));
506 processor_scroller.show ();
507 processor_display.show ();
510 parent->DeliveryChanged.connect (
511 _mixer_strip_connections, invalidator (*this), ui_bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
516 ProcessorBox::~ProcessorBox ()
521 ProcessorBox::set_route (boost::shared_ptr<Route> r)
527 _route_connections.drop_connections();
529 /* new route: any existing block on processor redisplay must be meaningless */
530 no_processor_redisplay = false;
533 _route->processors_changed.connect (
534 _route_connections, invalidator (*this), ui_bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
537 _route->DropReferences.connect (
538 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
541 _route->PropertyChanged.connect (
542 _route_connections, invalidator (*this), ui_bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
545 redisplay_processors ();
549 ProcessorBox::route_going_away ()
551 /* don't keep updating display as processors are deleted */
552 no_processor_redisplay = true;
557 ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
559 boost::shared_ptr<Processor> p;
561 p = position->processor ();
564 list<ProcessorEntry*> children = source->selection ();
565 list<boost::shared_ptr<Processor> > procs;
566 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
567 procs.push_back ((*i)->processor ());
570 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
571 XMLNode& state = (*i)->get_state ();
573 nlist.push_back (&state);
574 paste_processor_state (nlist, p);
578 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
582 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
583 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
585 cerr << "source was another processor box, delete the selected items\n";
586 other->delete_dragged_processors (procs);
592 ProcessorBox::update()
594 redisplay_processors ();
598 ProcessorBox::set_width (Width w)
606 list<ProcessorEntry*> children = processor_display.children ();
607 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
608 (*i)->set_enum_width (w);
611 redisplay_processors ();
615 ProcessorBox::build_send_action_menu ()
617 using namespace Menu_Helpers;
619 send_action_menu = new Menu;
620 send_action_menu->set_name ("ArdourContextMenu");
621 MenuList& items = send_action_menu->items();
623 items.push_back (MenuElem (_("New send"), sigc::mem_fun(*this, &ProcessorBox::new_send)));
624 items.push_back (MenuElem (_("Show send controls"), sigc::mem_fun(*this, &ProcessorBox::show_send_controls)));
628 ProcessorBox::build_possible_aux_menu ()
630 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
636 using namespace Menu_Helpers;
637 Menu* menu = manage (new Menu);
638 MenuList& items = menu->items();
640 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
641 if (!_route->internal_send_for (*r) && *r != _route) {
642 items.push_back (MenuElem ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
650 ProcessorBox::show_send_controls ()
655 ProcessorBox::new_send ()
660 ProcessorBox::show_processor_menu (int arg)
662 if (processor_menu == 0) {
663 processor_menu = build_processor_menu ();
664 processor_menu->signal_unmap().connect (sigc::mem_fun (*this, &ProcessorBox::processor_menu_unmapped));
667 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newplugin"));
669 if (plugin_menu_item) {
670 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
673 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newaux"));
676 Menu* m = build_possible_aux_menu();
677 if (m && !m->items().empty()) {
678 aux_menu_item->set_submenu (*m);
679 aux_menu_item->set_sensitive (true);
681 /* stupid gtkmm: we need to pass a null reference here */
682 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
683 aux_menu_item->set_sensitive (false);
687 cut_action->set_sensitive (can_cut());
688 paste_action->set_sensitive (!_rr_selection.processors.empty());
690 processor_menu->popup (1, arg);
692 /* Add a placeholder gap to the processor list to indicate where a processor would be
693 inserted were one chosen from the menu.
696 processor_display.get_pointer (x, y);
697 _placement = processor_display.add_placeholder (y);
701 ProcessorBox::enter_notify (GdkEventCrossing*)
703 _current_processor_box = this;
704 Keyboard::magic_widget_grab_focus ();
705 processor_display.grab_focus ();
711 ProcessorBox::leave_notify (GdkEventCrossing* ev)
713 switch (ev->detail) {
714 case GDK_NOTIFY_INFERIOR:
717 Keyboard::magic_widget_drop_focus ();
724 ProcessorBox::processor_key_press_event (GdkEventKey *)
726 /* do real stuff on key release */
731 ProcessorBox::processor_key_release_event (GdkEventKey *ev)
734 ProcSelection targets;
736 get_selected_processors (targets);
738 if (targets.empty()) {
741 processor_display.get_pointer (x, y);
743 pair<ProcessorEntry *, double> const pointer = processor_display.get_child_at_position (y);
746 targets.push_back (pointer.first->processor ());
751 switch (ev->keyval) {
753 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
754 processor_display.select_all ();
760 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
761 copy_processors (targets);
767 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
768 cut_processors (targets);
774 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
775 if (targets.empty()) {
778 paste_processors (targets.front());
792 delete_processors (targets);
797 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
798 if ((*i)->active()) {
820 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
822 boost::shared_ptr<Processor> processor;
824 processor = child->processor ();
828 bool selected = processor_display.selected (child);
830 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
832 if (_session->engine().connected()) {
833 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
834 toggle_edit_processor (processor);
838 } else if (processor && ev->button == 1 && selected) {
840 // this is purely informational but necessary for route params UI
841 ProcessorSelected (processor); // emit
843 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
846 _get_plugin_selector()->show_manager ();
853 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
855 boost::shared_ptr<Processor> processor;
857 processor = child->processor ();
860 if (processor && Keyboard::is_delete_event (ev)) {
862 Glib::signal_idle().connect (sigc::bind (
863 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
864 boost::weak_ptr<Processor>(processor)));
866 } else if (Keyboard::is_context_menu_event (ev)) {
868 show_processor_menu (ev->time);
870 } else if (processor && Keyboard::is_button2_event (ev)
872 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
876 /* button2-click with no/appropriate modifiers */
878 if (processor->active()) {
879 processor->deactivate ();
881 processor->activate ();
889 ProcessorBox::build_processor_menu ()
891 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/ProcessorMenu") );
892 processor_menu->set_name ("ArdourContextMenu");
893 return processor_menu;
897 ProcessorBox::selection_changed ()
899 const bool sensitive = !processor_display.selection().empty();
900 ActionManager::set_sensitive(ActionManager::plugin_selection_sensitive_actions,
902 edit_action->set_sensitive(one_processor_can_be_edited());
904 const bool single_selection = (processor_display.selection().size() == 1);
906 boost::shared_ptr<PluginInsert> pi;
907 if (single_selection) {
908 pi = boost::dynamic_pointer_cast<PluginInsert>(
909 processor_display.selection().front()->processor());
912 /* enable gui for plugin inserts with editors */
913 controls_action->set_sensitive(pi && pi->plugin()->has_editor());
915 /* disallow rename for multiple selections and for plugin inserts */
916 rename_action->set_sensitive(single_selection && pi);
920 ProcessorBox::select_all_processors ()
922 processor_display.select_all ();
926 ProcessorBox::deselect_all_processors ()
928 processor_display.select_none ();
932 ProcessorBox::choose_plugin ()
934 _get_plugin_selector()->set_interested_object (*this);
937 /** @return true if an error occurred, otherwise false */
939 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
941 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
943 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
945 Route::ProcessorStreams err_streams;
947 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
948 weird_plugin_dialog (**p, err_streams);
950 // XXX SHAREDPTR delete plugin here .. do we even need to care?
953 if (Profile->get_sae()) {
954 processor->activate ();
963 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
965 ArdourDialog dialog (_("Plugin Incompatibility"));
968 string text = string_compose(_("You attempted to add the plugin \"%1\" in slot %2.\n"),
969 p.name(), streams.index);
971 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
972 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
974 text += _("\nThis plugin has:\n");
976 uint32_t const n = p.get_info()->n_inputs.n_midi ();
977 text += string_compose (ngettext ("\t%1 MIDI input\n", "\t%1 MIDI inputs\n", n), n);
980 uint32_t const n = p.get_info()->n_inputs.n_audio ();
981 text += string_compose (ngettext ("\t%1 audio input\n", "\t%1 audio inputs\n", n), n);
984 text += _("\nbut at the insertion point, there are:\n");
986 uint32_t const n = streams.count.n_midi ();
987 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
990 uint32_t const n = streams.count.n_audio ();
991 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
994 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
995 label.set_text(text);
997 dialog.get_vbox()->pack_start (label);
998 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1000 dialog.set_name (X_("PluginIODialog"));
1001 dialog.set_position (Gtk::WIN_POS_MOUSE);
1002 dialog.set_modal (true);
1009 ProcessorBox::choose_insert ()
1011 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->pannable(), _route->mute_master()));
1012 _route->add_processor_by_index (processor, _placement);
1015 /* Caller must not hold process lock */
1017 ProcessorBox::choose_send ()
1019 boost::shared_ptr<Send> send (new Send (*_session, _route->pannable(), _route->mute_master()));
1021 /* make an educated guess at the initial number of outputs for the send */
1022 ChanCount outs = (_session->master_out())
1023 ? _session->master_out()->n_outputs()
1024 : _route->n_outputs();
1026 /* XXX need processor lock on route */
1028 Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock());
1029 send->output()->ensure_io (outs, false, this);
1030 } catch (AudioEngine::PortRegistrationFailure& err) {
1031 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
1035 /* let the user adjust the IO setup before creation.
1037 Note: this dialog is NOT modal - we just leave it to run and it will
1038 return when its Finished signal is emitted - typically when the window
1042 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
1045 /* keep a reference to the send so it doesn't get deleted while
1046 the IOSelectorWindow is doing its stuff
1048 _processor_being_created = send;
1050 ios->selector().Finished.connect (sigc::bind (
1051 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
1052 boost::weak_ptr<Processor>(send), ios));
1057 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1059 boost::shared_ptr<Processor> processor (weak_processor.lock());
1061 /* drop our temporary reference to the new send */
1062 _processor_being_created.reset ();
1069 case IOSelector::Cancelled:
1070 // processor will go away when all shared_ptrs to it vanish
1073 case IOSelector::Accepted:
1074 _route->add_processor_by_index (processor, _placement);
1075 if (Profile->get_sae()) {
1076 processor->activate ();
1081 delete_when_idle (ios);
1085 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1087 boost::shared_ptr<Processor> processor (weak_processor.lock());
1089 /* drop our temporary reference to the new return */
1090 _processor_being_created.reset ();
1097 case IOSelector::Cancelled:
1098 // processor will go away when all shared_ptrs to it vanish
1101 case IOSelector::Accepted:
1102 _route->add_processor_by_index (processor, _placement);
1103 if (Profile->get_sae()) {
1104 processor->activate ();
1109 delete_when_idle (ios);
1113 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
1119 boost::shared_ptr<Route> target = wr.lock();
1125 boost::shared_ptr<RouteList> rlist (new RouteList);
1126 rlist->push_back (_route);
1128 _session->add_internal_sends (target, PreFader, rlist);
1132 ProcessorBox::route_processors_changed (RouteProcessorChange c)
1134 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
1135 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
1139 redisplay_processors ();
1143 ProcessorBox::redisplay_processors ()
1145 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors)
1147 if (no_processor_redisplay) {
1151 processor_display.clear ();
1153 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
1155 for (list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin(); i != _processor_window_proxies.end(); ++i) {
1156 (*i)->marked = false;
1159 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
1161 /* trim dead wood from the processor window proxy list */
1163 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin();
1164 while (i != _processor_window_proxies.end()) {
1165 list<ProcessorWindowProxy*>::iterator j = i;
1168 if (!(*i)->marked) {
1169 ARDOUR_UI::instance()->remove_window_proxy (*i);
1171 _processor_window_proxies.erase (i);
1177 setup_entry_positions ();
1180 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
1181 * not already have one.
1184 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
1186 boost::shared_ptr<Processor> p = w.lock ();
1191 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin ();
1192 while (i != _processor_window_proxies.end()) {
1194 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
1197 /* this processor is already on the list; done */
1198 (*i)->marked = true;
1205 /* not on the list; add it */
1208 if (_parent_strip) {
1209 if (_parent_strip->mixer_owned()) {
1218 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
1219 string_compose ("%1-%2-%3", loc, _route->id(), p->id()),
1220 _session->extra_xml (X_("UI")),
1226 /* if the processor already has an existing UI,
1227 note that so that we don't recreate it
1230 void* existing_ui = p->get_ui ();
1233 wp->set (static_cast<Gtk::Window*>(existing_ui));
1236 _processor_window_proxies.push_back (wp);
1237 ARDOUR_UI::instance()->add_window_proxy (wp);
1241 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
1243 boost::shared_ptr<Processor> processor (p.lock ());
1245 if (!processor || !processor->display_to_user()) {
1249 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
1250 boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
1251 ProcessorEntry* e = 0;
1253 e = new SendProcessorEntry (send, _width);
1254 } else if (plugin_insert) {
1255 e = new PluginInsertProcessorEntry (plugin_insert, _width);
1257 e = new ProcessorEntry (processor, _width);
1260 e->set_pixel_width (get_allocation().get_width());
1261 processor_display.add_child (e);
1266 ProcessorBox::build_processor_tooltip (EventBox& box, string start)
1270 list<ProcessorEntry*> children = processor_display.children ();
1271 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1273 tip += (*i)->processor()->name();
1276 ARDOUR_UI::instance()->set_tip (box, tip);
1280 ProcessorBox::reordered ()
1282 compute_processor_sort_keys ();
1283 setup_entry_positions ();
1287 ProcessorBox::setup_entry_positions ()
1289 list<ProcessorEntry*> children = processor_display.children ();
1290 bool pre_fader = true;
1292 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1293 if (boost::dynamic_pointer_cast<Amp>((*i)->processor())) {
1295 (*i)->set_position (ProcessorEntry::Fader);
1298 (*i)->set_position (ProcessorEntry::PreFader);
1300 (*i)->set_position (ProcessorEntry::PostFader);
1307 ProcessorBox::compute_processor_sort_keys ()
1309 list<ProcessorEntry*> children = processor_display.children ();
1310 Route::ProcessorList our_processors;
1312 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
1313 our_processors.push_back ((*iter)->processor ());
1316 if (_route->reorder_processors (our_processors)) {
1317 /* Reorder failed, so report this to the user. As far as I can see this must be done
1318 in an idle handler: it seems that the redisplay_processors() that happens below destroys
1319 widgets that were involved in the drag-and-drop on the processor list, which causes problems
1320 when the drag is torn down after this handler function is finished.
1322 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
1327 ProcessorBox::report_failed_reorder ()
1329 /* reorder failed, so redisplay */
1331 redisplay_processors ();
1333 /* now tell them about the problem */
1335 ArdourDialog dialog (_("Plugin Incompatibility"));
1338 label.set_text (_("\
1339 You cannot reorder these plugins/sends/inserts\n\
1340 in that way because the inputs and\n\
1341 outputs will not work correctly."));
1343 dialog.get_vbox()->set_border_width (12);
1344 dialog.get_vbox()->pack_start (label);
1345 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1347 dialog.set_name (X_("PluginIODialog"));
1348 dialog.set_position (Gtk::WIN_POS_MOUSE);
1349 dialog.set_modal (true);
1356 ProcessorBox::rename_processors ()
1358 ProcSelection to_be_renamed;
1360 get_selected_processors (to_be_renamed);
1362 if (to_be_renamed.empty()) {
1366 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
1367 rename_processor (*i);
1372 ProcessorBox::can_cut () const
1374 vector<boost::shared_ptr<Processor> > sel;
1376 get_selected_processors (sel);
1378 /* cut_processors () does not cut inserts */
1380 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
1382 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1383 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1384 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1393 ProcessorBox::cut_processors ()
1395 ProcSelection to_be_removed;
1397 get_selected_processors (to_be_removed);
1401 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
1403 if (to_be_removed.empty()) {
1407 XMLNode* node = new XMLNode (X_("cut"));
1408 Route::ProcessorList to_cut;
1410 no_processor_redisplay = true;
1411 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
1412 // Cut only plugins, sends and returns
1413 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1414 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1415 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1417 Window* w = get_processor_ui (*i);
1423 XMLNode& child ((*i)->get_state());
1424 node->add_child_nocopy (child);
1425 to_cut.push_back (*i);
1429 if (_route->remove_processors (to_cut) != 0) {
1431 no_processor_redisplay = false;
1435 _rr_selection.set (node);
1437 no_processor_redisplay = false;
1438 redisplay_processors ();
1442 ProcessorBox::copy_processors ()
1444 ProcSelection to_be_copied;
1445 get_selected_processors (to_be_copied);
1446 copy_processors (to_be_copied);
1450 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
1452 if (to_be_copied.empty()) {
1456 XMLNode* node = new XMLNode (X_("copy"));
1458 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
1459 // Copy only plugins, sends, returns
1460 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1461 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1462 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1463 node->add_child_nocopy ((*i)->get_state());
1467 _rr_selection.set (node);
1471 ProcessorBox::delete_processors ()
1473 ProcSelection to_be_deleted;
1474 get_selected_processors (to_be_deleted);
1475 delete_processors (to_be_deleted);
1479 ProcessorBox::delete_processors (const ProcSelection& targets)
1481 if (targets.empty()) {
1485 no_processor_redisplay = true;
1487 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
1489 Window* w = get_processor_ui (*i);
1495 _route->remove_processor(*i);
1498 no_processor_redisplay = false;
1499 redisplay_processors ();
1503 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
1505 list<boost::shared_ptr<Processor> >::const_iterator x;
1507 no_processor_redisplay = true;
1508 for (x = procs.begin(); x != procs.end(); ++x) {
1510 Window* w = get_processor_ui (*x);
1516 _route->remove_processor(*x);
1519 no_processor_redisplay = false;
1520 redisplay_processors ();
1524 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
1526 boost::shared_ptr<Processor> processor (weak_processor.lock());
1532 /* NOT copied to _mixer.selection() */
1534 no_processor_redisplay = true;
1535 _route->remove_processor (processor);
1536 no_processor_redisplay = false;
1537 redisplay_processors ();
1543 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
1545 ArdourPrompter name_prompter (true);
1547 name_prompter.set_title (_("Rename Processor"));
1548 name_prompter.set_prompt (_("New name:"));
1549 name_prompter.set_initial_text (processor->name());
1550 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
1551 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
1552 name_prompter.show_all ();
1554 switch (name_prompter.run ()) {
1556 case Gtk::RESPONSE_ACCEPT:
1557 name_prompter.get_result (result);
1558 if (result.length()) {
1561 string test = result;
1563 while (tries < 100) {
1564 if (_session->io_name_is_legal (test)) {
1570 test = string_compose ("%1-%2", result, tries);
1574 processor->set_name (result);
1577 ARDOUR_UI::instance()->popup_error
1578 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
1588 ProcessorBox::paste_processors ()
1590 if (_rr_selection.processors.empty()) {
1594 paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
1598 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
1601 if (_rr_selection.processors.empty()) {
1605 paste_processor_state (_rr_selection.processors.get_node().children(), before);
1609 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
1611 XMLNodeConstIterator niter;
1612 list<boost::shared_ptr<Processor> > copies;
1614 if (nlist.empty()) {
1618 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1620 XMLProperty const * type = (*niter)->property ("type");
1623 boost::shared_ptr<Processor> p;
1625 if (type->value() == "meter" ||
1626 type->value() == "main-outs" ||
1627 type->value() == "amp" ||
1628 type->value() == "intsend" || type->value() == "intreturn") {
1629 /* do not paste meter, main outs, amp or internal send/returns */
1632 } else if (type->value() == "send") {
1634 XMLNode n (**niter);
1635 Send::make_unique (n, *_session);
1636 Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
1637 if (s->set_state (n, Stateful::loading_state_version)) {
1645 } else if (type->value() == "return") {
1647 XMLNode n (**niter);
1648 Return::make_unique (n, *_session);
1649 Return* r = new Return (*_session);
1651 if (r->set_state (n, Stateful::loading_state_version)) {
1658 } else if (type->value() == "port") {
1660 XMLNode n (**niter);
1661 p.reset (new PortInsert (*_session, _route->pannable (), _route->mute_master ()));
1662 if (p->set_state (n, Stateful::loading_state_version)) {
1667 /* XXX its a bit limiting to assume that everything else
1671 p.reset (new PluginInsert (*_session));
1672 p->set_state (**niter, Stateful::current_state_version);
1675 copies.push_back (p);
1679 cerr << "plugin insert constructor failed\n";
1683 if (copies.empty()) {
1687 if (_route->add_processors (copies, p)) {
1690 "Copying the set of processors on the clipboard failed,\n\
1691 probably because the I/O configuration of the plugins\n\
1692 could not match the configuration of this track.");
1693 MessageDialog am (msg);
1699 ProcessorBox::activate_processor (boost::shared_ptr<Processor> r)
1705 ProcessorBox::deactivate_processor (boost::shared_ptr<Processor> r)
1711 ProcessorBox::get_selected_processors (ProcSelection& processors) const
1713 const list<ProcessorEntry*> selection = processor_display.selection ();
1714 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
1715 processors.push_back ((*i)->processor ());
1720 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
1722 list<ProcessorEntry*> selection = processor_display.selection ();
1723 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
1724 (this->*method) ((*i)->processor ());
1729 ProcessorBox::all_processors_active (bool state)
1731 _route->all_processors_active (PreFader, state);
1732 _route->all_processors_active (PostFader, state);
1736 ProcessorBox::ab_plugins ()
1738 _route->ab_plugins (ab_direction);
1739 ab_direction = !ab_direction;
1744 ProcessorBox::clear_processors ()
1747 vector<string> choices;
1749 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
1750 "(this cannot be undone)"), _route->name());
1752 choices.push_back (_("Cancel"));
1753 choices.push_back (_("Yes, remove them all"));
1755 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1757 if (prompter.run () == 1) {
1758 _route->clear_processors (PreFader);
1759 _route->clear_processors (PostFader);
1764 ProcessorBox::clear_processors (Placement p)
1767 vector<string> choices;
1769 if (p == PreFader) {
1770 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
1771 "(this cannot be undone)"), _route->name());
1773 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
1774 "(this cannot be undone)"), _route->name());
1777 choices.push_back (_("Cancel"));
1778 choices.push_back (_("Yes, remove them all"));
1780 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1782 if (prompter.run () == 1) {
1783 _route->clear_processors (p);
1788 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
1790 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
1791 if (at && at->freeze_state() == AudioTrack::Frozen) {
1796 boost::dynamic_pointer_cast<Send> (processor) ||
1797 boost::dynamic_pointer_cast<Return> (processor) ||
1798 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
1799 boost::dynamic_pointer_cast<PortInsert> (processor)
1808 ProcessorBox::one_processor_can_be_edited ()
1810 list<ProcessorEntry*> selection = processor_display.selection ();
1811 list<ProcessorEntry*>::iterator i = selection.begin();
1812 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
1816 return (i != selection.end());
1820 ProcessorBox::toggle_edit_processor (boost::shared_ptr<Processor> processor)
1822 boost::shared_ptr<Send> send;
1823 boost::shared_ptr<InternalSend> internal_send;
1824 boost::shared_ptr<Return> retrn;
1825 boost::shared_ptr<PluginInsert> plugin_insert;
1826 boost::shared_ptr<PortInsert> port_insert;
1829 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
1831 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
1836 if (boost::dynamic_pointer_cast<Amp> (processor)) {
1838 if (_parent_strip) {
1839 _parent_strip->revert_to_default_display ();
1842 } else if ((internal_send = boost::dynamic_pointer_cast<InternalSend> (processor)) != 0) {
1844 if (!_session->engine().connected()) {
1848 if (_parent_strip) {
1849 if (boost::dynamic_pointer_cast<Send> (_parent_strip->current_delivery()) == internal_send) {
1850 _parent_strip->revert_to_default_display ();
1852 _parent_strip->show_send (internal_send);
1856 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
1858 if (!_session->engine().connected()) {
1862 SendUIWindow* w = new SendUIWindow (send, _session);
1865 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
1867 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
1868 /* no GUI for these */
1872 if (!_session->engine().connected()) {
1876 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
1878 ReturnUIWindow *return_ui;
1879 Window* w = get_processor_ui (retrn);
1883 return_ui = new ReturnUIWindow (retrn, _session);
1884 return_ui->set_title (retrn->name ());
1885 set_processor_ui (send, return_ui);
1888 return_ui = dynamic_cast<ReturnUIWindow *> (w);
1893 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
1895 PluginUIWindow *plugin_ui;
1897 /* these are both allowed to be null */
1899 Container* toplevel = get_toplevel();
1900 Window* win = dynamic_cast<Gtk::Window*>(toplevel);
1902 Window* w = get_processor_ui (plugin_insert);
1906 plugin_ui = new PluginUIWindow (win, plugin_insert);
1907 plugin_ui->set_title (generate_processor_title (plugin_insert));
1908 set_processor_ui (plugin_insert, plugin_ui);
1911 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
1912 plugin_ui->set_parent (win);
1917 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
1919 if (!_session->engine().connected()) {
1920 MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible"));
1925 PortInsertWindow *io_selector;
1927 Window* w = get_processor_ui (port_insert);
1930 io_selector = new PortInsertWindow (_session, port_insert);
1931 set_processor_ui (port_insert, io_selector);
1934 io_selector = dynamic_cast<PortInsertWindow *> (w);
1937 gidget = io_selector;
1941 if (gidget->is_visible()) {
1944 gidget->show_all ();
1951 ProcessorBox::toggle_processor_controls (boost::shared_ptr<Processor> processor)
1953 boost::shared_ptr<PluginInsert> plugin_insert
1954 = boost::dynamic_pointer_cast<PluginInsert>(processor);
1955 if (!plugin_insert) {
1959 Container* toplevel = get_toplevel();
1960 Window* win = dynamic_cast<Gtk::Window*>(toplevel);
1961 PluginUIWindow* plugin_ui = new PluginUIWindow(win, plugin_insert, true, false);
1962 plugin_ui->set_title(generate_processor_title (plugin_insert));
1964 if (plugin_ui->is_visible()) {
1967 plugin_ui->show_all();
1968 plugin_ui->present();
1973 ProcessorBox::register_actions ()
1975 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("ProcessorMenu"));
1976 Glib::RefPtr<Action> act;
1979 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin"),
1980 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
1982 act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"),
1983 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
1984 ActionManager::jack_sensitive_actions.push_back (act);
1985 act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New Send ..."),
1986 sigc::ptr_fun (ProcessorBox::rb_choose_send));
1987 ActionManager::jack_sensitive_actions.push_back (act);
1989 ActionManager::register_action (popup_act_grp, X_("newaux"), _("New Aux Send ..."));
1991 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear (all)"),
1992 sigc::ptr_fun (ProcessorBox::rb_clear));
1993 ActionManager::register_action (popup_act_grp, X_("clear_pre"), _("Clear (pre-fader)"),
1994 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
1995 ActionManager::register_action (popup_act_grp, X_("clear_post"), _("Clear (post-fader)"),
1996 sigc::ptr_fun (ProcessorBox::rb_clear_post));
1998 /* standard editing stuff */
1999 cut_action = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"),
2000 sigc::ptr_fun (ProcessorBox::rb_cut));
2001 ActionManager::plugin_selection_sensitive_actions.push_back(cut_action);
2002 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),
2003 sigc::ptr_fun (ProcessorBox::rb_copy));
2004 ActionManager::plugin_selection_sensitive_actions.push_back(act);
2006 act = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"),
2007 sigc::ptr_fun (ProcessorBox::rb_delete));
2008 ActionManager::plugin_selection_sensitive_actions.push_back(act); // ??
2010 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"),
2011 sigc::ptr_fun (ProcessorBox::rb_paste));
2012 rename_action = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"),
2013 sigc::ptr_fun (ProcessorBox::rb_rename));
2014 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"),
2015 sigc::ptr_fun (ProcessorBox::rb_select_all));
2016 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"),
2017 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
2019 /* activation etc. */
2021 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate all"),
2022 sigc::ptr_fun (ProcessorBox::rb_activate_all));
2023 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate all"),
2024 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
2025 ActionManager::register_action (popup_act_grp, X_("ab_plugins"), _("A/B Plugins"),
2026 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
2029 edit_action = ActionManager::register_action (
2030 popup_act_grp, X_("edit"), _("Edit..."),
2031 sigc::ptr_fun (ProcessorBox::rb_edit));
2033 /* show plugin GUI */
2034 controls_action = ActionManager::register_action (
2035 popup_act_grp, X_("controls"), _("Controls..."),
2036 sigc::ptr_fun (ProcessorBox::rb_controls));
2038 ActionManager::add_action_group (popup_act_grp);
2042 ProcessorBox::rb_ab_plugins ()
2044 if (_current_processor_box == 0) {
2048 _current_processor_box->ab_plugins ();
2052 ProcessorBox::rb_choose_plugin ()
2054 if (_current_processor_box == 0) {
2057 _current_processor_box->choose_plugin ();
2061 ProcessorBox::rb_choose_insert ()
2063 if (_current_processor_box == 0) {
2066 _current_processor_box->choose_insert ();
2070 ProcessorBox::rb_choose_send ()
2072 if (_current_processor_box == 0) {
2075 _current_processor_box->choose_send ();
2079 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
2081 if (_current_processor_box == 0) {
2085 _current_processor_box->choose_aux (wr);
2089 ProcessorBox::rb_clear ()
2091 if (_current_processor_box == 0) {
2095 _current_processor_box->clear_processors ();
2100 ProcessorBox::rb_clear_pre ()
2102 if (_current_processor_box == 0) {
2106 _current_processor_box->clear_processors (PreFader);
2111 ProcessorBox::rb_clear_post ()
2113 if (_current_processor_box == 0) {
2117 _current_processor_box->clear_processors (PostFader);
2121 ProcessorBox::rb_cut ()
2123 if (_current_processor_box == 0) {
2127 _current_processor_box->cut_processors ();
2131 ProcessorBox::rb_delete ()
2133 if (_current_processor_box == 0) {
2137 _current_processor_box->delete_processors ();
2141 ProcessorBox::rb_copy ()
2143 if (_current_processor_box == 0) {
2146 _current_processor_box->copy_processors ();
2150 ProcessorBox::rb_paste ()
2152 if (_current_processor_box == 0) {
2156 _current_processor_box->paste_processors ();
2160 ProcessorBox::rb_rename ()
2162 if (_current_processor_box == 0) {
2165 _current_processor_box->rename_processors ();
2169 ProcessorBox::rb_select_all ()
2171 if (_current_processor_box == 0) {
2175 _current_processor_box->select_all_processors ();
2179 ProcessorBox::rb_deselect_all ()
2181 if (_current_processor_box == 0) {
2185 _current_processor_box->deselect_all_processors ();
2189 ProcessorBox::rb_activate_all ()
2191 if (_current_processor_box == 0) {
2195 _current_processor_box->all_processors_active (true);
2199 ProcessorBox::rb_deactivate_all ()
2201 if (_current_processor_box == 0) {
2204 _current_processor_box->all_processors_active (false);
2208 ProcessorBox::rb_edit ()
2210 if (_current_processor_box == 0) {
2214 _current_processor_box->for_selected_processors (&ProcessorBox::toggle_edit_processor);
2218 ProcessorBox::rb_controls ()
2220 if (_current_processor_box == 0) {
2224 _current_processor_box->for_selected_processors (&ProcessorBox::toggle_processor_controls);
2228 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
2230 if (!what_changed.contains (ARDOUR::Properties::name)) {
2234 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
2236 boost::shared_ptr<Processor> processor;
2237 boost::shared_ptr<PluginInsert> plugin_insert;
2238 boost::shared_ptr<Send> send;
2240 list<ProcessorEntry*> children = processor_display.children();
2242 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
2244 processor = (*iter)->processor ();
2246 Window* w = get_processor_ui (processor);
2252 /* rename editor windows for sends and plugins */
2254 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
2255 w->set_title (send->name ());
2256 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
2257 w->set_title (generate_processor_title (plugin_insert));
2263 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
2265 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
2266 string::size_type email_pos;
2268 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
2269 maker = maker.substr (0, email_pos - 1);
2272 if (maker.length() > 32) {
2273 maker = maker.substr (0, 32);
2277 return string_compose(_("%1: %2 (by %3)"), _route->name(), pi->name(), maker);
2281 ProcessorBox::on_size_allocate (Allocation& a)
2283 HBox::on_size_allocate (a);
2285 list<ProcessorEntry*> children = processor_display.children ();
2286 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
2287 (*i)->set_pixel_width (a.get_width ());
2291 /** @param p Processor.
2292 * @return the UI window for \a p.
2295 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
2297 list<ProcessorWindowProxy*>::const_iterator i = _processor_window_proxies.begin ();
2298 while (i != _processor_window_proxies.end()) {
2299 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2301 return (*i)->get ();
2307 /* we shouldn't get here, because the ProcessorUIList should always contain
2308 an entry for each processor.
2314 /** Make a note of the UI window that a processor is using.
2315 * @param p Processor.
2316 * @param w UI window.
2319 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
2321 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin ();
2325 while (i != _processor_window_proxies.end()) {
2326 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2335 /* we shouldn't get here, because the ProcessorUIList should always contain
2336 an entry for each processor.
2342 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
2344 boost::shared_ptr<Delivery> d = w.lock ();
2349 list<ProcessorEntry*> children = processor_display.children ();
2350 list<ProcessorEntry*>::const_iterator i = children.begin();
2351 while (i != children.end() && (*i)->processor() != d) {
2355 if (i == children.end()) {
2356 processor_display.set_active (0);
2358 processor_display.set_active (*i);
2363 ProcessorBox::hide_things ()
2365 list<ProcessorEntry*> c = processor_display.children ();
2366 for (list<ProcessorEntry*>::iterator i = c.begin(); i != c.end(); ++i) {
2367 (*i)->hide_things ();
2372 ProcessorBox::processor_menu_unmapped ()
2374 processor_display.remove_placeholder ();
2377 ProcessorWindowProxy::ProcessorWindowProxy (
2378 string const & name,
2379 XMLNode const * node,
2381 boost::weak_ptr<Processor> processor
2383 : WindowProxy<Gtk::Window> (name, node)
2385 , _processor_box (box)
2386 , _processor (processor)
2393 ProcessorWindowProxy::show ()
2395 boost::shared_ptr<Processor> p = _processor.lock ();
2400 _processor_box->toggle_edit_processor (p);