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());
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 (Gtkmm2ext::VisualState s, bool yn)
153 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() | s));
155 _button.set_visual_state (Gtkmm2ext::VisualState (_button.visual_state() & ~s));
160 ProcessorEntry::setup_visuals ()
164 _button.set_name ("processor prefader");
168 _button.set_name ("processor fader");
172 _button.set_name ("processor postfader");
178 boost::shared_ptr<Processor>
179 ProcessorEntry::processor () const
185 ProcessorEntry::set_enum_width (Width w)
191 ProcessorEntry::led_clicked()
193 if (_button.active_state() == Gtkmm2ext::Active) {
194 _processor->deactivate ();
196 _processor->activate ();
201 ProcessorEntry::processor_active_changed ()
203 if (_processor->active()) {
204 _button.set_active_state (Gtkmm2ext::Active);
206 _button.unset_active_state ();
211 ProcessorEntry::processor_property_changed (const PropertyChange& what_changed)
213 if (what_changed.contains (ARDOUR::Properties::name)) {
214 _button.set_text (name ());
219 ProcessorEntry::name () const
221 boost::shared_ptr<Send> send;
224 if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
225 !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
229 /* grab the send name out of its overall name */
231 string::size_type lbracket, rbracket;
232 lbracket = send->name().find ('[');
233 rbracket = send->name().find (']');
237 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
240 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
248 name_display += _processor->display_name();
251 name_display += PBD::short_version (_processor->display_name(), 5);
260 SendProcessorEntry::SendProcessorEntry (boost::shared_ptr<Send> s, Width w)
261 : ProcessorEntry (s, w)
263 , _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1)
264 , _fader (_slider, &_adjustment, 0, false)
265 , _ignore_gain_change (false)
266 , _data_type (DataType::AUDIO)
268 _fader.set_name ("SendFader");
269 _fader.set_controllable (_send->amp()->gain_control ());
270 _vbox.pack_start (_fader);
274 _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &SendProcessorEntry::gain_adjusted));
276 _send->amp()->gain_control()->Changed.connect (
277 _send_connections, invalidator (*this), boost::bind (&SendProcessorEntry::show_gain, this), gui_context()
280 _send->amp()->ConfigurationChanged.connect (
281 _send_connections, invalidator (*this), ui_bind (&SendProcessorEntry::setup_gain_adjustment, this), gui_context ()
284 setup_gain_adjustment ();
289 SendProcessorEntry::setup_gain_adjustment ()
291 if (_send->amp()->output_streams().n_midi() == 0) {
292 _data_type = DataType::AUDIO;
293 _adjustment.set_lower (0);
294 _adjustment.set_upper (1);
295 _adjustment.set_step_increment (0.01);
296 _adjustment.set_page_increment (0.1);
297 _fader.set_default_value (gain_to_slider_position (1));
299 _data_type = DataType::MIDI;
300 _adjustment.set_lower (0);
301 _adjustment.set_upper (2);
302 _adjustment.set_step_increment (0.05);
303 _adjustment.set_page_increment (0.1);
304 _fader.set_default_value (1);
309 SendProcessorEntry::setup_slider_pix ()
311 _slider = ::get_icon ("fader_belt_h_thin");
316 SendProcessorEntry::show_gain ()
320 switch (_data_type) {
321 case DataType::AUDIO:
322 value = gain_to_slider_position_with_max (_send->amp()->gain (), Config->get_max_gain());
325 value = _send->amp()->gain ();
329 if (_adjustment.get_value() != value) {
330 _ignore_gain_change = true;
331 _adjustment.set_value (value);
332 _ignore_gain_change = false;
336 s.setf (ios::fixed, ios::floatfield);
337 s << accurate_coefficient_to_dB (_send->amp()->gain ());
338 if (_data_type == DataType::AUDIO) {
342 _fader.set_tooltip_text (s.str ());
347 SendProcessorEntry::gain_adjusted ()
349 if (_ignore_gain_change) {
355 switch (_data_type) {
356 case DataType::AUDIO:
357 value = slider_position_to_gain_with_max (_adjustment.get_value(), Config->get_max_gain());
360 value = _adjustment.get_value ();
363 _send->amp()->set_gain (value, this);
367 SendProcessorEntry::set_pixel_width (int p)
369 _fader.set_fader_length (p);
372 PluginInsertProcessorEntry::PluginInsertProcessorEntry (boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
373 : ProcessorEntry (p, w)
376 p->SplittingChanged.connect (
377 _splitting_connection, invalidator (*this), ui_bind (&PluginInsertProcessorEntry::plugin_insert_splitting_changed, this), gui_context()
380 _splitting_icon.set_size_request (-1, 12);
382 _vbox.pack_start (_splitting_icon);
383 _vbox.reorder_child (_splitting_icon, 0);
385 plugin_insert_splitting_changed ();
389 PluginInsertProcessorEntry::plugin_insert_splitting_changed ()
391 if (_plugin_insert->splitting ()) {
392 _splitting_icon.show ();
394 _splitting_icon.hide ();
399 PluginInsertProcessorEntry::hide_things ()
401 plugin_insert_splitting_changed ();
405 PluginInsertProcessorEntry::setup_visuals ()
409 _splitting_icon.set_name ("ProcessorPreFader");
413 _splitting_icon.set_name ("ProcessorFader");
417 _splitting_icon.set_name ("ProcessorPostFader");
421 ProcessorEntry::setup_visuals ();
425 PluginInsertProcessorEntry::SplittingIcon::on_expose_event (GdkEventExpose* ev)
427 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
429 cairo_set_line_width (cr, 1);
431 double const width = ev->area.width;
432 double const height = ev->area.height;
434 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
435 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
437 cairo_rectangle (cr, 0, 0, width, height);
440 Gdk::Color const fg = get_style()->get_fg (STATE_NORMAL);
441 cairo_set_source_rgb (cr, fg.get_red_p (), fg.get_green_p (), fg.get_blue_p ());
443 cairo_move_to (cr, width * 0.3, height);
444 cairo_line_to (cr, width * 0.3, height * 0.5);
445 cairo_line_to (cr, width * 0.7, height * 0.5);
446 cairo_line_to (cr, width * 0.7, height);
447 cairo_move_to (cr, width * 0.5, height * 0.5);
448 cairo_line_to (cr, width * 0.5, 0);
454 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
455 RouteRedirectSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
456 : _parent_strip (parent)
457 , _owner_is_mixer (owner_is_mixer)
458 , ab_direction (true)
459 , _get_plugin_selector (get_plugin_selector)
461 , _rr_selection(rsel)
467 send_action_menu = 0;
468 no_processor_redisplay = false;
470 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
471 processor_scroller.add (processor_display);
472 pack_start (processor_scroller, true, true);
474 processor_display.set_flags (CAN_FOCUS);
475 processor_display.set_name ("ProcessorList");
476 processor_display.set_size_request (48, -1);
477 processor_display.set_data ("processorbox", this);
478 processor_display.set_spacing (2);
480 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
481 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
483 processor_display.signal_key_press_event().connect (sigc::mem_fun(*this, &ProcessorBox::processor_key_press_event));
484 processor_display.signal_key_release_event().connect (sigc::mem_fun(*this, &ProcessorBox::processor_key_release_event));
486 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
487 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
489 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
490 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
491 processor_display.SelectionChanged.connect (sigc::mem_fun (*this, &ProcessorBox::selection_changed));
493 processor_scroller.show ();
494 processor_display.show ();
497 parent->DeliveryChanged.connect (
498 _mixer_strip_connections, invalidator (*this), ui_bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
503 ProcessorBox::~ProcessorBox ()
508 ProcessorBox::set_route (boost::shared_ptr<Route> r)
514 _route_connections.drop_connections();
516 /* new route: any existing block on processor redisplay must be meaningless */
517 no_processor_redisplay = false;
520 _route->processors_changed.connect (
521 _route_connections, invalidator (*this), ui_bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
524 _route->DropReferences.connect (
525 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
528 _route->PropertyChanged.connect (
529 _route_connections, invalidator (*this), ui_bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
532 redisplay_processors ();
536 ProcessorBox::route_going_away ()
538 /* don't keep updating display as processors are deleted */
539 no_processor_redisplay = true;
544 ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
546 boost::shared_ptr<Processor> p;
548 p = position->processor ();
551 list<ProcessorEntry*> children = source->selection ();
552 list<boost::shared_ptr<Processor> > procs;
553 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
554 procs.push_back ((*i)->processor ());
557 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
558 XMLNode& state = (*i)->get_state ();
560 nlist.push_back (&state);
561 paste_processor_state (nlist, p);
565 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
569 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
570 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
572 cerr << "source was another processor box, delete the selected items\n";
573 other->delete_dragged_processors (procs);
579 ProcessorBox::update()
581 redisplay_processors ();
585 ProcessorBox::set_width (Width w)
593 list<ProcessorEntry*> children = processor_display.children ();
594 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
595 (*i)->set_enum_width (w);
598 redisplay_processors ();
602 ProcessorBox::build_send_action_menu ()
604 using namespace Menu_Helpers;
606 send_action_menu = new Menu;
607 send_action_menu->set_name ("ArdourContextMenu");
608 MenuList& items = send_action_menu->items();
610 items.push_back (MenuElem (_("New send"), sigc::mem_fun(*this, &ProcessorBox::new_send)));
611 items.push_back (MenuElem (_("Show send controls"), sigc::mem_fun(*this, &ProcessorBox::show_send_controls)));
615 ProcessorBox::build_possible_aux_menu ()
617 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
623 using namespace Menu_Helpers;
624 Menu* menu = manage (new Menu);
625 MenuList& items = menu->items();
627 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
628 if (!_route->internal_send_for (*r) && *r != _route) {
629 items.push_back (MenuElem ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
637 ProcessorBox::show_send_controls ()
642 ProcessorBox::new_send ()
647 ProcessorBox::show_processor_menu (int arg)
649 if (processor_menu == 0) {
650 processor_menu = build_processor_menu ();
651 processor_menu->signal_unmap().connect (sigc::mem_fun (*this, &ProcessorBox::processor_menu_unmapped));
654 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newplugin"));
656 if (plugin_menu_item) {
657 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
660 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/newaux"));
663 Menu* m = build_possible_aux_menu();
664 if (m && !m->items().empty()) {
665 aux_menu_item->set_submenu (*m);
666 aux_menu_item->set_sensitive (true);
668 /* stupid gtkmm: we need to pass a null reference here */
669 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
670 aux_menu_item->set_sensitive (false);
674 cut_action->set_sensitive (can_cut());
675 paste_action->set_sensitive (!_rr_selection.processors.empty());
677 processor_menu->popup (1, arg);
679 /* Add a placeholder gap to the processor list to indicate where a processor would be
680 inserted were one chosen from the menu.
683 processor_display.get_pointer (x, y);
684 _placement = processor_display.add_placeholder (y);
688 ProcessorBox::enter_notify (GdkEventCrossing*)
690 _current_processor_box = this;
691 Keyboard::magic_widget_grab_focus ();
692 processor_display.grab_focus ();
698 ProcessorBox::leave_notify (GdkEventCrossing* ev)
700 switch (ev->detail) {
701 case GDK_NOTIFY_INFERIOR:
704 Keyboard::magic_widget_drop_focus ();
711 ProcessorBox::processor_key_press_event (GdkEventKey *ev)
713 switch (ev->keyval) {
724 /* do real stuff on key release */
727 return forward_key_press (ev);
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());
796 delete_processors (targets);
801 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
802 if ((*i)->active()) {
824 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
826 boost::shared_ptr<Processor> processor;
828 processor = child->processor ();
832 bool selected = processor_display.selected (child);
834 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
836 if (_session->engine().connected()) {
837 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
838 toggle_edit_processor (processor);
842 } else if (processor && ev->button == 1 && selected) {
844 // this is purely informational but necessary for route params UI
845 ProcessorSelected (processor); // emit
847 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
850 _get_plugin_selector()->show_manager ();
857 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
859 boost::shared_ptr<Processor> processor;
861 processor = child->processor ();
864 if (processor && Keyboard::is_delete_event (ev)) {
866 Glib::signal_idle().connect (sigc::bind (
867 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
868 boost::weak_ptr<Processor>(processor)));
870 } else if (Keyboard::is_context_menu_event (ev)) {
872 show_processor_menu (ev->time);
874 } else if (processor && Keyboard::is_button2_event (ev)
876 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
880 /* button2-click with no/appropriate modifiers */
882 if (processor->active()) {
883 processor->deactivate ();
885 processor->activate ();
893 ProcessorBox::build_processor_menu ()
895 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/ProcessorMenu") );
896 processor_menu->set_name ("ArdourContextMenu");
897 return processor_menu;
901 ProcessorBox::selection_changed ()
903 const bool sensitive = !processor_display.selection().empty();
904 ActionManager::set_sensitive(ActionManager::plugin_selection_sensitive_actions,
906 edit_action->set_sensitive(one_processor_can_be_edited());
908 const bool single_selection = (processor_display.selection().size() == 1);
910 boost::shared_ptr<PluginInsert> pi;
911 if (single_selection) {
912 pi = boost::dynamic_pointer_cast<PluginInsert>(
913 processor_display.selection().front()->processor());
916 /* enable gui for plugin inserts with editors */
917 controls_action->set_sensitive(pi && pi->plugin()->has_editor());
919 /* disallow rename for multiple selections and for plugin inserts */
920 rename_action->set_sensitive(single_selection && pi);
924 ProcessorBox::select_all_processors ()
926 processor_display.select_all ();
930 ProcessorBox::deselect_all_processors ()
932 processor_display.select_none ();
936 ProcessorBox::choose_plugin ()
938 _get_plugin_selector()->set_interested_object (*this);
941 /** @return true if an error occurred, otherwise false */
943 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
945 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
947 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
949 Route::ProcessorStreams err_streams;
951 if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
952 weird_plugin_dialog (**p, err_streams);
954 // XXX SHAREDPTR delete plugin here .. do we even need to care?
957 if (Profile->get_sae()) {
958 processor->activate ();
967 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
969 ArdourDialog dialog (_("Plugin Incompatibility"));
972 string text = string_compose(_("You attempted to add the plugin \"%1\" in slot %2.\n"),
973 p.name(), streams.index);
975 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
976 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
978 text += _("\nThis plugin has:\n");
980 uint32_t const n = p.get_info()->n_inputs.n_midi ();
981 text += string_compose (ngettext ("\t%1 MIDI input\n", "\t%1 MIDI inputs\n", n), n);
984 uint32_t const n = p.get_info()->n_inputs.n_audio ();
985 text += string_compose (ngettext ("\t%1 audio input\n", "\t%1 audio inputs\n", n), n);
988 text += _("\nbut at the insertion point, there are:\n");
990 uint32_t const n = streams.count.n_midi ();
991 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
994 uint32_t const n = streams.count.n_audio ();
995 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
998 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
999 label.set_text(text);
1001 dialog.get_vbox()->pack_start (label);
1002 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1004 dialog.set_name (X_("PluginIODialog"));
1005 dialog.set_position (Gtk::WIN_POS_MOUSE);
1006 dialog.set_modal (true);
1013 ProcessorBox::choose_insert ()
1015 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->pannable(), _route->mute_master()));
1016 _route->add_processor_by_index (processor, _placement);
1019 /* Caller must not hold process lock */
1021 ProcessorBox::choose_send ()
1023 boost::shared_ptr<Send> send (new Send (*_session, _route->pannable(), _route->mute_master()));
1025 /* make an educated guess at the initial number of outputs for the send */
1026 ChanCount outs = (_session->master_out())
1027 ? _session->master_out()->n_outputs()
1028 : _route->n_outputs();
1030 /* XXX need processor lock on route */
1032 Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock());
1033 send->output()->ensure_io (outs, false, this);
1034 } catch (AudioEngine::PortRegistrationFailure& err) {
1035 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
1039 /* let the user adjust the IO setup before creation.
1041 Note: this dialog is NOT modal - we just leave it to run and it will
1042 return when its Finished signal is emitted - typically when the window
1046 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
1049 /* keep a reference to the send so it doesn't get deleted while
1050 the IOSelectorWindow is doing its stuff
1052 _processor_being_created = send;
1054 ios->selector().Finished.connect (sigc::bind (
1055 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
1056 boost::weak_ptr<Processor>(send), ios));
1061 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1063 boost::shared_ptr<Processor> processor (weak_processor.lock());
1065 /* drop our temporary reference to the new send */
1066 _processor_being_created.reset ();
1073 case IOSelector::Cancelled:
1074 // processor will go away when all shared_ptrs to it vanish
1077 case IOSelector::Accepted:
1078 _route->add_processor_by_index (processor, _placement);
1079 if (Profile->get_sae()) {
1080 processor->activate ();
1085 delete_when_idle (ios);
1089 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1091 boost::shared_ptr<Processor> processor (weak_processor.lock());
1093 /* drop our temporary reference to the new return */
1094 _processor_being_created.reset ();
1101 case IOSelector::Cancelled:
1102 // processor will go away when all shared_ptrs to it vanish
1105 case IOSelector::Accepted:
1106 _route->add_processor_by_index (processor, _placement);
1107 if (Profile->get_sae()) {
1108 processor->activate ();
1113 delete_when_idle (ios);
1117 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
1123 boost::shared_ptr<Route> target = wr.lock();
1129 boost::shared_ptr<RouteList> rlist (new RouteList);
1130 rlist->push_back (_route);
1132 _session->add_internal_sends (target, PreFader, rlist);
1136 ProcessorBox::route_processors_changed (RouteProcessorChange c)
1138 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
1139 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
1143 redisplay_processors ();
1147 ProcessorBox::redisplay_processors ()
1149 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors)
1151 if (no_processor_redisplay) {
1155 processor_display.clear ();
1157 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
1159 for (list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin(); i != _processor_window_proxies.end(); ++i) {
1160 (*i)->marked = false;
1163 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
1165 /* trim dead wood from the processor window proxy list */
1167 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin();
1168 while (i != _processor_window_proxies.end()) {
1169 list<ProcessorWindowProxy*>::iterator j = i;
1172 if (!(*i)->marked) {
1173 ARDOUR_UI::instance()->remove_window_proxy (*i);
1175 _processor_window_proxies.erase (i);
1181 setup_entry_positions ();
1184 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
1185 * not already have one.
1188 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
1190 boost::shared_ptr<Processor> p = w.lock ();
1195 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin ();
1196 while (i != _processor_window_proxies.end()) {
1198 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
1201 /* this processor is already on the list; done */
1202 (*i)->marked = true;
1209 /* not on the list; add it */
1212 if (_parent_strip) {
1213 if (_parent_strip->mixer_owned()) {
1222 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
1223 string_compose ("%1-%2-%3", loc, _route->id(), p->id()),
1224 _session->extra_xml (X_("UI")),
1230 /* if the processor already has an existing UI,
1231 note that so that we don't recreate it
1234 void* existing_ui = p->get_ui ();
1237 wp->set (static_cast<Gtk::Window*>(existing_ui));
1240 _processor_window_proxies.push_back (wp);
1241 ARDOUR_UI::instance()->add_window_proxy (wp);
1245 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
1247 boost::shared_ptr<Processor> processor (p.lock ());
1249 if (!processor || !processor->display_to_user()) {
1253 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
1254 boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
1255 ProcessorEntry* e = 0;
1257 e = new SendProcessorEntry (send, _width);
1258 } else if (plugin_insert) {
1259 e = new PluginInsertProcessorEntry (plugin_insert, _width);
1261 e = new ProcessorEntry (processor, _width);
1264 e->set_pixel_width (get_allocation().get_width());
1265 processor_display.add_child (e);
1270 ProcessorBox::build_processor_tooltip (EventBox& box, string start)
1274 list<ProcessorEntry*> children = processor_display.children ();
1275 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1277 tip += (*i)->processor()->name();
1280 ARDOUR_UI::instance()->set_tip (box, tip);
1284 ProcessorBox::reordered ()
1286 compute_processor_sort_keys ();
1287 setup_entry_positions ();
1291 ProcessorBox::setup_entry_positions ()
1293 list<ProcessorEntry*> children = processor_display.children ();
1294 bool pre_fader = true;
1296 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1297 if (boost::dynamic_pointer_cast<Amp>((*i)->processor())) {
1299 (*i)->set_position (ProcessorEntry::Fader);
1302 (*i)->set_position (ProcessorEntry::PreFader);
1304 (*i)->set_position (ProcessorEntry::PostFader);
1311 ProcessorBox::compute_processor_sort_keys ()
1313 list<ProcessorEntry*> children = processor_display.children ();
1314 Route::ProcessorList our_processors;
1316 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
1317 our_processors.push_back ((*iter)->processor ());
1320 if (_route->reorder_processors (our_processors)) {
1321 /* Reorder failed, so report this to the user. As far as I can see this must be done
1322 in an idle handler: it seems that the redisplay_processors() that happens below destroys
1323 widgets that were involved in the drag-and-drop on the processor list, which causes problems
1324 when the drag is torn down after this handler function is finished.
1326 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
1331 ProcessorBox::report_failed_reorder ()
1333 /* reorder failed, so redisplay */
1335 redisplay_processors ();
1337 /* now tell them about the problem */
1339 ArdourDialog dialog (_("Plugin Incompatibility"));
1342 label.set_text (_("\
1343 You cannot reorder these plugins/sends/inserts\n\
1344 in that way because the inputs and\n\
1345 outputs will not work correctly."));
1347 dialog.get_vbox()->set_border_width (12);
1348 dialog.get_vbox()->pack_start (label);
1349 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1351 dialog.set_name (X_("PluginIODialog"));
1352 dialog.set_position (Gtk::WIN_POS_MOUSE);
1353 dialog.set_modal (true);
1360 ProcessorBox::rename_processors ()
1362 ProcSelection to_be_renamed;
1364 get_selected_processors (to_be_renamed);
1366 if (to_be_renamed.empty()) {
1370 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
1371 rename_processor (*i);
1376 ProcessorBox::can_cut () const
1378 vector<boost::shared_ptr<Processor> > sel;
1380 get_selected_processors (sel);
1382 /* cut_processors () does not cut inserts */
1384 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
1386 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1387 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1388 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1397 ProcessorBox::cut_processors ()
1399 ProcSelection to_be_removed;
1401 get_selected_processors (to_be_removed);
1405 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
1407 if (to_be_removed.empty()) {
1411 XMLNode* node = new XMLNode (X_("cut"));
1412 Route::ProcessorList to_cut;
1414 no_processor_redisplay = true;
1415 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
1416 // Cut only plugins, sends and returns
1417 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1418 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1419 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1421 Window* w = get_processor_ui (*i);
1427 XMLNode& child ((*i)->get_state());
1428 node->add_child_nocopy (child);
1429 to_cut.push_back (*i);
1433 if (_route->remove_processors (to_cut) != 0) {
1435 no_processor_redisplay = false;
1439 _rr_selection.set (node);
1441 no_processor_redisplay = false;
1442 redisplay_processors ();
1446 ProcessorBox::copy_processors ()
1448 ProcSelection to_be_copied;
1449 get_selected_processors (to_be_copied);
1450 copy_processors (to_be_copied);
1454 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
1456 if (to_be_copied.empty()) {
1460 XMLNode* node = new XMLNode (X_("copy"));
1462 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
1463 // Copy only plugins, sends, returns
1464 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1465 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1466 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1467 node->add_child_nocopy ((*i)->get_state());
1471 _rr_selection.set (node);
1475 ProcessorBox::processors_up ()
1481 ProcessorBox::processors_down ()
1488 ProcessorBox::delete_processors ()
1490 ProcSelection to_be_deleted;
1491 get_selected_processors (to_be_deleted);
1492 delete_processors (to_be_deleted);
1496 ProcessorBox::delete_processors (const ProcSelection& targets)
1498 if (targets.empty()) {
1502 no_processor_redisplay = true;
1504 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
1506 Window* w = get_processor_ui (*i);
1512 _route->remove_processor(*i);
1515 no_processor_redisplay = false;
1516 redisplay_processors ();
1520 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
1522 list<boost::shared_ptr<Processor> >::const_iterator x;
1524 no_processor_redisplay = true;
1525 for (x = procs.begin(); x != procs.end(); ++x) {
1527 Window* w = get_processor_ui (*x);
1533 _route->remove_processor(*x);
1536 no_processor_redisplay = false;
1537 redisplay_processors ();
1541 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
1543 boost::shared_ptr<Processor> processor (weak_processor.lock());
1549 /* NOT copied to _mixer.selection() */
1551 no_processor_redisplay = true;
1552 _route->remove_processor (processor);
1553 no_processor_redisplay = false;
1554 redisplay_processors ();
1560 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
1562 ArdourPrompter name_prompter (true);
1564 name_prompter.set_title (_("Rename Processor"));
1565 name_prompter.set_prompt (_("New name:"));
1566 name_prompter.set_initial_text (processor->name());
1567 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
1568 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
1569 name_prompter.show_all ();
1571 switch (name_prompter.run ()) {
1573 case Gtk::RESPONSE_ACCEPT:
1574 name_prompter.get_result (result);
1575 if (result.length()) {
1578 string test = result;
1580 while (tries < 100) {
1581 if (_session->io_name_is_legal (test)) {
1587 test = string_compose ("%1-%2", result, tries);
1591 processor->set_name (result);
1594 ARDOUR_UI::instance()->popup_error
1595 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
1605 ProcessorBox::paste_processors ()
1607 if (_rr_selection.processors.empty()) {
1611 paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
1615 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
1618 if (_rr_selection.processors.empty()) {
1622 paste_processor_state (_rr_selection.processors.get_node().children(), before);
1626 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
1628 XMLNodeConstIterator niter;
1629 list<boost::shared_ptr<Processor> > copies;
1631 if (nlist.empty()) {
1635 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1637 XMLProperty const * type = (*niter)->property ("type");
1640 boost::shared_ptr<Processor> p;
1642 if (type->value() == "meter" ||
1643 type->value() == "main-outs" ||
1644 type->value() == "amp" ||
1645 type->value() == "intsend" || type->value() == "intreturn") {
1646 /* do not paste meter, main outs, amp or internal send/returns */
1649 } else if (type->value() == "send") {
1651 XMLNode n (**niter);
1652 Send::make_unique (n, *_session);
1653 Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
1654 if (s->set_state (n, Stateful::loading_state_version)) {
1662 } else if (type->value() == "return") {
1664 XMLNode n (**niter);
1665 Return::make_unique (n, *_session);
1666 Return* r = new Return (*_session);
1668 if (r->set_state (n, Stateful::loading_state_version)) {
1675 } else if (type->value() == "port") {
1677 XMLNode n (**niter);
1678 p.reset (new PortInsert (*_session, _route->pannable (), _route->mute_master ()));
1679 if (p->set_state (n, Stateful::loading_state_version)) {
1684 /* XXX its a bit limiting to assume that everything else
1688 p.reset (new PluginInsert (*_session));
1689 p->set_state (**niter, Stateful::current_state_version);
1692 copies.push_back (p);
1696 cerr << "plugin insert constructor failed\n";
1700 if (copies.empty()) {
1704 if (_route->add_processors (copies, p)) {
1707 "Copying the set of processors on the clipboard failed,\n\
1708 probably because the I/O configuration of the plugins\n\
1709 could not match the configuration of this track.");
1710 MessageDialog am (msg);
1716 ProcessorBox::activate_processor (boost::shared_ptr<Processor> r)
1722 ProcessorBox::deactivate_processor (boost::shared_ptr<Processor> r)
1728 ProcessorBox::get_selected_processors (ProcSelection& processors) const
1730 const list<ProcessorEntry*> selection = processor_display.selection ();
1731 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
1732 processors.push_back ((*i)->processor ());
1737 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
1739 list<ProcessorEntry*> selection = processor_display.selection ();
1740 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
1741 (this->*method) ((*i)->processor ());
1746 ProcessorBox::all_processors_active (bool state)
1748 _route->all_processors_active (PreFader, state);
1749 _route->all_processors_active (PostFader, state);
1753 ProcessorBox::ab_plugins ()
1755 _route->ab_plugins (ab_direction);
1756 ab_direction = !ab_direction;
1761 ProcessorBox::clear_processors ()
1764 vector<string> choices;
1766 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
1767 "(this cannot be undone)"), _route->name());
1769 choices.push_back (_("Cancel"));
1770 choices.push_back (_("Yes, remove them all"));
1772 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1774 if (prompter.run () == 1) {
1775 _route->clear_processors (PreFader);
1776 _route->clear_processors (PostFader);
1781 ProcessorBox::clear_processors (Placement p)
1784 vector<string> choices;
1786 if (p == PreFader) {
1787 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
1788 "(this cannot be undone)"), _route->name());
1790 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
1791 "(this cannot be undone)"), _route->name());
1794 choices.push_back (_("Cancel"));
1795 choices.push_back (_("Yes, remove them all"));
1797 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1799 if (prompter.run () == 1) {
1800 _route->clear_processors (p);
1805 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
1807 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
1808 if (at && at->freeze_state() == AudioTrack::Frozen) {
1813 (boost::dynamic_pointer_cast<Send> (processor) && !boost::dynamic_pointer_cast<InternalSend> (processor))||
1814 boost::dynamic_pointer_cast<Return> (processor) ||
1815 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
1816 boost::dynamic_pointer_cast<PortInsert> (processor)
1825 ProcessorBox::one_processor_can_be_edited ()
1827 list<ProcessorEntry*> selection = processor_display.selection ();
1828 list<ProcessorEntry*>::iterator i = selection.begin();
1829 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
1833 return (i != selection.end());
1837 ProcessorBox::toggle_edit_processor (boost::shared_ptr<Processor> processor)
1839 boost::shared_ptr<Send> send;
1840 boost::shared_ptr<InternalSend> internal_send;
1841 boost::shared_ptr<Return> retrn;
1842 boost::shared_ptr<PluginInsert> plugin_insert;
1843 boost::shared_ptr<PortInsert> port_insert;
1846 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
1848 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
1853 if (boost::dynamic_pointer_cast<Amp> (processor)) {
1855 if (_parent_strip) {
1856 _parent_strip->revert_to_default_display ();
1859 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
1861 if (!_session->engine().connected()) {
1865 SendUIWindow* w = new SendUIWindow (send, _session);
1868 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
1870 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
1871 /* no GUI for these */
1875 if (!_session->engine().connected()) {
1879 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
1881 ReturnUIWindow *return_ui;
1882 Window* w = get_processor_ui (retrn);
1886 return_ui = new ReturnUIWindow (retrn, _session);
1887 return_ui->set_title (retrn->name ());
1888 set_processor_ui (send, return_ui);
1891 return_ui = dynamic_cast<ReturnUIWindow *> (w);
1896 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
1898 PluginUIWindow *plugin_ui;
1900 /* these are both allowed to be null */
1902 Container* toplevel = get_toplevel();
1903 Window* win = dynamic_cast<Gtk::Window*>(toplevel);
1905 Window* w = get_processor_ui (plugin_insert);
1909 plugin_ui = new PluginUIWindow (win, plugin_insert);
1910 plugin_ui->set_title (generate_processor_title (plugin_insert));
1911 set_processor_ui (plugin_insert, plugin_ui);
1914 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
1915 plugin_ui->set_parent (win);
1920 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
1922 if (!_session->engine().connected()) {
1923 MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible"));
1928 PortInsertWindow *io_selector;
1930 Window* w = get_processor_ui (port_insert);
1933 io_selector = new PortInsertWindow (_session, port_insert);
1934 set_processor_ui (port_insert, io_selector);
1937 io_selector = dynamic_cast<PortInsertWindow *> (w);
1940 gidget = io_selector;
1944 if (gidget->is_visible()) {
1947 gidget->show_all ();
1954 ProcessorBox::toggle_processor_controls (boost::shared_ptr<Processor> processor)
1956 boost::shared_ptr<PluginInsert> plugin_insert
1957 = boost::dynamic_pointer_cast<PluginInsert>(processor);
1958 if (!plugin_insert) {
1962 Container* toplevel = get_toplevel();
1963 Window* win = dynamic_cast<Gtk::Window*>(toplevel);
1964 PluginUIWindow* plugin_ui = new PluginUIWindow(win, plugin_insert, true, false);
1965 plugin_ui->set_title(generate_processor_title (plugin_insert));
1967 if (plugin_ui->is_visible()) {
1970 plugin_ui->show_all();
1971 plugin_ui->present();
1976 ProcessorBox::register_actions ()
1978 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("ProcessorMenu"));
1979 Glib::RefPtr<Action> act;
1982 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin"),
1983 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
1985 act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"),
1986 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
1987 ActionManager::jack_sensitive_actions.push_back (act);
1988 act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New Send ..."),
1989 sigc::ptr_fun (ProcessorBox::rb_choose_send));
1990 ActionManager::jack_sensitive_actions.push_back (act);
1992 ActionManager::register_action (popup_act_grp, X_("newaux"), _("New Aux Send ..."));
1994 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear (all)"),
1995 sigc::ptr_fun (ProcessorBox::rb_clear));
1996 ActionManager::register_action (popup_act_grp, X_("clear_pre"), _("Clear (pre-fader)"),
1997 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
1998 ActionManager::register_action (popup_act_grp, X_("clear_post"), _("Clear (post-fader)"),
1999 sigc::ptr_fun (ProcessorBox::rb_clear_post));
2001 /* standard editing stuff */
2002 cut_action = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"),
2003 sigc::ptr_fun (ProcessorBox::rb_cut));
2004 ActionManager::plugin_selection_sensitive_actions.push_back(cut_action);
2005 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),
2006 sigc::ptr_fun (ProcessorBox::rb_copy));
2007 ActionManager::plugin_selection_sensitive_actions.push_back(act);
2009 act = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"),
2010 sigc::ptr_fun (ProcessorBox::rb_delete));
2011 ActionManager::plugin_selection_sensitive_actions.push_back(act); // ??
2013 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"),
2014 sigc::ptr_fun (ProcessorBox::rb_paste));
2015 rename_action = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"),
2016 sigc::ptr_fun (ProcessorBox::rb_rename));
2017 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"),
2018 sigc::ptr_fun (ProcessorBox::rb_select_all));
2019 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"),
2020 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
2022 /* activation etc. */
2024 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate all"),
2025 sigc::ptr_fun (ProcessorBox::rb_activate_all));
2026 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate all"),
2027 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
2028 ActionManager::register_action (popup_act_grp, X_("ab_plugins"), _("A/B Plugins"),
2029 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
2032 edit_action = ActionManager::register_action (
2033 popup_act_grp, X_("edit"), _("Edit..."),
2034 sigc::ptr_fun (ProcessorBox::rb_edit));
2036 /* show plugin GUI */
2037 controls_action = ActionManager::register_action (
2038 popup_act_grp, X_("controls"), _("Controls..."),
2039 sigc::ptr_fun (ProcessorBox::rb_controls));
2041 ActionManager::add_action_group (popup_act_grp);
2045 ProcessorBox::rb_ab_plugins ()
2047 if (_current_processor_box == 0) {
2051 _current_processor_box->ab_plugins ();
2055 ProcessorBox::rb_choose_plugin ()
2057 if (_current_processor_box == 0) {
2060 _current_processor_box->choose_plugin ();
2064 ProcessorBox::rb_choose_insert ()
2066 if (_current_processor_box == 0) {
2069 _current_processor_box->choose_insert ();
2073 ProcessorBox::rb_choose_send ()
2075 if (_current_processor_box == 0) {
2078 _current_processor_box->choose_send ();
2082 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
2084 if (_current_processor_box == 0) {
2088 _current_processor_box->choose_aux (wr);
2092 ProcessorBox::rb_clear ()
2094 if (_current_processor_box == 0) {
2098 _current_processor_box->clear_processors ();
2103 ProcessorBox::rb_clear_pre ()
2105 if (_current_processor_box == 0) {
2109 _current_processor_box->clear_processors (PreFader);
2114 ProcessorBox::rb_clear_post ()
2116 if (_current_processor_box == 0) {
2120 _current_processor_box->clear_processors (PostFader);
2124 ProcessorBox::rb_cut ()
2126 if (_current_processor_box == 0) {
2130 _current_processor_box->cut_processors ();
2134 ProcessorBox::rb_delete ()
2136 if (_current_processor_box == 0) {
2140 _current_processor_box->delete_processors ();
2144 ProcessorBox::rb_copy ()
2146 if (_current_processor_box == 0) {
2149 _current_processor_box->copy_processors ();
2153 ProcessorBox::rb_paste ()
2155 if (_current_processor_box == 0) {
2159 _current_processor_box->paste_processors ();
2163 ProcessorBox::rb_rename ()
2165 if (_current_processor_box == 0) {
2168 _current_processor_box->rename_processors ();
2172 ProcessorBox::rb_select_all ()
2174 if (_current_processor_box == 0) {
2178 _current_processor_box->select_all_processors ();
2182 ProcessorBox::rb_deselect_all ()
2184 if (_current_processor_box == 0) {
2188 _current_processor_box->deselect_all_processors ();
2192 ProcessorBox::rb_activate_all ()
2194 if (_current_processor_box == 0) {
2198 _current_processor_box->all_processors_active (true);
2202 ProcessorBox::rb_deactivate_all ()
2204 if (_current_processor_box == 0) {
2207 _current_processor_box->all_processors_active (false);
2211 ProcessorBox::rb_edit ()
2213 if (_current_processor_box == 0) {
2217 _current_processor_box->for_selected_processors (&ProcessorBox::toggle_edit_processor);
2221 ProcessorBox::rb_controls ()
2223 if (_current_processor_box == 0) {
2227 _current_processor_box->for_selected_processors (&ProcessorBox::toggle_processor_controls);
2231 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
2233 if (!what_changed.contains (ARDOUR::Properties::name)) {
2237 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
2239 boost::shared_ptr<Processor> processor;
2240 boost::shared_ptr<PluginInsert> plugin_insert;
2241 boost::shared_ptr<Send> send;
2243 list<ProcessorEntry*> children = processor_display.children();
2245 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
2247 processor = (*iter)->processor ();
2249 Window* w = get_processor_ui (processor);
2255 /* rename editor windows for sends and plugins */
2257 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
2258 w->set_title (send->name ());
2259 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
2260 w->set_title (generate_processor_title (plugin_insert));
2266 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
2268 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
2269 string::size_type email_pos;
2271 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
2272 maker = maker.substr (0, email_pos - 1);
2275 if (maker.length() > 32) {
2276 maker = maker.substr (0, 32);
2280 return string_compose(_("%1: %2 (by %3)"), _route->name(), pi->name(), maker);
2284 ProcessorBox::on_size_allocate (Allocation& a)
2286 HBox::on_size_allocate (a);
2288 list<ProcessorEntry*> children = processor_display.children ();
2289 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
2290 (*i)->set_pixel_width (a.get_width ());
2294 /** @param p Processor.
2295 * @return the UI window for \a p.
2298 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
2300 list<ProcessorWindowProxy*>::const_iterator i = _processor_window_proxies.begin ();
2301 while (i != _processor_window_proxies.end()) {
2302 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2304 return (*i)->get ();
2310 /* we shouldn't get here, because the ProcessorUIList should always contain
2311 an entry for each processor.
2317 /** Make a note of the UI window that a processor is using.
2318 * @param p Processor.
2319 * @param w UI window.
2322 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
2324 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin ();
2328 while (i != _processor_window_proxies.end()) {
2329 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2338 /* we shouldn't get here, because the ProcessorUIList should always contain
2339 an entry for each processor.
2345 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
2347 boost::shared_ptr<Delivery> d = w.lock ();
2352 list<ProcessorEntry*> children = processor_display.children ();
2353 list<ProcessorEntry*>::const_iterator i = children.begin();
2354 while (i != children.end() && (*i)->processor() != d) {
2358 if (i == children.end()) {
2359 processor_display.set_active (0);
2361 processor_display.set_active (*i);
2366 ProcessorBox::hide_things ()
2368 list<ProcessorEntry*> c = processor_display.children ();
2369 for (list<ProcessorEntry*>::iterator i = c.begin(); i != c.end(); ++i) {
2370 (*i)->hide_things ();
2375 ProcessorBox::processor_menu_unmapped ()
2377 processor_display.remove_placeholder ();
2380 ProcessorWindowProxy::ProcessorWindowProxy (
2381 string const & name,
2382 XMLNode const * node,
2384 boost::weak_ptr<Processor> processor
2386 : WindowProxy<Gtk::Window> (name, node)
2388 , _processor_box (box)
2389 , _processor (processor)
2396 ProcessorWindowProxy::show ()
2398 boost::shared_ptr<Processor> p = _processor.lock ();
2403 _processor_box->toggle_edit_processor (p);