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)
99 , _visual_state (Gtk::STATE_NORMAL)
100 , _position (PreFader)
102 _hbox.pack_start (_active, false, false);
103 _event_box.add (_name);
104 _hbox.pack_start (_event_box, true, true);
105 _vbox.pack_start (_hbox);
108 _name.set_alignment (0, 0.5);
109 _name.set_text (name ());
110 _name.set_padding (2, 2);
112 if (boost::dynamic_pointer_cast<Amp> (p)) {
113 /* Fader processor gets a special look */
114 _event_box.set_name ("ProcessorFader");
115 _frame.set_name ("ProcessorFaderFrame");
116 _name.set_padding (2, 4);
119 _active.set_active (_processor->active ());
120 _active.signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::active_toggled));
122 _processor->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_active_changed, this), gui_context());
123 _processor->PropertyChanged.connect (name_connection, invalidator (*this), ui_bind (&ProcessorEntry::processor_property_changed, this, _1), gui_context());
127 ProcessorEntry::action_widget ()
133 ProcessorEntry::widget ()
139 ProcessorEntry::drag_text () const
145 ProcessorEntry::set_visual_state (Gtk::StateType t)
152 ProcessorEntry::set_position (Position p)
159 ProcessorEntry::setup_visuals ()
163 _event_box.set_name ("ProcessorPreFader");
164 if (_visual_state == Gtk::STATE_NORMAL) {
165 _frame.set_name ("ProcessorPreFaderFrame");
170 _event_box.set_name ("ProcessorFader");
171 if (_visual_state == Gtk::STATE_NORMAL) {
172 _frame.set_name ("ProcessorFaderFrame");
177 _event_box.set_name ("ProcessorPostFader");
178 if (_visual_state == Gtk::STATE_NORMAL) {
179 _frame.set_name ("ProcessorPostFaderFrame");
184 switch (_visual_state) {
185 case Gtk::STATE_NORMAL:
186 /* _frame has been set up above */
187 _event_box.set_state (Gtk::STATE_NORMAL);
189 case Gtk::STATE_SELECTED:
190 _frame.set_name ("ProcessorFrameSelected");
191 /* don't change the background of the box when it is selected */
192 _event_box.set_state (Gtk::STATE_NORMAL);
194 case Gtk::STATE_ACTIVE:
195 _frame.set_name ("ProcessorFrameActiveSend");
196 _event_box.set_state (Gtk::STATE_ACTIVE);
202 boost::shared_ptr<Processor>
203 ProcessorEntry::processor () const
209 ProcessorEntry::set_enum_width (Width w)
215 ProcessorEntry::active_toggled ()
217 if (_active.get_active ()) {
218 if (!_processor->active ()) {
219 _processor->activate ();
222 if (_processor->active ()) {
223 _processor->deactivate ();
229 ProcessorEntry::processor_active_changed ()
231 if (_active.get_active () != _processor->active ()) {
232 _active.set_active (_processor->active ());
237 ProcessorEntry::processor_property_changed (const PropertyChange& what_changed)
239 if (what_changed.contains (ARDOUR::Properties::name)) {
240 _name.set_text (name ());
245 ProcessorEntry::name () const
247 boost::shared_ptr<Send> send;
250 if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
251 !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
255 /* grab the send name out of its overall name */
257 string::size_type lbracket, rbracket;
258 lbracket = send->name().find ('[');
259 rbracket = send->name().find (']');
263 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
266 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
274 name_display += _processor->display_name();
277 name_display += PBD::short_version (_processor->display_name(), 5);
286 SendProcessorEntry::SendProcessorEntry (boost::shared_ptr<Send> s, Width w)
287 : ProcessorEntry (s, w),
289 /* set the adjustment to a gain of 0dB so that the fader's default value is right */
290 _adjustment (0.781787, 0, 1, 0.01, 0.1),
291 _fader (_slider, &_adjustment, 0, false),
292 _ignore_gain_change (false)
294 _fader.set_name ("SendFader");
295 _fader.set_controllable (_send->amp()->gain_control ());
296 _vbox.pack_start (_fader);
298 _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &SendProcessorEntry::gain_adjusted));
299 _send->amp()->gain_control()->Changed.connect (send_gain_connection, invalidator (*this), boost::bind (&SendProcessorEntry::show_gain, this), gui_context());
304 SendProcessorEntry::setup_slider_pix ()
306 _slider = ::get_icon ("fader_belt_h_thin");
311 SendProcessorEntry::show_gain ()
313 ENSURE_GUI_THREAD (*this, &SendProcessorEntry::show_gain)
315 float const value = gain_to_slider_position (_send->amp()->gain ());
317 if (_adjustment.get_value() != value) {
318 _ignore_gain_change = true;
319 _adjustment.set_value (value);
320 _ignore_gain_change = false;
325 SendProcessorEntry::gain_adjusted ()
327 if (_ignore_gain_change) {
331 _send->amp()->set_gain (slider_position_to_gain (_adjustment.get_value()), this);
335 SendProcessorEntry::set_pixel_width (int p)
337 _fader.set_fader_length (p);
340 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
341 RouteRedirectSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
342 : _parent_strip (parent)
343 , _owner_is_mixer (owner_is_mixer)
344 , ab_direction (true)
345 , _get_plugin_selector (get_plugin_selector)
346 , _placement(PreFader)
347 , _rr_selection(rsel)
353 send_action_menu = 0;
354 no_processor_redisplay = false;
356 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
357 processor_scroller.add (processor_display);
358 pack_start (processor_scroller, true, true);
360 processor_display.set_flags (CAN_FOCUS);
361 processor_display.set_name ("ProcessorList");
362 processor_display.set_size_request (48, -1);
363 processor_display.set_data ("processorbox", this);
364 processor_display.set_spacing (2);
366 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
367 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
369 processor_display.signal_key_press_event().connect (sigc::mem_fun(*this, &ProcessorBox::processor_key_press_event));
370 processor_display.signal_key_release_event().connect (sigc::mem_fun(*this, &ProcessorBox::processor_key_release_event));
372 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
373 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
375 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
376 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
377 processor_display.SelectionChanged.connect (sigc::mem_fun (*this, &ProcessorBox::selection_changed));
380 parent->DeliveryChanged.connect (
381 _mixer_strip_connections, invalidator (*this), ui_bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
386 ProcessorBox::~ProcessorBox ()
391 ProcessorBox::set_route (boost::shared_ptr<Route> r)
397 _route_connections.drop_connections();
399 /* new route: any existing block on processor redisplay must be meaningless */
400 no_processor_redisplay = false;
403 _route->processors_changed.connect (
404 _route_connections, invalidator (*this), ui_bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
407 _route->DropReferences.connect (
408 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
411 _route->PropertyChanged.connect (
412 _route_connections, invalidator (*this), ui_bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
415 redisplay_processors ();
419 ProcessorBox::route_going_away ()
421 /* don't keep updating display as processors are deleted */
422 no_processor_redisplay = true;
426 ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
428 boost::shared_ptr<Processor> p;
430 p = position->processor ();
433 list<ProcessorEntry*> children = source->selection ();
434 list<boost::shared_ptr<Processor> > procs;
435 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
436 procs.push_back ((*i)->processor ());
439 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
440 XMLNode& state = (*i)->get_state ();
442 nlist.push_back (&state);
443 paste_processor_state (nlist, p);
447 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
451 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
452 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
454 cerr << "source was another processor box, delete the selected items\n";
455 other->delete_dragged_processors (procs);
461 ProcessorBox::update()
463 redisplay_processors ();
467 ProcessorBox::set_width (Width w)
475 list<ProcessorEntry*> children = processor_display.children ();
476 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
477 (*i)->set_enum_width (w);
480 redisplay_processors ();
484 ProcessorBox::build_send_action_menu ()
486 using namespace Menu_Helpers;
488 send_action_menu = new Menu;
489 send_action_menu->set_name ("ArdourContextMenu");
490 MenuList& items = send_action_menu->items();
492 items.push_back (MenuElem (_("New send"), sigc::mem_fun(*this, &ProcessorBox::new_send)));
493 items.push_back (MenuElem (_("Show send controls"), sigc::mem_fun(*this, &ProcessorBox::show_send_controls)));
497 ProcessorBox::build_possible_aux_menu ()
499 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
505 using namespace Menu_Helpers;
506 Menu* menu = manage (new Menu);
507 MenuList& items = menu->items();
509 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
510 if (!_route->internal_send_for (*r) && *r != _route) {
511 items.push_back (MenuElem ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
519 ProcessorBox::show_send_controls ()
524 ProcessorBox::new_send ()
529 ProcessorBox::show_processor_menu (gint arg)
531 if (processor_menu == 0) {
532 processor_menu = build_processor_menu ();
535 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/processormenu/newplugin"));
537 if (plugin_menu_item) {
538 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
541 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/processormenu/newaux"));
544 Menu* m = build_possible_aux_menu();
545 if (m && !m->items().empty()) {
546 aux_menu_item->set_submenu (*m);
547 aux_menu_item->set_sensitive (true);
549 /* stupid gtkmm: we need to pass a null reference here */
550 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
551 aux_menu_item->set_sensitive (false);
555 cut_action->set_sensitive (can_cut());
556 paste_action->set_sensitive (!_rr_selection.processors.empty());
558 processor_menu->popup (1, arg);
562 ProcessorBox::enter_notify (GdkEventCrossing*)
564 _current_processor_box = this;
565 Keyboard::magic_widget_grab_focus ();
566 processor_display.grab_focus ();
572 ProcessorBox::leave_notify (GdkEventCrossing* ev)
574 switch (ev->detail) {
575 case GDK_NOTIFY_INFERIOR:
578 Keyboard::magic_widget_drop_focus ();
585 ProcessorBox::processor_key_press_event (GdkEventKey *)
587 /* do real stuff on key release */
592 ProcessorBox::processor_key_release_event (GdkEventKey *ev)
595 ProcSelection targets;
597 get_selected_processors (targets);
599 if (targets.empty()) {
602 processor_display.get_pointer (x, y);
604 pair<ProcessorEntry *, double> const pointer = processor_display.get_child_at_position (y);
607 targets.push_back (pointer.first->processor ());
612 switch (ev->keyval) {
614 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
615 processor_display.select_all ();
621 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
622 copy_processors (targets);
628 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
629 cut_processors (targets);
635 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
636 if (targets.empty()) {
639 paste_processors (targets.front());
653 delete_processors (targets);
658 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
659 if ((*i)->active()) {
681 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
683 boost::shared_ptr<Processor> processor;
685 processor = child->processor ();
689 bool selected = processor_display.selected (child);
691 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
693 if (_session->engine().connected()) {
694 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
695 toggle_edit_processor (processor);
699 } else if (processor && ev->button == 1 && selected) {
701 // this is purely informational but necessary for route params UI
702 ProcessorSelected (processor); // emit
704 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
707 _get_plugin_selector()->show_manager ();
714 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
716 boost::shared_ptr<Processor> processor;
718 processor = child->processor ();
723 if (processor && Keyboard::is_delete_event (ev)) {
725 Glib::signal_idle().connect (sigc::bind (
726 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
727 boost::weak_ptr<Processor>(processor)));
730 } else if (Keyboard::is_context_menu_event (ev)) {
732 /* figure out if we are above or below the fader/amp processor,
733 and set the next insert position appropriately.
737 if (_route->processor_is_prefader (processor)) {
738 _placement = PreFader;
740 _placement = PostFader;
743 _placement = PostFader;
746 show_processor_menu (ev->time);
749 } else if (processor && Keyboard::is_button2_event (ev)
751 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
755 /* button2-click with no/appropriate modifiers */
757 if (processor->active()) {
758 processor->deactivate ();
760 processor->activate ();
770 ProcessorBox::build_processor_menu ()
772 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/processormenu") );
773 processor_menu->set_name ("ArdourContextMenu");
777 return processor_menu;
781 ProcessorBox::selection_changed ()
783 bool const sensitive = (processor_display.selection().empty()) ? false : true;
784 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
785 edit_action->set_sensitive (one_processor_can_be_edited ());
787 /* disallow rename for multiple selections and for plugin inserts */
788 rename_action->set_sensitive (
789 processor_display.selection().size() == 1 && boost::dynamic_pointer_cast<PluginInsert> (processor_display.selection().front()->processor()) == 0
794 ProcessorBox::select_all_processors ()
796 processor_display.select_all ();
800 ProcessorBox::deselect_all_processors ()
802 processor_display.select_none ();
806 ProcessorBox::choose_plugin ()
808 _get_plugin_selector()->set_interested_object (*this);
811 /** @return true if an error occurred, otherwise false */
813 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
815 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
817 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
819 Route::ProcessorStreams err_streams;
821 if (Config->get_new_plugins_active()) {
822 processor->activate ();
825 if (_route->add_processor (processor, _placement, &err_streams)) {
826 weird_plugin_dialog (**p, err_streams);
828 // XXX SHAREDPTR delete plugin here .. do we even need to care?
831 if (Profile->get_sae()) {
832 processor->activate ();
841 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
843 ArdourDialog dialog (_("Plugin Incompatibility"));
846 string text = string_compose(_("You attempted to add the plugin \"%1\" at index %2.\n"),
847 p.name(), streams.index);
849 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
850 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
852 text += _("\nThis plugin has:\n");
854 uint32_t const n = p.get_info()->n_inputs.n_midi ();
855 text += string_compose (ngettext ("\t%1 MIDI input", "\t%1 MIDI inputs", n), n);
858 uint32_t const n = p.get_info()->n_inputs.n_audio ();
859 text += string_compose (ngettext ("\t%1 audio input", "\t%1 audio inputs", n), n);
862 text += _("\nBut at the insertion point, there are:\n");
864 uint32_t const n = streams.count.n_midi ();
865 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
868 uint32_t const n = streams.count.n_audio ();
869 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
872 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
873 label.set_text(text);
875 dialog.get_vbox()->pack_start (label);
876 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
878 dialog.set_name (X_("PluginIODialog"));
879 dialog.set_position (Gtk::WIN_POS_MOUSE);
880 dialog.set_modal (true);
887 ProcessorBox::choose_insert ()
889 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->mute_master()));
890 _route->add_processor (processor, _placement);
893 /* Caller must not hold process lock */
895 ProcessorBox::choose_send ()
897 boost::shared_ptr<Send> send (new Send (*_session, _route->mute_master()));
899 /* make an educated guess at the initial number of outputs for the send */
900 ChanCount outs = (_session->master_out())
901 ? _session->master_out()->n_outputs()
902 : _route->n_outputs();
904 /* XXX need processor lock on route */
906 Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock());
907 send->output()->ensure_io (outs, false, this);
908 } catch (AudioEngine::PortRegistrationFailure& err) {
909 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
913 /* let the user adjust the IO setup before creation.
915 Note: this dialog is NOT modal - we just leave it to run and it will
916 return when its Finished signal is emitted - typically when the window
920 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
923 /* keep a reference to the send so it doesn't get deleted while
924 the IOSelectorWindow is doing its stuff
926 _processor_being_created = send;
928 ios->selector().Finished.connect (sigc::bind (
929 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
930 boost::weak_ptr<Processor>(send), ios));
935 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
937 boost::shared_ptr<Processor> processor (weak_processor.lock());
939 /* drop our temporary reference to the new send */
940 _processor_being_created.reset ();
947 case IOSelector::Cancelled:
948 // processor will go away when all shared_ptrs to it vanish
951 case IOSelector::Accepted:
952 _route->add_processor (processor, _placement);
953 if (Profile->get_sae()) {
954 processor->activate ();
959 delete_when_idle (ios);
963 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
965 boost::shared_ptr<Processor> processor (weak_processor.lock());
967 /* drop our temporary reference to the new return */
968 _processor_being_created.reset ();
975 case IOSelector::Cancelled:
976 // processor will go away when all shared_ptrs to it vanish
979 case IOSelector::Accepted:
980 _route->add_processor (processor, _placement);
981 if (Profile->get_sae()) {
982 processor->activate ();
987 delete_when_idle (ios);
991 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
997 boost::shared_ptr<Route> target = wr.lock();
1003 boost::shared_ptr<RouteList> rlist (new RouteList);
1004 rlist->push_back (_route);
1006 _session->add_internal_sends (target, PreFader, rlist);
1010 ProcessorBox::route_processors_changed (RouteProcessorChange c)
1012 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
1013 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
1017 redisplay_processors ();
1021 ProcessorBox::redisplay_processors ()
1023 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors)
1025 if (no_processor_redisplay) {
1029 processor_display.clear ();
1031 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
1033 build_processor_tooltip (processor_eventbox, _("Inserts, sends & plugins:"));
1035 for (list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin(); i != _processor_window_proxies.end(); ++i) {
1036 (*i)->marked = false;
1039 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
1041 /* trim dead wood from the processor window proxy list */
1043 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin();
1044 while (i != _processor_window_proxies.end()) {
1045 list<ProcessorWindowProxy*>::iterator j = i;
1048 if (!(*i)->marked) {
1049 ARDOUR_UI::instance()->remove_window_proxy (*i);
1051 _processor_window_proxies.erase (i);
1057 setup_entry_positions ();
1060 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
1061 * not already have one.
1064 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
1066 boost::shared_ptr<Processor> p = w.lock ();
1071 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin ();
1072 while (i != _processor_window_proxies.end()) {
1074 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
1077 /* this processor is already on the list; done */
1078 (*i)->marked = true;
1085 /* not on the list; add it */
1088 if (_parent_strip) {
1089 if (_parent_strip->mixer_owned()) {
1098 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
1099 string_compose ("%1-%2-%3", loc, _route->id(), p->id()),
1100 _session->extra_xml (X_("UI")),
1105 _processor_window_proxies.push_back (wp);
1106 ARDOUR_UI::instance()->add_window_proxy (wp);
1110 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
1112 boost::shared_ptr<Processor> processor (p.lock ());
1114 if (!processor || !processor->display_to_user()) {
1118 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
1119 ProcessorEntry* e = 0;
1121 e = new SendProcessorEntry (send, _width);
1123 e = new ProcessorEntry (processor, _width);
1125 e->set_pixel_width (get_allocation().get_width());
1126 processor_display.add_child (e);
1131 ProcessorBox::build_processor_tooltip (EventBox& box, string start)
1135 list<ProcessorEntry*> children = processor_display.children ();
1136 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1138 tip += (*i)->processor()->name();
1141 ARDOUR_UI::instance()->set_tip (box, tip);
1145 ProcessorBox::reordered ()
1147 compute_processor_sort_keys ();
1148 setup_entry_positions ();
1152 ProcessorBox::setup_entry_positions ()
1154 list<ProcessorEntry*> children = processor_display.children ();
1155 bool pre_fader = true;
1157 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1158 if (boost::dynamic_pointer_cast<Amp>((*i)->processor())) {
1160 (*i)->set_position (ProcessorEntry::Fader);
1163 (*i)->set_position (ProcessorEntry::PreFader);
1165 (*i)->set_position (ProcessorEntry::PostFader);
1172 ProcessorBox::compute_processor_sort_keys ()
1174 list<ProcessorEntry*> children = processor_display.children ();
1175 Route::ProcessorList our_processors;
1177 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
1178 our_processors.push_back ((*iter)->processor ());
1181 if (_route->reorder_processors (our_processors)) {
1182 /* Reorder failed, so report this to the user. As far as I can see this must be done
1183 in an idle handler: it seems that the redisplay_processors() that happens below destroys
1184 widgets that were involved in the drag-and-drop on the processor list, which causes problems
1185 when the drag is torn down after this handler function is finished.
1187 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
1192 ProcessorBox::report_failed_reorder ()
1194 /* reorder failed, so redisplay */
1196 redisplay_processors ();
1198 /* now tell them about the problem */
1200 ArdourDialog dialog (_("Plugin Incompatibility"));
1203 label.set_text (_("\
1204 You cannot reorder these plugins/sends/inserts\n\
1205 in that way because the inputs and\n\
1206 outputs will not work correctly."));
1208 dialog.get_vbox()->set_border_width (12);
1209 dialog.get_vbox()->pack_start (label);
1210 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1212 dialog.set_name (X_("PluginIODialog"));
1213 dialog.set_position (Gtk::WIN_POS_MOUSE);
1214 dialog.set_modal (true);
1221 ProcessorBox::rename_processors ()
1223 ProcSelection to_be_renamed;
1225 get_selected_processors (to_be_renamed);
1227 if (to_be_renamed.empty()) {
1231 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
1232 rename_processor (*i);
1237 ProcessorBox::can_cut () const
1239 vector<boost::shared_ptr<Processor> > sel;
1241 get_selected_processors (sel);
1243 /* cut_processors () does not cut inserts */
1245 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
1247 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1248 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1249 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1258 ProcessorBox::cut_processors ()
1260 ProcSelection to_be_removed;
1262 get_selected_processors (to_be_removed);
1266 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
1268 if (to_be_removed.empty()) {
1272 XMLNode* node = new XMLNode (X_("cut"));
1273 Route::ProcessorList to_cut;
1275 no_processor_redisplay = true;
1276 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
1277 // Cut only plugins, sends and returns
1278 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1279 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1280 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1282 Window* w = get_processor_ui (*i);
1288 XMLNode& child ((*i)->get_state());
1289 node->add_child_nocopy (child);
1290 to_cut.push_back (*i);
1294 if (_route->remove_processors (to_cut) != 0) {
1296 no_processor_redisplay = false;
1300 _rr_selection.set (node);
1302 no_processor_redisplay = false;
1303 redisplay_processors ();
1307 ProcessorBox::copy_processors ()
1309 ProcSelection to_be_copied;
1310 get_selected_processors (to_be_copied);
1311 copy_processors (to_be_copied);
1315 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
1317 if (to_be_copied.empty()) {
1321 XMLNode* node = new XMLNode (X_("copy"));
1323 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
1324 // Copy only plugins, sends, returns
1325 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1326 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1327 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1328 node->add_child_nocopy ((*i)->get_state());
1332 _rr_selection.set (node);
1336 ProcessorBox::delete_processors ()
1338 ProcSelection to_be_deleted;
1339 get_selected_processors (to_be_deleted);
1340 delete_processors (to_be_deleted);
1344 ProcessorBox::delete_processors (const ProcSelection& targets)
1346 if (targets.empty()) {
1350 no_processor_redisplay = true;
1352 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
1354 Window* w = get_processor_ui (*i);
1360 _route->remove_processor(*i);
1363 no_processor_redisplay = false;
1364 redisplay_processors ();
1368 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
1370 list<boost::shared_ptr<Processor> >::const_iterator x;
1372 no_processor_redisplay = true;
1373 for (x = procs.begin(); x != procs.end(); ++x) {
1375 Window* w = get_processor_ui (*x);
1381 _route->remove_processor(*x);
1384 no_processor_redisplay = false;
1385 redisplay_processors ();
1389 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
1391 boost::shared_ptr<Processor> processor (weak_processor.lock());
1397 /* NOT copied to _mixer.selection() */
1399 no_processor_redisplay = true;
1400 _route->remove_processor (processor);
1401 no_processor_redisplay = false;
1402 redisplay_processors ();
1408 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
1410 ArdourPrompter name_prompter (true);
1412 name_prompter.set_title (_("Rename Processor"));
1413 name_prompter.set_prompt (_("New name:"));
1414 name_prompter.set_initial_text (processor->name());
1415 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
1416 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
1417 name_prompter.show_all ();
1419 switch (name_prompter.run ()) {
1421 case Gtk::RESPONSE_ACCEPT:
1422 name_prompter.get_result (result);
1423 if (result.length()) {
1426 string test = result;
1428 while (tries < 100) {
1429 if (_session->io_name_is_legal (test)) {
1435 test = string_compose ("%1-%2", result, tries);
1439 processor->set_name (result);
1442 ARDOUR_UI::instance()->popup_error
1443 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
1453 ProcessorBox::paste_processors ()
1455 if (_rr_selection.processors.empty()) {
1459 paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
1463 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
1466 if (_rr_selection.processors.empty()) {
1470 paste_processor_state (_rr_selection.processors.get_node().children(), before);
1474 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
1476 XMLNodeConstIterator niter;
1477 list<boost::shared_ptr<Processor> > copies;
1479 if (nlist.empty()) {
1483 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1485 XMLProperty const * type = (*niter)->property ("type");
1488 boost::shared_ptr<Processor> p;
1490 if (type->value() == "meter" ||
1491 type->value() == "main-outs" ||
1492 type->value() == "amp" ||
1493 type->value() == "intsend" || type->value() == "intreturn") {
1494 /* do not paste meter, main outs, amp or internal send/returns */
1497 } else if (type->value() == "send") {
1499 XMLNode n (**niter);
1500 Send::make_unique (n, *_session);
1501 Send* s = new Send (*_session, _route->mute_master());
1502 if (s->set_state (n, Stateful::loading_state_version)) {
1510 } else if (type->value() == "return") {
1512 XMLNode n (**niter);
1513 Return::make_unique (n, *_session);
1514 Return* r = new Return (*_session);
1516 if (r->set_state (n, Stateful::loading_state_version)) {
1524 /* XXX its a bit limiting to assume that everything else
1528 p.reset (new PluginInsert (*_session));
1529 p->set_state (**niter, Stateful::current_state_version);
1532 copies.push_back (p);
1536 cerr << "plugin insert constructor failed\n";
1540 if (copies.empty()) {
1544 if (_route->add_processors (copies, p)) {
1547 "Copying the set of processors on the clipboard failed,\n\
1548 probably because the I/O configuration of the plugins\n\
1549 could not match the configuration of this track.");
1550 MessageDialog am (msg);
1556 ProcessorBox::activate_processor (boost::shared_ptr<Processor> r)
1562 ProcessorBox::deactivate_processor (boost::shared_ptr<Processor> r)
1568 ProcessorBox::get_selected_processors (ProcSelection& processors) const
1570 const list<ProcessorEntry*> selection = processor_display.selection ();
1571 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
1572 processors.push_back ((*i)->processor ());
1577 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
1579 list<ProcessorEntry*> selection = processor_display.selection ();
1580 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
1581 (this->*method) ((*i)->processor ());
1586 ProcessorBox::all_processors_active (bool state)
1588 _route->all_processors_active (_placement, state);
1592 ProcessorBox::ab_plugins ()
1594 _route->ab_plugins (ab_direction);
1595 ab_direction = !ab_direction;
1600 ProcessorBox::clear_processors ()
1603 vector<string> choices;
1605 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
1606 "(this cannot be undone)"), _route->name());
1608 choices.push_back (_("Cancel"));
1609 choices.push_back (_("Yes, remove them all"));
1611 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1613 if (prompter.run () == 1) {
1614 _route->clear_processors (PreFader);
1615 _route->clear_processors (PostFader);
1620 ProcessorBox::clear_processors (Placement p)
1623 vector<string> choices;
1625 if (p == PreFader) {
1626 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
1627 "(this cannot be undone)"), _route->name());
1629 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
1630 "(this cannot be undone)"), _route->name());
1633 choices.push_back (_("Cancel"));
1634 choices.push_back (_("Yes, remove them all"));
1636 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1638 if (prompter.run () == 1) {
1639 _route->clear_processors (p);
1644 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
1646 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
1647 if (at && at->freeze_state() == AudioTrack::Frozen) {
1652 boost::dynamic_pointer_cast<Send> (processor) ||
1653 boost::dynamic_pointer_cast<Return> (processor) ||
1654 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
1655 boost::dynamic_pointer_cast<PortInsert> (processor)
1664 ProcessorBox::one_processor_can_be_edited ()
1666 list<ProcessorEntry*> selection = processor_display.selection ();
1667 list<ProcessorEntry*>::iterator i = selection.begin();
1668 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
1672 return (i != selection.end());
1676 ProcessorBox::toggle_edit_processor (boost::shared_ptr<Processor> processor)
1678 boost::shared_ptr<Send> send;
1679 boost::shared_ptr<InternalSend> internal_send;
1680 boost::shared_ptr<Return> retrn;
1681 boost::shared_ptr<PluginInsert> plugin_insert;
1682 boost::shared_ptr<PortInsert> port_insert;
1685 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
1687 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
1692 if (boost::dynamic_pointer_cast<Amp> (processor)) {
1694 _parent_strip->revert_to_default_display ();
1696 } else if ((internal_send = boost::dynamic_pointer_cast<InternalSend> (processor)) != 0) {
1698 if (!_session->engine().connected()) {
1702 if (_parent_strip) {
1703 if (boost::dynamic_pointer_cast<Send> (_parent_strip->current_delivery()) == internal_send) {
1704 _parent_strip->revert_to_default_display ();
1706 _parent_strip->show_send (internal_send);
1710 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
1712 if (!_session->engine().connected()) {
1716 SendUIWindow* w = new SendUIWindow (send, _session);
1719 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
1721 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
1722 /* no GUI for these */
1726 if (!_session->engine().connected()) {
1730 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
1732 ReturnUIWindow *return_ui;
1733 Window* w = get_processor_ui (retrn);
1737 return_ui = new ReturnUIWindow (retrn, _session);
1738 return_ui->set_title (retrn->name ());
1739 set_processor_ui (send, return_ui);
1742 return_ui = dynamic_cast<ReturnUIWindow *> (w);
1747 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
1749 PluginUIWindow *plugin_ui;
1751 /* these are both allowed to be null */
1753 Container* toplevel = get_toplevel();
1754 Window* win = dynamic_cast<Gtk::Window*>(toplevel);
1756 Window* w = get_processor_ui (plugin_insert);
1760 plugin_ui = new PluginUIWindow (win, plugin_insert);
1761 plugin_ui->set_title (generate_processor_title (plugin_insert));
1762 set_processor_ui (plugin_insert, plugin_ui);
1765 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
1766 plugin_ui->set_parent (win);
1771 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
1773 if (!_session->engine().connected()) {
1774 MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible"));
1779 PortInsertWindow *io_selector;
1781 Window* w = get_processor_ui (port_insert);
1784 io_selector = new PortInsertWindow (_session, port_insert);
1785 set_processor_ui (port_insert, io_selector);
1788 io_selector = dynamic_cast<PortInsertWindow *> (w);
1791 gidget = io_selector;
1795 if (gidget->is_visible()) {
1798 gidget->show_all ();
1805 ProcessorBox::register_actions ()
1807 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("processormenu"));
1808 Glib::RefPtr<Action> act;
1811 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin"),
1812 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
1814 act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"),
1815 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
1816 ActionManager::jack_sensitive_actions.push_back (act);
1817 act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New Send ..."),
1818 sigc::ptr_fun (ProcessorBox::rb_choose_send));
1819 ActionManager::jack_sensitive_actions.push_back (act);
1821 ActionManager::register_action (popup_act_grp, X_("newaux"), _("New Aux Send ..."));
1823 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear (all)"),
1824 sigc::ptr_fun (ProcessorBox::rb_clear));
1825 ActionManager::register_action (popup_act_grp, X_("clear_pre"), _("Clear (pre-fader)"),
1826 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
1827 ActionManager::register_action (popup_act_grp, X_("clear_post"), _("Clear (post-fader)"),
1828 sigc::ptr_fun (ProcessorBox::rb_clear_post));
1830 /* standard editing stuff */
1831 cut_action = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"),
1832 sigc::ptr_fun (ProcessorBox::rb_cut));
1833 ActionManager::plugin_selection_sensitive_actions.push_back(cut_action);
1834 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),
1835 sigc::ptr_fun (ProcessorBox::rb_copy));
1836 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1838 act = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"),
1839 sigc::ptr_fun (ProcessorBox::rb_delete));
1840 ActionManager::plugin_selection_sensitive_actions.push_back(act); // ??
1842 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"),
1843 sigc::ptr_fun (ProcessorBox::rb_paste));
1844 rename_action = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"),
1845 sigc::ptr_fun (ProcessorBox::rb_rename));
1846 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"),
1847 sigc::ptr_fun (ProcessorBox::rb_select_all));
1848 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"),
1849 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
1851 /* activation etc. */
1853 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate all"),
1854 sigc::ptr_fun (ProcessorBox::rb_activate_all));
1855 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate all"),
1856 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
1857 ActionManager::register_action (popup_act_grp, X_("ab_plugins"), _("A/B Plugins"),
1858 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
1861 edit_action = ActionManager::register_action (popup_act_grp, X_("edit"), _("Edit..."),
1862 sigc::ptr_fun (ProcessorBox::rb_edit));
1864 ActionManager::add_action_group (popup_act_grp);
1868 ProcessorBox::rb_ab_plugins ()
1870 if (_current_processor_box == 0) {
1874 _current_processor_box->ab_plugins ();
1878 ProcessorBox::rb_choose_plugin ()
1880 if (_current_processor_box == 0) {
1883 _current_processor_box->choose_plugin ();
1887 ProcessorBox::rb_choose_insert ()
1889 if (_current_processor_box == 0) {
1892 _current_processor_box->choose_insert ();
1896 ProcessorBox::rb_choose_send ()
1898 if (_current_processor_box == 0) {
1901 _current_processor_box->choose_send ();
1905 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
1907 if (_current_processor_box == 0) {
1911 _current_processor_box->choose_aux (wr);
1915 ProcessorBox::rb_clear ()
1917 if (_current_processor_box == 0) {
1921 _current_processor_box->clear_processors ();
1926 ProcessorBox::rb_clear_pre ()
1928 if (_current_processor_box == 0) {
1932 _current_processor_box->clear_processors (PreFader);
1937 ProcessorBox::rb_clear_post ()
1939 if (_current_processor_box == 0) {
1943 _current_processor_box->clear_processors (PostFader);
1947 ProcessorBox::rb_cut ()
1949 if (_current_processor_box == 0) {
1953 _current_processor_box->cut_processors ();
1957 ProcessorBox::rb_delete ()
1959 if (_current_processor_box == 0) {
1963 _current_processor_box->delete_processors ();
1967 ProcessorBox::rb_copy ()
1969 if (_current_processor_box == 0) {
1972 _current_processor_box->copy_processors ();
1976 ProcessorBox::rb_paste ()
1978 if (_current_processor_box == 0) {
1982 _current_processor_box->paste_processors ();
1986 ProcessorBox::rb_rename ()
1988 if (_current_processor_box == 0) {
1991 _current_processor_box->rename_processors ();
1995 ProcessorBox::rb_select_all ()
1997 if (_current_processor_box == 0) {
2001 _current_processor_box->select_all_processors ();
2005 ProcessorBox::rb_deselect_all ()
2007 if (_current_processor_box == 0) {
2011 _current_processor_box->deselect_all_processors ();
2015 ProcessorBox::rb_activate_all ()
2017 if (_current_processor_box == 0) {
2021 _current_processor_box->all_processors_active (true);
2025 ProcessorBox::rb_deactivate_all ()
2027 if (_current_processor_box == 0) {
2030 _current_processor_box->all_processors_active (false);
2034 ProcessorBox::rb_edit ()
2036 if (_current_processor_box == 0) {
2040 _current_processor_box->for_selected_processors (&ProcessorBox::toggle_edit_processor);
2044 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
2046 if (!what_changed.contains (ARDOUR::Properties::name)) {
2050 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
2052 boost::shared_ptr<Processor> processor;
2053 boost::shared_ptr<PluginInsert> plugin_insert;
2054 boost::shared_ptr<Send> send;
2056 list<ProcessorEntry*> children = processor_display.children();
2058 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
2060 processor = (*iter)->processor ();
2062 Window* w = get_processor_ui (processor);
2068 /* rename editor windows for sends and plugins */
2070 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
2071 w->set_title (send->name ());
2072 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
2073 w->set_title (generate_processor_title (plugin_insert));
2079 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
2081 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
2082 string::size_type email_pos;
2084 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
2085 maker = maker.substr (0, email_pos - 1);
2088 if (maker.length() > 32) {
2089 maker = maker.substr (0, 32);
2093 return string_compose(_("%1: %2 (by %3)"), _route->name(), pi->name(), maker);
2097 ProcessorBox::on_size_allocate (Allocation& a)
2099 HBox::on_size_allocate (a);
2101 list<ProcessorEntry*> children = processor_display.children ();
2102 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
2103 (*i)->set_pixel_width (a.get_width ());
2107 /** @param p Processor.
2108 * @return the UI window for \a p.
2111 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
2113 list<ProcessorWindowProxy*>::const_iterator i = _processor_window_proxies.begin ();
2114 while (i != _processor_window_proxies.end()) {
2115 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2117 return (*i)->get ();
2123 /* we shouldn't get here, because the ProcessorUIList should always contain
2124 an entry for each processor.
2130 /** Make a note of the UI window that a processor is using.
2131 * @param p Processor.
2132 * @param w UI window.
2135 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
2137 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin ();
2138 while (i != _processor_window_proxies.end()) {
2139 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2148 /* we shouldn't get here, because the ProcessorUIList should always contain
2149 an entry for each processor.
2155 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
2157 boost::shared_ptr<Delivery> d = w.lock ();
2162 list<ProcessorEntry*> children = processor_display.children ();
2163 list<ProcessorEntry*>::const_iterator i = children.begin();
2164 while (i != children.end() && (*i)->processor() != d) {
2168 if (i == children.end()) {
2169 processor_display.set_active (0);
2171 processor_display.set_active (*i);
2175 ProcessorWindowProxy::ProcessorWindowProxy (
2176 string const & name,
2177 XMLNode const * node,
2179 boost::weak_ptr<Processor> processor
2181 : WindowProxy<Gtk::Window> (name, node)
2183 , _processor_box (box)
2184 , _processor (processor)
2191 ProcessorWindowProxy::show ()
2193 boost::shared_ptr<Processor> p = _processor.lock ();
2198 _processor_box->toggle_edit_processor (p);