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"
59 #include "ardour_dialog.h"
60 #include "ardour_ui.h"
61 #include "gui_thread.h"
62 #include "io_selector.h"
65 #include "mixer_strip.h"
66 #include "plugin_selector.h"
67 #include "plugin_ui.h"
68 #include "port_insert_ui.h"
69 #include "processor_box.h"
70 #include "public_editor.h"
71 #include "return_ui.h"
72 #include "route_processor_selection.h"
78 #ifdef HAVE_AUDIOUNITS
83 using namespace ARDOUR;
87 using namespace Gtkmm2ext;
89 ProcessorBox* ProcessorBox::_current_processor_box = 0;
90 RefPtr<Action> ProcessorBox::paste_action;
91 RefPtr<Action> ProcessorBox::cut_action;
92 RefPtr<Action> ProcessorBox::rename_action;
93 RefPtr<Action> ProcessorBox::edit_action;
94 Glib::RefPtr<Gdk::Pixbuf> SendProcessorEntry::_slider;
96 ProcessorEntry::ProcessorEntry (boost::shared_ptr<Processor> p, Width w)
100 _hbox.pack_start (_active, false, false);
101 _event_box.add (_name);
102 _hbox.pack_start (_event_box, true, true);
103 _vbox.pack_start (_hbox);
106 _name.set_alignment (0, 0.5);
107 _name.set_text (name ());
108 _name.set_padding (2, 2);
110 if (boost::dynamic_pointer_cast<Amp> (p)) {
111 /* Fader processor gets a special look */
112 _event_box.set_name ("ProcessorFader");
113 _frame.set_name ("ProcessorFaderFrame");
114 _name.set_padding (2, 4);
117 _active.set_active (_processor->active ());
118 _active.signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::active_toggled));
120 _processor->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_active_changed, this), gui_context());
121 _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
142 boost::shared_ptr<Processor>
143 ProcessorEntry::processor () const
149 ProcessorEntry::set_enum_width (Width w)
155 ProcessorEntry::active_toggled ()
157 if (_active.get_active ()) {
158 if (!_processor->active ()) {
159 _processor->activate ();
162 if (_processor->active ()) {
163 _processor->deactivate ();
169 ProcessorEntry::processor_active_changed ()
171 if (_active.get_active () != _processor->active ()) {
172 _active.set_active (_processor->active ());
177 ProcessorEntry::processor_property_changed (const PropertyChange& what_changed)
179 if (what_changed.contains (ARDOUR::Properties::name)) {
180 _name.set_text (name ());
185 ProcessorEntry::name () const
187 boost::shared_ptr<Send> send;
190 if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
191 !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
195 /* grab the send name out of its overall name */
197 string::size_type lbracket, rbracket;
198 lbracket = send->name().find ('[');
199 rbracket = send->name().find (']');
203 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
206 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
214 name_display += _processor->display_name();
217 name_display += PBD::short_version (_processor->display_name(), 5);
226 SendProcessorEntry::SendProcessorEntry (boost::shared_ptr<Send> s, Width w)
227 : ProcessorEntry (s, w),
229 /* set the adjustment to a gain of 0dB so that the fader's default value is right */
230 _adjustment (0.781787, 0, 1, 0.01, 0.1),
231 _fader (_slider, &_adjustment, 0, false),
232 _ignore_gain_change (false)
234 _fader.set_name ("SendFader");
235 _fader.set_controllable (_send->amp()->gain_control ());
236 _vbox.pack_start (_fader);
238 _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &SendProcessorEntry::gain_adjusted));
239 _send->amp()->gain_control()->Changed.connect (send_gain_connection, invalidator (*this), boost::bind (&SendProcessorEntry::show_gain, this), gui_context());
244 SendProcessorEntry::setup_slider_pix ()
246 _slider = ::get_icon ("fader_belt_h_thin");
251 SendProcessorEntry::show_gain ()
253 ENSURE_GUI_THREAD (*this, &SendProcessorEntry::show_gain)
255 float const value = gain_to_slider_position (_send->amp()->gain ());
257 if (_adjustment.get_value() != value) {
258 _ignore_gain_change = true;
259 _adjustment.set_value (value);
260 _ignore_gain_change = false;
265 SendProcessorEntry::gain_adjusted ()
267 if (_ignore_gain_change) {
271 _send->amp()->set_gain (slider_position_to_gain (_adjustment.get_value()), this);
275 SendProcessorEntry::set_pixel_width (int p)
277 _fader.set_fader_length (p);
280 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
281 RouteRedirectSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
282 : _parent_strip (parent)
283 , _owner_is_mixer (owner_is_mixer)
284 , ab_direction (true)
285 , _get_plugin_selector (get_plugin_selector)
286 , _placement(PreFader)
287 , _rr_selection(rsel)
293 send_action_menu = 0;
294 no_processor_redisplay = false;
296 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
297 processor_scroller.add (processor_display);
298 pack_start (processor_scroller, true, true);
300 processor_display.set_flags (CAN_FOCUS);
301 processor_display.set_name ("ProcessorList");
302 processor_display.set_size_request (48, -1);
303 processor_display.set_data ("processorbox", this);
304 processor_display.set_spacing (2);
306 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
307 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
309 processor_display.signal_key_press_event().connect (sigc::mem_fun(*this, &ProcessorBox::processor_key_press_event));
310 processor_display.signal_key_release_event().connect (sigc::mem_fun(*this, &ProcessorBox::processor_key_release_event));
312 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
313 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
315 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
316 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
317 processor_display.SelectionChanged.connect (sigc::mem_fun (*this, &ProcessorBox::selection_changed));
320 parent->DeliveryChanged.connect (
321 _mixer_strip_connections, invalidator (*this), ui_bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
326 ProcessorBox::~ProcessorBox ()
331 ProcessorBox::set_route (boost::shared_ptr<Route> r)
337 _route_connections.drop_connections();
339 /* new route: any existing block on processor redisplay must be meaningless */
340 no_processor_redisplay = false;
343 _route->processors_changed.connect (
344 _route_connections, invalidator (*this), ui_bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
347 _route->DropReferences.connect (
348 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
351 _route->PropertyChanged.connect (
352 _route_connections, invalidator (*this), ui_bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
355 redisplay_processors ();
359 ProcessorBox::route_going_away ()
361 /* don't keep updating display as processors are deleted */
362 no_processor_redisplay = true;
366 ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
368 boost::shared_ptr<Processor> p;
370 p = position->processor ();
373 list<ProcessorEntry*> children = source->selection ();
374 list<boost::shared_ptr<Processor> > procs;
375 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
376 procs.push_back ((*i)->processor ());
379 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
380 XMLNode& state = (*i)->get_state ();
382 nlist.push_back (&state);
383 paste_processor_state (nlist, p);
387 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
391 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
392 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
394 cerr << "source was another processor box, delete the selected items\n";
395 other->delete_dragged_processors (procs);
401 ProcessorBox::update()
403 redisplay_processors ();
407 ProcessorBox::set_width (Width w)
415 list<ProcessorEntry*> children = processor_display.children ();
416 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
417 (*i)->set_enum_width (w);
420 redisplay_processors ();
424 ProcessorBox::build_send_action_menu ()
426 using namespace Menu_Helpers;
428 send_action_menu = new Menu;
429 send_action_menu->set_name ("ArdourContextMenu");
430 MenuList& items = send_action_menu->items();
432 items.push_back (MenuElem (_("New send"), sigc::mem_fun(*this, &ProcessorBox::new_send)));
433 items.push_back (MenuElem (_("Show send controls"), sigc::mem_fun(*this, &ProcessorBox::show_send_controls)));
437 ProcessorBox::build_possible_aux_menu ()
439 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
445 using namespace Menu_Helpers;
446 Menu* menu = manage (new Menu);
447 MenuList& items = menu->items();
449 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
450 if (!_route->internal_send_for (*r) && *r != _route) {
451 items.push_back (MenuElem ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
459 ProcessorBox::show_send_controls ()
464 ProcessorBox::new_send ()
469 ProcessorBox::show_processor_menu (gint arg)
471 if (processor_menu == 0) {
472 processor_menu = build_processor_menu ();
475 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/processormenu/newplugin"));
477 if (plugin_menu_item) {
478 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
481 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/processormenu/newaux"));
484 Menu* m = build_possible_aux_menu();
485 if (m && !m->items().empty()) {
486 aux_menu_item->set_submenu (*m);
487 aux_menu_item->set_sensitive (true);
489 /* stupid gtkmm: we need to pass a null reference here */
490 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
491 aux_menu_item->set_sensitive (false);
495 cut_action->set_sensitive (can_cut());
496 paste_action->set_sensitive (!_rr_selection.processors.empty());
498 processor_menu->popup (1, arg);
502 ProcessorBox::enter_notify (GdkEventCrossing*)
504 _current_processor_box = this;
505 Keyboard::magic_widget_grab_focus ();
506 processor_display.grab_focus ();
512 ProcessorBox::leave_notify (GdkEventCrossing* ev)
514 switch (ev->detail) {
515 case GDK_NOTIFY_INFERIOR:
518 Keyboard::magic_widget_drop_focus ();
525 ProcessorBox::processor_key_press_event (GdkEventKey *)
527 /* do real stuff on key release */
532 ProcessorBox::processor_key_release_event (GdkEventKey *ev)
535 ProcSelection targets;
537 get_selected_processors (targets);
539 if (targets.empty()) {
542 processor_display.get_pointer (x, y);
544 pair<ProcessorEntry *, double> const pointer = processor_display.get_child_at_position (y);
547 targets.push_back (pointer.first->processor ());
552 switch (ev->keyval) {
554 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
555 processor_display.select_all ();
561 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
562 copy_processors (targets);
568 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
569 cut_processors (targets);
575 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
576 if (targets.empty()) {
579 paste_processors (targets.front());
593 delete_processors (targets);
598 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
599 if ((*i)->active()) {
621 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
623 boost::shared_ptr<Processor> processor;
625 processor = child->processor ();
629 bool selected = processor_display.selected (child);
631 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
633 if (_session->engine().connected()) {
634 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
635 toggle_edit_processor (processor);
639 } else if (processor && ev->button == 1 && selected) {
641 // this is purely informational but necessary for route params UI
642 ProcessorSelected (processor); // emit
644 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
647 _get_plugin_selector()->show_manager ();
654 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
656 boost::shared_ptr<Processor> processor;
658 processor = child->processor ();
663 if (processor && Keyboard::is_delete_event (ev)) {
665 Glib::signal_idle().connect (sigc::bind (
666 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
667 boost::weak_ptr<Processor>(processor)));
670 } else if (Keyboard::is_context_menu_event (ev)) {
672 /* figure out if we are above or below the fader/amp processor,
673 and set the next insert position appropriately.
677 if (_route->processor_is_prefader (processor)) {
678 _placement = PreFader;
680 _placement = PostFader;
683 _placement = PostFader;
686 show_processor_menu (ev->time);
689 } else if (processor && Keyboard::is_button2_event (ev)
691 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
695 /* button2-click with no/appropriate modifiers */
697 if (processor->active()) {
698 processor->deactivate ();
700 processor->activate ();
710 ProcessorBox::build_processor_menu ()
712 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/processormenu") );
713 processor_menu->set_name ("ArdourContextMenu");
717 return processor_menu;
721 ProcessorBox::selection_changed ()
723 bool const sensitive = (processor_display.selection().empty()) ? false : true;
724 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
725 edit_action->set_sensitive (one_processor_can_be_edited ());
727 /* disallow rename for multiple selections and for plugin inserts */
728 rename_action->set_sensitive (
729 processor_display.selection().size() == 1 && boost::dynamic_pointer_cast<PluginInsert> (processor_display.selection().front()->processor()) == 0
734 ProcessorBox::select_all_processors ()
736 processor_display.select_all ();
740 ProcessorBox::deselect_all_processors ()
742 processor_display.select_none ();
746 ProcessorBox::choose_plugin ()
748 _get_plugin_selector()->set_interested_object (*this);
751 /** @return true if an error occurred, otherwise false */
753 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
755 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
757 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
759 Route::ProcessorStreams err_streams;
761 if (Config->get_new_plugins_active()) {
762 processor->activate ();
765 if (_route->add_processor (processor, _placement, &err_streams)) {
766 weird_plugin_dialog (**p, err_streams);
768 // XXX SHAREDPTR delete plugin here .. do we even need to care?
771 if (Profile->get_sae()) {
772 processor->activate ();
781 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
783 ArdourDialog dialog (_("Plugin Incompatibility"));
786 string text = string_compose(_("You attempted to add the plugin \"%1\" at index %2.\n"),
787 p.name(), streams.index);
789 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
790 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
792 text += _("\nThis plugin has:\n");
794 uint32_t const n = p.get_info()->n_inputs.n_midi ();
795 text += string_compose (ngettext ("\t%1 MIDI input", "\t%1 MIDI inputs", n), n);
798 uint32_t const n = p.get_info()->n_inputs.n_audio ();
799 text += string_compose (ngettext ("\t%1 audio input", "\t%1 audio inputs", n), n);
802 text += _("\nBut at the insertion point, there are:\n");
804 uint32_t const n = streams.count.n_midi ();
805 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
808 uint32_t const n = streams.count.n_audio ();
809 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
812 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
813 label.set_text(text);
815 dialog.get_vbox()->pack_start (label);
816 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
818 dialog.set_name (X_("PluginIODialog"));
819 dialog.set_position (Gtk::WIN_POS_MOUSE);
820 dialog.set_modal (true);
827 ProcessorBox::choose_insert ()
829 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->mute_master()));
830 _route->add_processor (processor, _placement);
833 /* Caller must not hold process lock */
835 ProcessorBox::choose_send ()
837 boost::shared_ptr<Send> send (new Send (*_session, _route->mute_master()));
839 /* make an educated guess at the initial number of outputs for the send */
840 ChanCount outs = (_session->master_out())
841 ? _session->master_out()->n_outputs()
842 : _route->n_outputs();
844 /* XXX need processor lock on route */
846 Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock());
847 send->output()->ensure_io (outs, false, this);
848 } catch (AudioEngine::PortRegistrationFailure& err) {
849 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
853 /* let the user adjust the IO setup before creation.
855 Note: this dialog is NOT modal - we just leave it to run and it will
856 return when its Finished signal is emitted - typically when the window
860 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
863 /* keep a reference to the send so it doesn't get deleted while
864 the IOSelectorWindow is doing its stuff
866 _processor_being_created = send;
868 ios->selector().Finished.connect (sigc::bind (
869 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
870 boost::weak_ptr<Processor>(send), ios));
875 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
877 boost::shared_ptr<Processor> processor (weak_processor.lock());
879 /* drop our temporary reference to the new send */
880 _processor_being_created.reset ();
887 case IOSelector::Cancelled:
888 // processor will go away when all shared_ptrs to it vanish
891 case IOSelector::Accepted:
892 _route->add_processor (processor, _placement);
893 if (Profile->get_sae()) {
894 processor->activate ();
899 delete_when_idle (ios);
903 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
905 boost::shared_ptr<Processor> processor (weak_processor.lock());
907 /* drop our temporary reference to the new return */
908 _processor_being_created.reset ();
915 case IOSelector::Cancelled:
916 // processor will go away when all shared_ptrs to it vanish
919 case IOSelector::Accepted:
920 _route->add_processor (processor, _placement);
921 if (Profile->get_sae()) {
922 processor->activate ();
927 delete_when_idle (ios);
931 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
937 boost::shared_ptr<Route> target = wr.lock();
943 boost::shared_ptr<RouteList> rlist (new RouteList);
944 rlist->push_back (_route);
946 _session->add_internal_sends (target, PreFader, rlist);
950 ProcessorBox::route_processors_changed (RouteProcessorChange c)
952 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
953 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
957 redisplay_processors ();
961 ProcessorBox::redisplay_processors ()
963 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors)
965 if (no_processor_redisplay) {
969 processor_display.clear ();
971 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
973 build_processor_tooltip (processor_eventbox, _("Inserts, sends & plugins:"));
975 for (list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin(); i != _processor_window_proxies.end(); ++i) {
976 (*i)->marked = false;
979 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
981 /* trim dead wood from the processor window proxy list */
983 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin();
984 while (i != _processor_window_proxies.end()) {
985 list<ProcessorWindowProxy*>::iterator j = i;
989 ARDOUR_UI::instance()->remove_window_proxy (*i);
991 _processor_window_proxies.erase (i);
997 setup_entry_widget_names ();
1000 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
1001 * not already have one.
1004 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
1006 boost::shared_ptr<Processor> p = w.lock ();
1011 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin ();
1012 while (i != _processor_window_proxies.end()) {
1014 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
1017 /* this processor is already on the list; done */
1018 (*i)->marked = true;
1025 /* not on the list; add it */
1028 if (_parent_strip) {
1029 if (_parent_strip->mixer_owned()) {
1038 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
1039 string_compose ("%1-%2-%3", loc, _route->id(), p->id()),
1040 _session->extra_xml (X_("UI")),
1045 _processor_window_proxies.push_back (wp);
1046 ARDOUR_UI::instance()->add_window_proxy (wp);
1050 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
1052 boost::shared_ptr<Processor> processor (p.lock ());
1054 if (!processor || !processor->display_to_user()) {
1058 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
1059 ProcessorEntry* e = 0;
1061 e = new SendProcessorEntry (send, _width);
1063 e = new ProcessorEntry (processor, _width);
1065 e->set_pixel_width (get_allocation().get_width());
1066 processor_display.add_child (e);
1071 ProcessorBox::build_processor_tooltip (EventBox& box, string start)
1075 list<ProcessorEntry*> children = processor_display.children ();
1076 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1078 tip += (*i)->processor()->name();
1081 ARDOUR_UI::instance()->set_tip (box, tip);
1085 ProcessorBox::reordered ()
1087 compute_processor_sort_keys ();
1088 setup_entry_widget_names ();
1091 /* Name the Entry widgets according to pre- or post-fader so that they get coloured right */
1093 ProcessorBox::setup_entry_widget_names ()
1095 /* It just so happens that the action_widget() is the event box (which gives the background
1096 * colour) and the widget() is the frame, more by good luck than good judgement.
1099 list<ProcessorEntry*> children = processor_display.children ();
1100 bool pre_fader = true;
1101 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1102 if (boost::dynamic_pointer_cast<Amp>((*i)->processor())) {
1106 (*i)->action_widget().set_name ("ProcessorPreFader");
1107 (*i)->widget().set_name ("ProcessorPreFaderFrame");
1109 (*i)->action_widget().set_name ("ProcessorPostFader");
1110 (*i)->widget().set_name ("ProcessorPostFaderFrame");
1117 ProcessorBox::compute_processor_sort_keys ()
1119 list<ProcessorEntry*> children = processor_display.children ();
1120 Route::ProcessorList our_processors;
1122 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
1123 our_processors.push_back ((*iter)->processor ());
1126 if (_route->reorder_processors (our_processors)) {
1127 /* Reorder failed, so report this to the user. As far as I can see this must be done
1128 in an idle handler: it seems that the redisplay_processors() that happens below destroys
1129 widgets that were involved in the drag-and-drop on the processor list, which causes problems
1130 when the drag is torn down after this handler function is finished.
1132 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
1137 ProcessorBox::report_failed_reorder ()
1139 /* reorder failed, so redisplay */
1141 redisplay_processors ();
1143 /* now tell them about the problem */
1145 ArdourDialog dialog (_("Plugin Incompatibility"));
1148 label.set_text (_("\
1149 You cannot reorder these plugins/sends/inserts\n\
1150 in that way because the inputs and\n\
1151 outputs will not work correctly."));
1153 dialog.get_vbox()->set_border_width (12);
1154 dialog.get_vbox()->pack_start (label);
1155 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1157 dialog.set_name (X_("PluginIODialog"));
1158 dialog.set_position (Gtk::WIN_POS_MOUSE);
1159 dialog.set_modal (true);
1166 ProcessorBox::rename_processors ()
1168 ProcSelection to_be_renamed;
1170 get_selected_processors (to_be_renamed);
1172 if (to_be_renamed.empty()) {
1176 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
1177 rename_processor (*i);
1182 ProcessorBox::can_cut () const
1184 vector<boost::shared_ptr<Processor> > sel;
1186 get_selected_processors (sel);
1188 /* cut_processors () does not cut inserts */
1190 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
1192 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1193 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1194 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1203 ProcessorBox::cut_processors ()
1205 ProcSelection to_be_removed;
1207 get_selected_processors (to_be_removed);
1211 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
1213 if (to_be_removed.empty()) {
1217 XMLNode* node = new XMLNode (X_("cut"));
1218 Route::ProcessorList to_cut;
1220 no_processor_redisplay = true;
1221 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
1222 // Cut only plugins, sends and returns
1223 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1224 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1225 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1227 Window* w = get_processor_ui (*i);
1233 XMLNode& child ((*i)->get_state());
1234 node->add_child_nocopy (child);
1235 to_cut.push_back (*i);
1239 if (_route->remove_processors (to_cut) != 0) {
1241 no_processor_redisplay = false;
1245 _rr_selection.set (node);
1247 no_processor_redisplay = false;
1248 redisplay_processors ();
1252 ProcessorBox::copy_processors ()
1254 ProcSelection to_be_copied;
1255 get_selected_processors (to_be_copied);
1256 copy_processors (to_be_copied);
1260 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
1262 if (to_be_copied.empty()) {
1266 XMLNode* node = new XMLNode (X_("copy"));
1268 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
1269 // Copy only plugins, sends, returns
1270 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1271 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1272 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1273 node->add_child_nocopy ((*i)->get_state());
1277 _rr_selection.set (node);
1281 ProcessorBox::delete_processors ()
1283 ProcSelection to_be_deleted;
1284 get_selected_processors (to_be_deleted);
1285 delete_processors (to_be_deleted);
1289 ProcessorBox::delete_processors (const ProcSelection& targets)
1291 if (targets.empty()) {
1295 no_processor_redisplay = true;
1297 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
1299 Window* w = get_processor_ui (*i);
1305 _route->remove_processor(*i);
1308 no_processor_redisplay = false;
1309 redisplay_processors ();
1313 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
1315 list<boost::shared_ptr<Processor> >::const_iterator x;
1317 no_processor_redisplay = true;
1318 for (x = procs.begin(); x != procs.end(); ++x) {
1320 Window* w = get_processor_ui (*x);
1326 _route->remove_processor(*x);
1329 no_processor_redisplay = false;
1330 redisplay_processors ();
1334 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
1336 boost::shared_ptr<Processor> processor (weak_processor.lock());
1342 /* NOT copied to _mixer.selection() */
1344 no_processor_redisplay = true;
1345 _route->remove_processor (processor);
1346 no_processor_redisplay = false;
1347 redisplay_processors ();
1353 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
1355 ArdourPrompter name_prompter (true);
1357 name_prompter.set_title (_("Rename Processor"));
1358 name_prompter.set_prompt (_("New name:"));
1359 name_prompter.set_initial_text (processor->name());
1360 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
1361 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
1362 name_prompter.show_all ();
1364 switch (name_prompter.run ()) {
1366 case Gtk::RESPONSE_ACCEPT:
1367 name_prompter.get_result (result);
1368 if (result.length()) {
1371 string test = result;
1373 while (tries < 100) {
1374 if (_session->io_name_is_legal (test)) {
1380 test = string_compose ("%1-%2", result, tries);
1384 processor->set_name (result);
1387 ARDOUR_UI::instance()->popup_error
1388 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
1398 ProcessorBox::paste_processors ()
1400 if (_rr_selection.processors.empty()) {
1404 paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
1408 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
1411 if (_rr_selection.processors.empty()) {
1415 paste_processor_state (_rr_selection.processors.get_node().children(), before);
1419 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
1421 XMLNodeConstIterator niter;
1422 list<boost::shared_ptr<Processor> > copies;
1424 if (nlist.empty()) {
1428 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1430 XMLProperty const * type = (*niter)->property ("type");
1433 boost::shared_ptr<Processor> p;
1435 if (type->value() == "meter" ||
1436 type->value() == "main-outs" ||
1437 type->value() == "amp" ||
1438 type->value() == "intsend" || type->value() == "intreturn") {
1439 /* do not paste meter, main outs, amp or internal send/returns */
1442 } else if (type->value() == "send") {
1444 XMLNode n (**niter);
1445 Send::make_unique (n, *_session);
1446 Send* s = new Send (*_session, _route->mute_master());
1447 if (s->set_state (n, Stateful::loading_state_version)) {
1455 } else if (type->value() == "return") {
1457 XMLNode n (**niter);
1458 Return::make_unique (n, *_session);
1459 Return* r = new Return (*_session);
1461 if (r->set_state (n, Stateful::loading_state_version)) {
1469 /* XXX its a bit limiting to assume that everything else
1473 p.reset (new PluginInsert (*_session));
1474 p->set_state (**niter, Stateful::current_state_version);
1477 copies.push_back (p);
1481 cerr << "plugin insert constructor failed\n";
1485 if (copies.empty()) {
1489 if (_route->add_processors (copies, p)) {
1492 "Copying the set of processors on the clipboard failed,\n\
1493 probably because the I/O configuration of the plugins\n\
1494 could not match the configuration of this track.");
1495 MessageDialog am (msg);
1501 ProcessorBox::activate_processor (boost::shared_ptr<Processor> r)
1507 ProcessorBox::deactivate_processor (boost::shared_ptr<Processor> r)
1513 ProcessorBox::get_selected_processors (ProcSelection& processors) const
1515 const list<ProcessorEntry*> selection = processor_display.selection ();
1516 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
1517 processors.push_back ((*i)->processor ());
1522 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
1524 list<ProcessorEntry*> selection = processor_display.selection ();
1525 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
1526 (this->*method) ((*i)->processor ());
1531 ProcessorBox::all_processors_active (bool state)
1533 _route->all_processors_active (_placement, state);
1537 ProcessorBox::ab_plugins ()
1539 _route->ab_plugins (ab_direction);
1540 ab_direction = !ab_direction;
1545 ProcessorBox::clear_processors ()
1548 vector<string> choices;
1550 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
1551 "(this cannot be undone)"), _route->name());
1553 choices.push_back (_("Cancel"));
1554 choices.push_back (_("Yes, remove them all"));
1556 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1558 if (prompter.run () == 1) {
1559 _route->clear_processors (PreFader);
1560 _route->clear_processors (PostFader);
1565 ProcessorBox::clear_processors (Placement p)
1568 vector<string> choices;
1570 if (p == PreFader) {
1571 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
1572 "(this cannot be undone)"), _route->name());
1574 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
1575 "(this cannot be undone)"), _route->name());
1578 choices.push_back (_("Cancel"));
1579 choices.push_back (_("Yes, remove them all"));
1581 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1583 if (prompter.run () == 1) {
1584 _route->clear_processors (p);
1589 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
1591 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
1592 if (at && at->freeze_state() == AudioTrack::Frozen) {
1597 boost::dynamic_pointer_cast<Send> (processor) ||
1598 boost::dynamic_pointer_cast<Return> (processor) ||
1599 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
1600 boost::dynamic_pointer_cast<PortInsert> (processor)
1609 ProcessorBox::one_processor_can_be_edited ()
1611 list<ProcessorEntry*> selection = processor_display.selection ();
1612 list<ProcessorEntry*>::iterator i = selection.begin();
1613 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
1617 return (i != selection.end());
1621 ProcessorBox::toggle_edit_processor (boost::shared_ptr<Processor> processor)
1623 boost::shared_ptr<Send> send;
1624 boost::shared_ptr<InternalSend> internal_send;
1625 boost::shared_ptr<Return> retrn;
1626 boost::shared_ptr<PluginInsert> plugin_insert;
1627 boost::shared_ptr<PortInsert> port_insert;
1630 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
1632 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
1637 if (boost::dynamic_pointer_cast<Amp> (processor)) {
1639 _parent_strip->revert_to_default_display ();
1641 } else if ((internal_send = boost::dynamic_pointer_cast<InternalSend> (processor)) != 0) {
1643 if (!_session->engine().connected()) {
1647 if (_parent_strip) {
1648 if (boost::dynamic_pointer_cast<Send> (_parent_strip->current_delivery()) == internal_send) {
1649 _parent_strip->revert_to_default_display ();
1651 _parent_strip->show_send (internal_send);
1655 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
1657 if (!_session->engine().connected()) {
1661 SendUIWindow* w = new SendUIWindow (send, _session);
1664 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
1666 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
1667 /* no GUI for these */
1671 if (!_session->engine().connected()) {
1675 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
1677 ReturnUIWindow *return_ui;
1678 Window* w = get_processor_ui (retrn);
1682 return_ui = new ReturnUIWindow (retrn, _session);
1683 return_ui->set_title (retrn->name ());
1684 set_processor_ui (send, return_ui);
1687 return_ui = dynamic_cast<ReturnUIWindow *> (w);
1692 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
1694 PluginUIWindow *plugin_ui;
1696 /* these are both allowed to be null */
1698 Container* toplevel = get_toplevel();
1699 Window* win = dynamic_cast<Gtk::Window*>(toplevel);
1701 Window* w = get_processor_ui (plugin_insert);
1705 plugin_ui = new PluginUIWindow (win, plugin_insert);
1706 plugin_ui->set_title (generate_processor_title (plugin_insert));
1707 set_processor_ui (plugin_insert, plugin_ui);
1710 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
1711 plugin_ui->set_parent (win);
1716 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
1718 if (!_session->engine().connected()) {
1719 MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible"));
1724 PortInsertWindow *io_selector;
1726 Window* w = get_processor_ui (port_insert);
1729 io_selector = new PortInsertWindow (_session, port_insert);
1730 set_processor_ui (port_insert, io_selector);
1733 io_selector = dynamic_cast<PortInsertWindow *> (w);
1736 gidget = io_selector;
1740 if (gidget->is_visible()) {
1743 gidget->show_all ();
1750 ProcessorBox::register_actions ()
1752 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("processormenu"));
1753 Glib::RefPtr<Action> act;
1756 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin"),
1757 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
1759 act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"),
1760 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
1761 ActionManager::jack_sensitive_actions.push_back (act);
1762 act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New Send ..."),
1763 sigc::ptr_fun (ProcessorBox::rb_choose_send));
1764 ActionManager::jack_sensitive_actions.push_back (act);
1766 ActionManager::register_action (popup_act_grp, X_("newaux"), _("New Aux Send ..."));
1768 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear (all)"),
1769 sigc::ptr_fun (ProcessorBox::rb_clear));
1770 ActionManager::register_action (popup_act_grp, X_("clear_pre"), _("Clear (pre-fader)"),
1771 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
1772 ActionManager::register_action (popup_act_grp, X_("clear_post"), _("Clear (post-fader)"),
1773 sigc::ptr_fun (ProcessorBox::rb_clear_post));
1775 /* standard editing stuff */
1776 cut_action = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"),
1777 sigc::ptr_fun (ProcessorBox::rb_cut));
1778 ActionManager::plugin_selection_sensitive_actions.push_back(cut_action);
1779 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),
1780 sigc::ptr_fun (ProcessorBox::rb_copy));
1781 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1783 act = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"),
1784 sigc::ptr_fun (ProcessorBox::rb_delete));
1785 ActionManager::plugin_selection_sensitive_actions.push_back(act); // ??
1787 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"),
1788 sigc::ptr_fun (ProcessorBox::rb_paste));
1789 rename_action = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"),
1790 sigc::ptr_fun (ProcessorBox::rb_rename));
1791 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"),
1792 sigc::ptr_fun (ProcessorBox::rb_select_all));
1793 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"),
1794 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
1796 /* activation etc. */
1798 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate all"),
1799 sigc::ptr_fun (ProcessorBox::rb_activate_all));
1800 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate all"),
1801 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
1802 ActionManager::register_action (popup_act_grp, X_("ab_plugins"), _("A/B Plugins"),
1803 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
1806 edit_action = ActionManager::register_action (popup_act_grp, X_("edit"), _("Edit..."),
1807 sigc::ptr_fun (ProcessorBox::rb_edit));
1809 ActionManager::add_action_group (popup_act_grp);
1813 ProcessorBox::rb_ab_plugins ()
1815 if (_current_processor_box == 0) {
1819 _current_processor_box->ab_plugins ();
1823 ProcessorBox::rb_choose_plugin ()
1825 if (_current_processor_box == 0) {
1828 _current_processor_box->choose_plugin ();
1832 ProcessorBox::rb_choose_insert ()
1834 if (_current_processor_box == 0) {
1837 _current_processor_box->choose_insert ();
1841 ProcessorBox::rb_choose_send ()
1843 if (_current_processor_box == 0) {
1846 _current_processor_box->choose_send ();
1850 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
1852 if (_current_processor_box == 0) {
1856 _current_processor_box->choose_aux (wr);
1860 ProcessorBox::rb_clear ()
1862 if (_current_processor_box == 0) {
1866 _current_processor_box->clear_processors ();
1871 ProcessorBox::rb_clear_pre ()
1873 if (_current_processor_box == 0) {
1877 _current_processor_box->clear_processors (PreFader);
1882 ProcessorBox::rb_clear_post ()
1884 if (_current_processor_box == 0) {
1888 _current_processor_box->clear_processors (PostFader);
1892 ProcessorBox::rb_cut ()
1894 if (_current_processor_box == 0) {
1898 _current_processor_box->cut_processors ();
1902 ProcessorBox::rb_delete ()
1904 if (_current_processor_box == 0) {
1908 _current_processor_box->delete_processors ();
1912 ProcessorBox::rb_copy ()
1914 if (_current_processor_box == 0) {
1917 _current_processor_box->copy_processors ();
1921 ProcessorBox::rb_paste ()
1923 if (_current_processor_box == 0) {
1927 _current_processor_box->paste_processors ();
1931 ProcessorBox::rb_rename ()
1933 if (_current_processor_box == 0) {
1936 _current_processor_box->rename_processors ();
1940 ProcessorBox::rb_select_all ()
1942 if (_current_processor_box == 0) {
1946 _current_processor_box->select_all_processors ();
1950 ProcessorBox::rb_deselect_all ()
1952 if (_current_processor_box == 0) {
1956 _current_processor_box->deselect_all_processors ();
1960 ProcessorBox::rb_activate_all ()
1962 if (_current_processor_box == 0) {
1966 _current_processor_box->all_processors_active (true);
1970 ProcessorBox::rb_deactivate_all ()
1972 if (_current_processor_box == 0) {
1975 _current_processor_box->all_processors_active (false);
1979 ProcessorBox::rb_edit ()
1981 if (_current_processor_box == 0) {
1985 _current_processor_box->for_selected_processors (&ProcessorBox::toggle_edit_processor);
1989 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
1991 if (!what_changed.contains (ARDOUR::Properties::name)) {
1995 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
1997 boost::shared_ptr<Processor> processor;
1998 boost::shared_ptr<PluginInsert> plugin_insert;
1999 boost::shared_ptr<Send> send;
2001 list<ProcessorEntry*> children = processor_display.children();
2003 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
2005 processor = (*iter)->processor ();
2007 Window* w = get_processor_ui (processor);
2013 /* rename editor windows for sends and plugins */
2015 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
2016 w->set_title (send->name ());
2017 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
2018 w->set_title (generate_processor_title (plugin_insert));
2024 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
2026 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
2027 string::size_type email_pos;
2029 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
2030 maker = maker.substr (0, email_pos - 1);
2033 if (maker.length() > 32) {
2034 maker = maker.substr (0, 32);
2038 return string_compose(_("%1: %2 (by %3)"), _route->name(), pi->name(), maker);
2042 ProcessorBox::on_size_allocate (Allocation& a)
2044 HBox::on_size_allocate (a);
2046 list<ProcessorEntry*> children = processor_display.children ();
2047 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
2048 (*i)->set_pixel_width (a.get_width ());
2052 /** @param p Processor.
2053 * @return the UI window for \a p.
2056 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
2058 list<ProcessorWindowProxy*>::const_iterator i = _processor_window_proxies.begin ();
2059 while (i != _processor_window_proxies.end()) {
2060 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2062 return (*i)->get ();
2068 /* we shouldn't get here, because the ProcessorUIList should always contain
2069 an entry for each processor.
2075 /** Make a note of the UI window that a processor is using.
2076 * @param p Processor.
2077 * @param w UI window.
2080 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
2082 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin ();
2083 while (i != _processor_window_proxies.end()) {
2084 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2093 /* we shouldn't get here, because the ProcessorUIList should always contain
2094 an entry for each processor.
2100 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
2102 boost::shared_ptr<Delivery> d = w.lock ();
2107 list<ProcessorEntry*> children = processor_display.children ();
2108 list<ProcessorEntry*>::const_iterator i = children.begin();
2109 while (i != children.end() && (*i)->processor() != d) {
2113 if (i == children.end()) {
2114 processor_display.set_active (0);
2116 processor_display.set_active (*i);
2120 ProcessorWindowProxy::ProcessorWindowProxy (
2121 string const & name,
2122 XMLNode const * node,
2124 boost::weak_ptr<Processor> processor
2126 : WindowProxy<Gtk::Window> (name, node)
2128 , _processor_box (box)
2129 , _processor (processor)
2136 ProcessorWindowProxy::show ()
2138 boost::shared_ptr<Processor> p = _processor.lock ();
2143 _processor_box->toggle_edit_processor (p);