2 Copyright (C) 2000-2004 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "gtk2ardour-config.h"
28 #include <sigc++/bind.h>
30 #include "pbd/convert.h"
32 #include <glibmm/miscutils.h>
34 #include <gtkmm/messagedialog.h>
36 #include <gtkmm2ext/gtk_ui.h>
37 #include <gtkmm2ext/utils.h>
38 #include <gtkmm2ext/choice.h>
39 #include <gtkmm2ext/utils.h>
40 #include <gtkmm2ext/doi.h>
42 #include "ardour/amp.h"
43 #include "ardour/ardour.h"
44 #include "ardour/audio_track.h"
45 #include "ardour/audioengine.h"
46 #include "ardour/internal_send.h"
47 #include "ardour/internal_return.h"
48 #include "ardour/ladspa_plugin.h"
49 #include "ardour/meter.h"
50 #include "ardour/plugin_insert.h"
51 #include "ardour/port_insert.h"
52 #include "ardour/profile.h"
53 #include "ardour/return.h"
54 #include "ardour/route.h"
55 #include "ardour/send.h"
56 #include "ardour/session.h"
57 #include "ardour/dB.h"
60 #include "ardour_dialog.h"
61 #include "ardour_ui.h"
62 #include "gui_thread.h"
63 #include "io_selector.h"
66 #include "mixer_strip.h"
67 #include "plugin_selector.h"
68 #include "plugin_ui.h"
69 #include "port_insert_ui.h"
70 #include "processor_box.h"
71 #include "public_editor.h"
72 #include "return_ui.h"
73 #include "route_processor_selection.h"
79 #ifdef HAVE_AUDIOUNITS
84 using namespace ARDOUR;
88 using namespace Gtkmm2ext;
90 ProcessorBox* ProcessorBox::_current_processor_box = 0;
91 RefPtr<Action> ProcessorBox::paste_action;
92 RefPtr<Action> ProcessorBox::cut_action;
93 RefPtr<Action> ProcessorBox::rename_action;
94 RefPtr<Action> ProcessorBox::edit_action;
95 Glib::RefPtr<Gdk::Pixbuf> SendProcessorEntry::_slider;
97 ProcessorEntry::ProcessorEntry (boost::shared_ptr<Processor> p, Width w)
98 : _position (PreFader)
101 , _visual_state (Gtk::STATE_NORMAL)
103 _hbox.pack_start (_active, false, false);
104 _event_box.add (_name);
105 _hbox.pack_start (_event_box, true, true);
106 _vbox.pack_start (_hbox);
109 /* without this, the border is mis-drawn on some systems */
110 _vbox.set_border_width (1);
112 _name.set_alignment (0, 0.5);
113 _name.set_text (name ());
114 _name.set_padding (2, 2);
116 if (boost::dynamic_pointer_cast<Amp> (p)) {
117 /* Fader processor gets a special look */
118 _event_box.set_name ("ProcessorFader");
119 _frame.set_name ("ProcessorFaderFrame");
120 _name.set_padding (2, 4);
123 _active.set_active (_processor->active ());
124 _active.signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::active_toggled));
133 _processor->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_active_changed, this), gui_context());
134 _processor->PropertyChanged.connect (name_connection, invalidator (*this), ui_bind (&ProcessorEntry::processor_property_changed, this, _1), gui_context());
138 ProcessorEntry::action_widget ()
144 ProcessorEntry::widget ()
150 ProcessorEntry::drag_text () const
156 ProcessorEntry::set_visual_state (Gtk::StateType t)
163 ProcessorEntry::set_position (Position p)
170 ProcessorEntry::setup_visuals ()
174 _event_box.set_name ("ProcessorPreFader");
175 if (_visual_state == Gtk::STATE_NORMAL) {
176 _frame.set_name ("ProcessorPreFaderFrame");
181 _event_box.set_name ("ProcessorFader");
182 if (_visual_state == Gtk::STATE_NORMAL) {
183 _frame.set_name ("ProcessorFaderFrame");
188 _event_box.set_name ("ProcessorPostFader");
189 if (_visual_state == Gtk::STATE_NORMAL) {
190 _frame.set_name ("ProcessorPostFaderFrame");
195 switch (_visual_state) {
196 case Gtk::STATE_NORMAL:
197 /* _frame has been set up above */
198 _event_box.set_state (Gtk::STATE_NORMAL);
200 case Gtk::STATE_SELECTED:
201 _frame.set_name ("ProcessorFrameSelected");
202 /* don't change the background of the box when it is selected */
203 _event_box.set_state (Gtk::STATE_NORMAL);
205 case Gtk::STATE_ACTIVE:
206 _frame.set_name ("ProcessorFrameActiveSend");
207 _event_box.set_state (Gtk::STATE_ACTIVE);
215 boost::shared_ptr<Processor>
216 ProcessorEntry::processor () const
222 ProcessorEntry::set_enum_width (Width w)
228 ProcessorEntry::active_toggled ()
230 if (_active.get_active ()) {
231 if (!_processor->active ()) {
232 _processor->activate ();
235 if (_processor->active ()) {
236 _processor->deactivate ();
242 ProcessorEntry::processor_active_changed ()
244 if (_active.get_active () != _processor->active ()) {
245 _active.set_active (_processor->active ());
250 ProcessorEntry::processor_property_changed (const PropertyChange& what_changed)
252 if (what_changed.contains (ARDOUR::Properties::name)) {
253 _name.set_text (name ());
258 ProcessorEntry::name () const
260 boost::shared_ptr<Send> send;
263 if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
264 !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
268 /* grab the send name out of its overall name */
270 string::size_type lbracket, rbracket;
271 lbracket = send->name().find ('[');
272 rbracket = send->name().find (']');
276 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
279 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
287 name_display += _processor->display_name();
290 name_display += PBD::short_version (_processor->display_name(), 5);
299 SendProcessorEntry::SendProcessorEntry (boost::shared_ptr<Send> s, Width w)
300 : ProcessorEntry (s, w),
302 /* set the adjustment to a gain of 0dB so that the fader's default value is right */
303 _adjustment (0.781787, 0, 1, 0.01, 0.1),
304 _fader (_slider, &_adjustment, 0, false),
305 _ignore_gain_change (false)
307 _fader.set_name ("SendFader");
308 _fader.set_controllable (_send->amp()->gain_control ());
309 _vbox.pack_start (_fader);
313 _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &SendProcessorEntry::gain_adjusted));
314 _send->amp()->gain_control()->Changed.connect (send_gain_connection, invalidator (*this), boost::bind (&SendProcessorEntry::show_gain, this), gui_context());
319 SendProcessorEntry::setup_slider_pix ()
321 _slider = ::get_icon ("fader_belt_h_thin");
326 SendProcessorEntry::show_gain ()
328 ENSURE_GUI_THREAD (*this, &SendProcessorEntry::show_gain)
330 float const value = gain_to_slider_position (_send->amp()->gain ());
332 if (_adjustment.get_value() != value) {
333 _ignore_gain_change = true;
334 _adjustment.set_value (value);
335 _ignore_gain_change = false;
339 s.setf (ios::fixed, ios::floatfield);
340 s << accurate_coefficient_to_dB (_send->amp()->gain ()) << _("dB");
341 _fader.set_tooltip_text (s.str ());
346 SendProcessorEntry::gain_adjusted ()
348 if (_ignore_gain_change) {
352 _send->amp()->set_gain (slider_position_to_gain (_adjustment.get_value()), this);
356 SendProcessorEntry::set_pixel_width (int p)
358 _fader.set_fader_length (p);
361 PluginInsertProcessorEntry::PluginInsertProcessorEntry (boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
362 : ProcessorEntry (p, w)
365 p->SplittingChanged.connect (
366 _splitting_connection, invalidator (*this), ui_bind (&PluginInsertProcessorEntry::plugin_insert_splitting_changed, this), gui_context()
369 _splitting_icon.set_size_request (-1, 12);
371 _vbox.pack_start (_splitting_icon);
372 _vbox.reorder_child (_splitting_icon, 0);
374 plugin_insert_splitting_changed ();
378 PluginInsertProcessorEntry::plugin_insert_splitting_changed ()
380 if (_plugin_insert->splitting ()) {
381 _splitting_icon.show ();
383 _splitting_icon.hide ();
388 PluginInsertProcessorEntry::setup_visuals ()
392 _splitting_icon.set_name ("ProcessorPreFader");
396 _splitting_icon.set_name ("ProcessorFader");
400 _splitting_icon.set_name ("ProcessorPostFader");
404 ProcessorEntry::setup_visuals ();
408 PluginInsertProcessorEntry::SplittingIcon::on_expose_event (GdkEventExpose* ev)
410 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
412 cairo_set_line_width (cr, 1);
414 double const width = ev->area.width;
415 double const height = ev->area.height;
417 Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
418 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
420 cairo_rectangle (cr, 0, 0, width, height);
423 Gdk::Color const fg = get_style()->get_fg (STATE_NORMAL);
424 cairo_set_source_rgb (cr, fg.get_red_p (), fg.get_green_p (), fg.get_blue_p ());
426 cairo_move_to (cr, width * 0.3, height);
427 cairo_line_to (cr, width * 0.3, height * 0.5);
428 cairo_line_to (cr, width * 0.7, height * 0.5);
429 cairo_line_to (cr, width * 0.7, height);
430 cairo_move_to (cr, width * 0.5, height * 0.5);
431 cairo_line_to (cr, width * 0.5, 0);
437 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
438 RouteRedirectSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
439 : _parent_strip (parent)
440 , _owner_is_mixer (owner_is_mixer)
441 , ab_direction (true)
442 , _get_plugin_selector (get_plugin_selector)
443 , _placement(PreFader)
444 , _rr_selection(rsel)
450 send_action_menu = 0;
451 no_processor_redisplay = false;
453 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
454 processor_scroller.add (processor_display);
455 pack_start (processor_scroller, true, true);
457 processor_display.set_flags (CAN_FOCUS);
458 processor_display.set_name ("ProcessorList");
459 processor_display.set_size_request (48, -1);
460 processor_display.set_data ("processorbox", this);
461 processor_display.set_spacing (2);
463 processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
464 processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
466 processor_display.signal_key_press_event().connect (sigc::mem_fun(*this, &ProcessorBox::processor_key_press_event));
467 processor_display.signal_key_release_event().connect (sigc::mem_fun(*this, &ProcessorBox::processor_key_release_event));
469 processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
470 processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
472 processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
473 processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
474 processor_display.SelectionChanged.connect (sigc::mem_fun (*this, &ProcessorBox::selection_changed));
476 processor_scroller.show ();
477 processor_display.show ();
480 parent->DeliveryChanged.connect (
481 _mixer_strip_connections, invalidator (*this), ui_bind (&ProcessorBox::mixer_strip_delivery_changed, this, _1), gui_context ()
486 ProcessorBox::~ProcessorBox ()
491 ProcessorBox::set_route (boost::shared_ptr<Route> r)
497 _route_connections.drop_connections();
499 /* new route: any existing block on processor redisplay must be meaningless */
500 no_processor_redisplay = false;
503 _route->processors_changed.connect (
504 _route_connections, invalidator (*this), ui_bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()
507 _route->DropReferences.connect (
508 _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()
511 _route->PropertyChanged.connect (
512 _route_connections, invalidator (*this), ui_bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
515 redisplay_processors ();
519 ProcessorBox::route_going_away ()
521 /* don't keep updating display as processors are deleted */
522 no_processor_redisplay = true;
526 ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
528 boost::shared_ptr<Processor> p;
530 p = position->processor ();
533 list<ProcessorEntry*> children = source->selection ();
534 list<boost::shared_ptr<Processor> > procs;
535 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
536 procs.push_back ((*i)->processor ());
539 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
540 XMLNode& state = (*i)->get_state ();
542 nlist.push_back (&state);
543 paste_processor_state (nlist, p);
547 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
551 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
552 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
554 cerr << "source was another processor box, delete the selected items\n";
555 other->delete_dragged_processors (procs);
561 ProcessorBox::update()
563 redisplay_processors ();
567 ProcessorBox::set_width (Width w)
575 list<ProcessorEntry*> children = processor_display.children ();
576 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
577 (*i)->set_enum_width (w);
580 redisplay_processors ();
584 ProcessorBox::build_send_action_menu ()
586 using namespace Menu_Helpers;
588 send_action_menu = new Menu;
589 send_action_menu->set_name ("ArdourContextMenu");
590 MenuList& items = send_action_menu->items();
592 items.push_back (MenuElem (_("New send"), sigc::mem_fun(*this, &ProcessorBox::new_send)));
593 items.push_back (MenuElem (_("Show send controls"), sigc::mem_fun(*this, &ProcessorBox::show_send_controls)));
597 ProcessorBox::build_possible_aux_menu ()
599 boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
605 using namespace Menu_Helpers;
606 Menu* menu = manage (new Menu);
607 MenuList& items = menu->items();
609 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
610 if (!_route->internal_send_for (*r) && *r != _route) {
611 items.push_back (MenuElem ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
619 ProcessorBox::show_send_controls ()
624 ProcessorBox::new_send ()
629 ProcessorBox::show_processor_menu (gint arg)
631 if (processor_menu == 0) {
632 processor_menu = build_processor_menu ();
635 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/processormenu/newplugin"));
637 if (plugin_menu_item) {
638 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
641 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/processormenu/newaux"));
644 Menu* m = build_possible_aux_menu();
645 if (m && !m->items().empty()) {
646 aux_menu_item->set_submenu (*m);
647 aux_menu_item->set_sensitive (true);
649 /* stupid gtkmm: we need to pass a null reference here */
650 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
651 aux_menu_item->set_sensitive (false);
655 cut_action->set_sensitive (can_cut());
656 paste_action->set_sensitive (!_rr_selection.processors.empty());
658 processor_menu->popup (1, arg);
662 ProcessorBox::enter_notify (GdkEventCrossing*)
664 _current_processor_box = this;
665 Keyboard::magic_widget_grab_focus ();
666 processor_display.grab_focus ();
672 ProcessorBox::leave_notify (GdkEventCrossing* ev)
674 switch (ev->detail) {
675 case GDK_NOTIFY_INFERIOR:
678 Keyboard::magic_widget_drop_focus ();
685 ProcessorBox::processor_key_press_event (GdkEventKey *)
687 /* do real stuff on key release */
692 ProcessorBox::processor_key_release_event (GdkEventKey *ev)
695 ProcSelection targets;
697 get_selected_processors (targets);
699 if (targets.empty()) {
702 processor_display.get_pointer (x, y);
704 pair<ProcessorEntry *, double> const pointer = processor_display.get_child_at_position (y);
707 targets.push_back (pointer.first->processor ());
712 switch (ev->keyval) {
714 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
715 processor_display.select_all ();
721 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
722 copy_processors (targets);
728 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
729 cut_processors (targets);
735 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
736 if (targets.empty()) {
739 paste_processors (targets.front());
753 delete_processors (targets);
758 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
759 if ((*i)->active()) {
781 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
783 boost::shared_ptr<Processor> processor;
785 processor = child->processor ();
789 bool selected = processor_display.selected (child);
791 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
793 if (_session->engine().connected()) {
794 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
795 toggle_edit_processor (processor);
799 } else if (processor && ev->button == 1 && selected) {
801 // this is purely informational but necessary for route params UI
802 ProcessorSelected (processor); // emit
804 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
807 _get_plugin_selector()->show_manager ();
814 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
816 boost::shared_ptr<Processor> processor;
818 processor = child->processor ();
823 if (processor && Keyboard::is_delete_event (ev)) {
825 Glib::signal_idle().connect (sigc::bind (
826 sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
827 boost::weak_ptr<Processor>(processor)));
830 } else if (Keyboard::is_context_menu_event (ev)) {
832 /* figure out if we are above or below the fader/amp processor,
833 and set the next insert position appropriately.
837 if (_route->processor_is_prefader (processor)) {
838 _placement = PreFader;
840 _placement = PostFader;
843 _placement = PostFader;
846 show_processor_menu (ev->time);
849 } else if (processor && Keyboard::is_button2_event (ev)
851 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
855 /* button2-click with no/appropriate modifiers */
857 if (processor->active()) {
858 processor->deactivate ();
860 processor->activate ();
870 ProcessorBox::build_processor_menu ()
872 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/processormenu") );
873 processor_menu->set_name ("ArdourContextMenu");
874 return processor_menu;
878 ProcessorBox::selection_changed ()
880 bool const sensitive = (processor_display.selection().empty()) ? false : true;
881 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
882 edit_action->set_sensitive (one_processor_can_be_edited ());
884 /* disallow rename for multiple selections and for plugin inserts */
885 rename_action->set_sensitive (
886 processor_display.selection().size() == 1 && boost::dynamic_pointer_cast<PluginInsert> (processor_display.selection().front()->processor()) == 0
891 ProcessorBox::select_all_processors ()
893 processor_display.select_all ();
897 ProcessorBox::deselect_all_processors ()
899 processor_display.select_none ();
903 ProcessorBox::choose_plugin ()
905 _get_plugin_selector()->set_interested_object (*this);
908 /** @return true if an error occurred, otherwise false */
910 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
912 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
914 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
916 Route::ProcessorStreams err_streams;
918 if (Config->get_new_plugins_active()) {
919 processor->activate ();
922 if (_route->add_processor (processor, _placement, &err_streams)) {
923 weird_plugin_dialog (**p, err_streams);
925 // XXX SHAREDPTR delete plugin here .. do we even need to care?
928 if (Profile->get_sae()) {
929 processor->activate ();
938 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
940 ArdourDialog dialog (_("Plugin Incompatibility"));
943 string text = string_compose(_("You attempted to add the plugin \"%1\" at index %2.\n"),
944 p.name(), streams.index);
946 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
947 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
949 text += _("\nThis plugin has:\n");
951 uint32_t const n = p.get_info()->n_inputs.n_midi ();
952 text += string_compose (ngettext ("\t%1 MIDI input", "\t%1 MIDI inputs", n), n);
955 uint32_t const n = p.get_info()->n_inputs.n_audio ();
956 text += string_compose (ngettext ("\t%1 audio input", "\t%1 audio inputs", n), n);
959 text += _("\nBut at the insertion point, there are:\n");
961 uint32_t const n = streams.count.n_midi ();
962 text += string_compose (ngettext ("\t%1 MIDI channel\n", "\t%1 MIDI channels\n", n), n);
965 uint32_t const n = streams.count.n_audio ();
966 text += string_compose (ngettext ("\t%1 audio channel\n", "\t%1 audio channels\n", n), n);
969 text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME);
970 label.set_text(text);
972 dialog.get_vbox()->pack_start (label);
973 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
975 dialog.set_name (X_("PluginIODialog"));
976 dialog.set_position (Gtk::WIN_POS_MOUSE);
977 dialog.set_modal (true);
984 ProcessorBox::choose_insert ()
986 boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->pannable(), _route->mute_master()));
987 _route->add_processor (processor, _placement);
990 /* Caller must not hold process lock */
992 ProcessorBox::choose_send ()
994 boost::shared_ptr<Send> send (new Send (*_session, _route->pannable(), _route->mute_master()));
996 /* make an educated guess at the initial number of outputs for the send */
997 ChanCount outs = (_session->master_out())
998 ? _session->master_out()->n_outputs()
999 : _route->n_outputs();
1001 /* XXX need processor lock on route */
1003 Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock());
1004 send->output()->ensure_io (outs, false, this);
1005 } catch (AudioEngine::PortRegistrationFailure& err) {
1006 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
1010 /* let the user adjust the IO setup before creation.
1012 Note: this dialog is NOT modal - we just leave it to run and it will
1013 return when its Finished signal is emitted - typically when the window
1017 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
1020 /* keep a reference to the send so it doesn't get deleted while
1021 the IOSelectorWindow is doing its stuff
1023 _processor_being_created = send;
1025 ios->selector().Finished.connect (sigc::bind (
1026 sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
1027 boost::weak_ptr<Processor>(send), ios));
1032 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1034 boost::shared_ptr<Processor> processor (weak_processor.lock());
1036 /* drop our temporary reference to the new send */
1037 _processor_being_created.reset ();
1044 case IOSelector::Cancelled:
1045 // processor will go away when all shared_ptrs to it vanish
1048 case IOSelector::Accepted:
1049 _route->add_processor (processor, _placement);
1050 if (Profile->get_sae()) {
1051 processor->activate ();
1056 delete_when_idle (ios);
1060 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
1062 boost::shared_ptr<Processor> processor (weak_processor.lock());
1064 /* drop our temporary reference to the new return */
1065 _processor_being_created.reset ();
1072 case IOSelector::Cancelled:
1073 // processor will go away when all shared_ptrs to it vanish
1076 case IOSelector::Accepted:
1077 _route->add_processor (processor, _placement);
1078 if (Profile->get_sae()) {
1079 processor->activate ();
1084 delete_when_idle (ios);
1088 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
1094 boost::shared_ptr<Route> target = wr.lock();
1100 boost::shared_ptr<RouteList> rlist (new RouteList);
1101 rlist->push_back (_route);
1103 _session->add_internal_sends (target, PreFader, rlist);
1107 ProcessorBox::route_processors_changed (RouteProcessorChange c)
1109 if (c.type == RouteProcessorChange::MeterPointChange && c.meter_visibly_changed == false) {
1110 /* the meter has moved, but it was and still is invisible to the user, so nothing to do */
1114 redisplay_processors ();
1118 ProcessorBox::redisplay_processors ()
1120 ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors)
1122 if (no_processor_redisplay) {
1126 processor_display.clear ();
1128 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
1130 for (list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin(); i != _processor_window_proxies.end(); ++i) {
1131 (*i)->marked = false;
1134 _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
1136 /* trim dead wood from the processor window proxy list */
1138 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin();
1139 while (i != _processor_window_proxies.end()) {
1140 list<ProcessorWindowProxy*>::iterator j = i;
1143 if (!(*i)->marked) {
1144 ARDOUR_UI::instance()->remove_window_proxy (*i);
1146 _processor_window_proxies.erase (i);
1152 setup_entry_positions ();
1155 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
1156 * not already have one.
1159 ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
1161 boost::shared_ptr<Processor> p = w.lock ();
1166 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin ();
1167 while (i != _processor_window_proxies.end()) {
1169 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
1172 /* this processor is already on the list; done */
1173 (*i)->marked = true;
1180 /* not on the list; add it */
1183 if (_parent_strip) {
1184 if (_parent_strip->mixer_owned()) {
1193 ProcessorWindowProxy* wp = new ProcessorWindowProxy (
1194 string_compose ("%1-%2-%3", loc, _route->id(), p->id()),
1195 _session->extra_xml (X_("UI")),
1201 /* if the processor already has an existing UI,
1202 note that so that we don't recreate it
1205 void* existing_ui = p->get_ui ();
1208 wp->set (static_cast<Gtk::Window*>(existing_ui));
1211 _processor_window_proxies.push_back (wp);
1212 ARDOUR_UI::instance()->add_window_proxy (wp);
1216 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
1218 boost::shared_ptr<Processor> processor (p.lock ());
1220 if (!processor || !processor->display_to_user()) {
1224 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
1225 boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
1226 ProcessorEntry* e = 0;
1228 e = new SendProcessorEntry (send, _width);
1229 } else if (plugin_insert) {
1230 e = new PluginInsertProcessorEntry (plugin_insert, _width);
1232 e = new ProcessorEntry (processor, _width);
1235 e->set_pixel_width (get_allocation().get_width());
1236 processor_display.add_child (e);
1241 ProcessorBox::build_processor_tooltip (EventBox& box, string start)
1245 list<ProcessorEntry*> children = processor_display.children ();
1246 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1248 tip += (*i)->processor()->name();
1251 ARDOUR_UI::instance()->set_tip (box, tip);
1255 ProcessorBox::reordered ()
1257 compute_processor_sort_keys ();
1258 setup_entry_positions ();
1262 ProcessorBox::setup_entry_positions ()
1264 list<ProcessorEntry*> children = processor_display.children ();
1265 bool pre_fader = true;
1267 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
1268 if (boost::dynamic_pointer_cast<Amp>((*i)->processor())) {
1270 (*i)->set_position (ProcessorEntry::Fader);
1273 (*i)->set_position (ProcessorEntry::PreFader);
1275 (*i)->set_position (ProcessorEntry::PostFader);
1282 ProcessorBox::compute_processor_sort_keys ()
1284 list<ProcessorEntry*> children = processor_display.children ();
1285 Route::ProcessorList our_processors;
1287 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
1288 our_processors.push_back ((*iter)->processor ());
1291 if (_route->reorder_processors (our_processors)) {
1292 /* Reorder failed, so report this to the user. As far as I can see this must be done
1293 in an idle handler: it seems that the redisplay_processors() that happens below destroys
1294 widgets that were involved in the drag-and-drop on the processor list, which causes problems
1295 when the drag is torn down after this handler function is finished.
1297 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::report_failed_reorder));
1302 ProcessorBox::report_failed_reorder ()
1304 /* reorder failed, so redisplay */
1306 redisplay_processors ();
1308 /* now tell them about the problem */
1310 ArdourDialog dialog (_("Plugin Incompatibility"));
1313 label.set_text (_("\
1314 You cannot reorder these plugins/sends/inserts\n\
1315 in that way because the inputs and\n\
1316 outputs will not work correctly."));
1318 dialog.get_vbox()->set_border_width (12);
1319 dialog.get_vbox()->pack_start (label);
1320 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1322 dialog.set_name (X_("PluginIODialog"));
1323 dialog.set_position (Gtk::WIN_POS_MOUSE);
1324 dialog.set_modal (true);
1331 ProcessorBox::rename_processors ()
1333 ProcSelection to_be_renamed;
1335 get_selected_processors (to_be_renamed);
1337 if (to_be_renamed.empty()) {
1341 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
1342 rename_processor (*i);
1347 ProcessorBox::can_cut () const
1349 vector<boost::shared_ptr<Processor> > sel;
1351 get_selected_processors (sel);
1353 /* cut_processors () does not cut inserts */
1355 for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
1357 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1358 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1359 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1368 ProcessorBox::cut_processors ()
1370 ProcSelection to_be_removed;
1372 get_selected_processors (to_be_removed);
1376 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
1378 if (to_be_removed.empty()) {
1382 XMLNode* node = new XMLNode (X_("cut"));
1383 Route::ProcessorList to_cut;
1385 no_processor_redisplay = true;
1386 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
1387 // Cut only plugins, sends and returns
1388 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1389 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1390 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1392 Window* w = get_processor_ui (*i);
1398 XMLNode& child ((*i)->get_state());
1399 node->add_child_nocopy (child);
1400 to_cut.push_back (*i);
1404 if (_route->remove_processors (to_cut) != 0) {
1406 no_processor_redisplay = false;
1410 _rr_selection.set (node);
1412 no_processor_redisplay = false;
1413 redisplay_processors ();
1417 ProcessorBox::copy_processors ()
1419 ProcSelection to_be_copied;
1420 get_selected_processors (to_be_copied);
1421 copy_processors (to_be_copied);
1425 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
1427 if (to_be_copied.empty()) {
1431 XMLNode* node = new XMLNode (X_("copy"));
1433 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
1434 // Copy only plugins, sends, returns
1435 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1436 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1437 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1438 node->add_child_nocopy ((*i)->get_state());
1442 _rr_selection.set (node);
1446 ProcessorBox::delete_processors ()
1448 ProcSelection to_be_deleted;
1449 get_selected_processors (to_be_deleted);
1450 delete_processors (to_be_deleted);
1454 ProcessorBox::delete_processors (const ProcSelection& targets)
1456 if (targets.empty()) {
1460 no_processor_redisplay = true;
1462 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
1464 Window* w = get_processor_ui (*i);
1470 _route->remove_processor(*i);
1473 no_processor_redisplay = false;
1474 redisplay_processors ();
1478 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
1480 list<boost::shared_ptr<Processor> >::const_iterator x;
1482 no_processor_redisplay = true;
1483 for (x = procs.begin(); x != procs.end(); ++x) {
1485 Window* w = get_processor_ui (*x);
1491 _route->remove_processor(*x);
1494 no_processor_redisplay = false;
1495 redisplay_processors ();
1499 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
1501 boost::shared_ptr<Processor> processor (weak_processor.lock());
1507 /* NOT copied to _mixer.selection() */
1509 no_processor_redisplay = true;
1510 _route->remove_processor (processor);
1511 no_processor_redisplay = false;
1512 redisplay_processors ();
1518 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
1520 ArdourPrompter name_prompter (true);
1522 name_prompter.set_title (_("Rename Processor"));
1523 name_prompter.set_prompt (_("New name:"));
1524 name_prompter.set_initial_text (processor->name());
1525 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
1526 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
1527 name_prompter.show_all ();
1529 switch (name_prompter.run ()) {
1531 case Gtk::RESPONSE_ACCEPT:
1532 name_prompter.get_result (result);
1533 if (result.length()) {
1536 string test = result;
1538 while (tries < 100) {
1539 if (_session->io_name_is_legal (test)) {
1545 test = string_compose ("%1-%2", result, tries);
1549 processor->set_name (result);
1552 ARDOUR_UI::instance()->popup_error
1553 (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
1563 ProcessorBox::paste_processors ()
1565 if (_rr_selection.processors.empty()) {
1569 paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
1573 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
1576 if (_rr_selection.processors.empty()) {
1580 paste_processor_state (_rr_selection.processors.get_node().children(), before);
1584 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
1586 XMLNodeConstIterator niter;
1587 list<boost::shared_ptr<Processor> > copies;
1589 if (nlist.empty()) {
1593 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1595 XMLProperty const * type = (*niter)->property ("type");
1598 boost::shared_ptr<Processor> p;
1600 if (type->value() == "meter" ||
1601 type->value() == "main-outs" ||
1602 type->value() == "amp" ||
1603 type->value() == "intsend" || type->value() == "intreturn") {
1604 /* do not paste meter, main outs, amp or internal send/returns */
1607 } else if (type->value() == "send") {
1609 XMLNode n (**niter);
1610 Send::make_unique (n, *_session);
1611 Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
1612 if (s->set_state (n, Stateful::loading_state_version)) {
1620 } else if (type->value() == "return") {
1622 XMLNode n (**niter);
1623 Return::make_unique (n, *_session);
1624 Return* r = new Return (*_session);
1626 if (r->set_state (n, Stateful::loading_state_version)) {
1634 /* XXX its a bit limiting to assume that everything else
1638 p.reset (new PluginInsert (*_session));
1639 p->set_state (**niter, Stateful::current_state_version);
1642 copies.push_back (p);
1646 cerr << "plugin insert constructor failed\n";
1650 if (copies.empty()) {
1654 if (_route->add_processors (copies, p)) {
1657 "Copying the set of processors on the clipboard failed,\n\
1658 probably because the I/O configuration of the plugins\n\
1659 could not match the configuration of this track.");
1660 MessageDialog am (msg);
1666 ProcessorBox::activate_processor (boost::shared_ptr<Processor> r)
1672 ProcessorBox::deactivate_processor (boost::shared_ptr<Processor> r)
1678 ProcessorBox::get_selected_processors (ProcSelection& processors) const
1680 const list<ProcessorEntry*> selection = processor_display.selection ();
1681 for (list<ProcessorEntry*>::const_iterator i = selection.begin(); i != selection.end(); ++i) {
1682 processors.push_back ((*i)->processor ());
1687 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
1689 list<ProcessorEntry*> selection = processor_display.selection ();
1690 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
1691 (this->*method) ((*i)->processor ());
1696 ProcessorBox::all_processors_active (bool state)
1698 _route->all_processors_active (_placement, state);
1702 ProcessorBox::ab_plugins ()
1704 _route->ab_plugins (ab_direction);
1705 ab_direction = !ab_direction;
1710 ProcessorBox::clear_processors ()
1713 vector<string> choices;
1715 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
1716 "(this cannot be undone)"), _route->name());
1718 choices.push_back (_("Cancel"));
1719 choices.push_back (_("Yes, remove them all"));
1721 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1723 if (prompter.run () == 1) {
1724 _route->clear_processors (PreFader);
1725 _route->clear_processors (PostFader);
1730 ProcessorBox::clear_processors (Placement p)
1733 vector<string> choices;
1735 if (p == PreFader) {
1736 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
1737 "(this cannot be undone)"), _route->name());
1739 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
1740 "(this cannot be undone)"), _route->name());
1743 choices.push_back (_("Cancel"));
1744 choices.push_back (_("Yes, remove them all"));
1746 Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
1748 if (prompter.run () == 1) {
1749 _route->clear_processors (p);
1754 ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
1756 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
1757 if (at && at->freeze_state() == AudioTrack::Frozen) {
1762 boost::dynamic_pointer_cast<Send> (processor) ||
1763 boost::dynamic_pointer_cast<Return> (processor) ||
1764 boost::dynamic_pointer_cast<PluginInsert> (processor) ||
1765 boost::dynamic_pointer_cast<PortInsert> (processor)
1774 ProcessorBox::one_processor_can_be_edited ()
1776 list<ProcessorEntry*> selection = processor_display.selection ();
1777 list<ProcessorEntry*>::iterator i = selection.begin();
1778 while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
1782 return (i != selection.end());
1786 ProcessorBox::toggle_edit_processor (boost::shared_ptr<Processor> processor)
1788 boost::shared_ptr<Send> send;
1789 boost::shared_ptr<InternalSend> internal_send;
1790 boost::shared_ptr<Return> retrn;
1791 boost::shared_ptr<PluginInsert> plugin_insert;
1792 boost::shared_ptr<PortInsert> port_insert;
1795 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
1797 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
1802 if (boost::dynamic_pointer_cast<Amp> (processor)) {
1804 _parent_strip->revert_to_default_display ();
1806 } else if ((internal_send = boost::dynamic_pointer_cast<InternalSend> (processor)) != 0) {
1808 if (!_session->engine().connected()) {
1812 if (_parent_strip) {
1813 if (boost::dynamic_pointer_cast<Send> (_parent_strip->current_delivery()) == internal_send) {
1814 _parent_strip->revert_to_default_display ();
1816 _parent_strip->show_send (internal_send);
1820 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
1822 if (!_session->engine().connected()) {
1826 SendUIWindow* w = new SendUIWindow (send, _session);
1829 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
1831 if (boost::dynamic_pointer_cast<InternalReturn> (retrn)) {
1832 /* no GUI for these */
1836 if (!_session->engine().connected()) {
1840 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
1842 ReturnUIWindow *return_ui;
1843 Window* w = get_processor_ui (retrn);
1847 return_ui = new ReturnUIWindow (retrn, _session);
1848 return_ui->set_title (retrn->name ());
1849 set_processor_ui (send, return_ui);
1852 return_ui = dynamic_cast<ReturnUIWindow *> (w);
1857 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
1859 PluginUIWindow *plugin_ui;
1861 /* these are both allowed to be null */
1863 Container* toplevel = get_toplevel();
1864 Window* win = dynamic_cast<Gtk::Window*>(toplevel);
1866 Window* w = get_processor_ui (plugin_insert);
1870 plugin_ui = new PluginUIWindow (win, plugin_insert);
1871 plugin_ui->set_title (generate_processor_title (plugin_insert));
1872 set_processor_ui (plugin_insert, plugin_ui);
1875 plugin_ui = dynamic_cast<PluginUIWindow *> (w);
1876 plugin_ui->set_parent (win);
1881 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
1883 if (!_session->engine().connected()) {
1884 MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible"));
1889 PortInsertWindow *io_selector;
1891 Window* w = get_processor_ui (port_insert);
1894 io_selector = new PortInsertWindow (_session, port_insert);
1895 set_processor_ui (port_insert, io_selector);
1898 io_selector = dynamic_cast<PortInsertWindow *> (w);
1901 gidget = io_selector;
1905 if (gidget->is_visible()) {
1908 gidget->show_all ();
1915 ProcessorBox::register_actions ()
1917 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("processormenu"));
1918 Glib::RefPtr<Action> act;
1921 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin"),
1922 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
1924 act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"),
1925 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
1926 ActionManager::jack_sensitive_actions.push_back (act);
1927 act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New Send ..."),
1928 sigc::ptr_fun (ProcessorBox::rb_choose_send));
1929 ActionManager::jack_sensitive_actions.push_back (act);
1931 ActionManager::register_action (popup_act_grp, X_("newaux"), _("New Aux Send ..."));
1933 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear (all)"),
1934 sigc::ptr_fun (ProcessorBox::rb_clear));
1935 ActionManager::register_action (popup_act_grp, X_("clear_pre"), _("Clear (pre-fader)"),
1936 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
1937 ActionManager::register_action (popup_act_grp, X_("clear_post"), _("Clear (post-fader)"),
1938 sigc::ptr_fun (ProcessorBox::rb_clear_post));
1940 /* standard editing stuff */
1941 cut_action = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"),
1942 sigc::ptr_fun (ProcessorBox::rb_cut));
1943 ActionManager::plugin_selection_sensitive_actions.push_back(cut_action);
1944 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),
1945 sigc::ptr_fun (ProcessorBox::rb_copy));
1946 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1948 act = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"),
1949 sigc::ptr_fun (ProcessorBox::rb_delete));
1950 ActionManager::plugin_selection_sensitive_actions.push_back(act); // ??
1952 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"),
1953 sigc::ptr_fun (ProcessorBox::rb_paste));
1954 rename_action = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"),
1955 sigc::ptr_fun (ProcessorBox::rb_rename));
1956 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"),
1957 sigc::ptr_fun (ProcessorBox::rb_select_all));
1958 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"),
1959 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
1961 /* activation etc. */
1963 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate all"),
1964 sigc::ptr_fun (ProcessorBox::rb_activate_all));
1965 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate all"),
1966 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
1967 ActionManager::register_action (popup_act_grp, X_("ab_plugins"), _("A/B Plugins"),
1968 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
1971 edit_action = ActionManager::register_action (popup_act_grp, X_("edit"), _("Edit..."),
1972 sigc::ptr_fun (ProcessorBox::rb_edit));
1974 ActionManager::add_action_group (popup_act_grp);
1978 ProcessorBox::rb_ab_plugins ()
1980 if (_current_processor_box == 0) {
1984 _current_processor_box->ab_plugins ();
1988 ProcessorBox::rb_choose_plugin ()
1990 if (_current_processor_box == 0) {
1993 _current_processor_box->choose_plugin ();
1997 ProcessorBox::rb_choose_insert ()
1999 if (_current_processor_box == 0) {
2002 _current_processor_box->choose_insert ();
2006 ProcessorBox::rb_choose_send ()
2008 if (_current_processor_box == 0) {
2011 _current_processor_box->choose_send ();
2015 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
2017 if (_current_processor_box == 0) {
2021 _current_processor_box->choose_aux (wr);
2025 ProcessorBox::rb_clear ()
2027 if (_current_processor_box == 0) {
2031 _current_processor_box->clear_processors ();
2036 ProcessorBox::rb_clear_pre ()
2038 if (_current_processor_box == 0) {
2042 _current_processor_box->clear_processors (PreFader);
2047 ProcessorBox::rb_clear_post ()
2049 if (_current_processor_box == 0) {
2053 _current_processor_box->clear_processors (PostFader);
2057 ProcessorBox::rb_cut ()
2059 if (_current_processor_box == 0) {
2063 _current_processor_box->cut_processors ();
2067 ProcessorBox::rb_delete ()
2069 if (_current_processor_box == 0) {
2073 _current_processor_box->delete_processors ();
2077 ProcessorBox::rb_copy ()
2079 if (_current_processor_box == 0) {
2082 _current_processor_box->copy_processors ();
2086 ProcessorBox::rb_paste ()
2088 if (_current_processor_box == 0) {
2092 _current_processor_box->paste_processors ();
2096 ProcessorBox::rb_rename ()
2098 if (_current_processor_box == 0) {
2101 _current_processor_box->rename_processors ();
2105 ProcessorBox::rb_select_all ()
2107 if (_current_processor_box == 0) {
2111 _current_processor_box->select_all_processors ();
2115 ProcessorBox::rb_deselect_all ()
2117 if (_current_processor_box == 0) {
2121 _current_processor_box->deselect_all_processors ();
2125 ProcessorBox::rb_activate_all ()
2127 if (_current_processor_box == 0) {
2131 _current_processor_box->all_processors_active (true);
2135 ProcessorBox::rb_deactivate_all ()
2137 if (_current_processor_box == 0) {
2140 _current_processor_box->all_processors_active (false);
2144 ProcessorBox::rb_edit ()
2146 if (_current_processor_box == 0) {
2150 _current_processor_box->for_selected_processors (&ProcessorBox::toggle_edit_processor);
2154 ProcessorBox::route_property_changed (const PropertyChange& what_changed)
2156 if (!what_changed.contains (ARDOUR::Properties::name)) {
2160 ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
2162 boost::shared_ptr<Processor> processor;
2163 boost::shared_ptr<PluginInsert> plugin_insert;
2164 boost::shared_ptr<Send> send;
2166 list<ProcessorEntry*> children = processor_display.children();
2168 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
2170 processor = (*iter)->processor ();
2172 Window* w = get_processor_ui (processor);
2178 /* rename editor windows for sends and plugins */
2180 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
2181 w->set_title (send->name ());
2182 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
2183 w->set_title (generate_processor_title (plugin_insert));
2189 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
2191 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
2192 string::size_type email_pos;
2194 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
2195 maker = maker.substr (0, email_pos - 1);
2198 if (maker.length() > 32) {
2199 maker = maker.substr (0, 32);
2203 return string_compose(_("%1: %2 (by %3)"), _route->name(), pi->name(), maker);
2207 ProcessorBox::on_size_allocate (Allocation& a)
2209 HBox::on_size_allocate (a);
2211 list<ProcessorEntry*> children = processor_display.children ();
2212 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
2213 (*i)->set_pixel_width (a.get_width ());
2217 /** @param p Processor.
2218 * @return the UI window for \a p.
2221 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
2223 list<ProcessorWindowProxy*>::const_iterator i = _processor_window_proxies.begin ();
2224 while (i != _processor_window_proxies.end()) {
2225 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2227 return (*i)->get ();
2233 /* we shouldn't get here, because the ProcessorUIList should always contain
2234 an entry for each processor.
2240 /** Make a note of the UI window that a processor is using.
2241 * @param p Processor.
2242 * @param w UI window.
2245 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
2247 list<ProcessorWindowProxy*>::iterator i = _processor_window_proxies.begin ();
2251 while (i != _processor_window_proxies.end()) {
2252 boost::shared_ptr<Processor> t = (*i)->processor().lock ();
2261 /* we shouldn't get here, because the ProcessorUIList should always contain
2262 an entry for each processor.
2268 ProcessorBox::mixer_strip_delivery_changed (boost::weak_ptr<Delivery> w)
2270 boost::shared_ptr<Delivery> d = w.lock ();
2275 list<ProcessorEntry*> children = processor_display.children ();
2276 list<ProcessorEntry*>::const_iterator i = children.begin();
2277 while (i != children.end() && (*i)->processor() != d) {
2281 if (i == children.end()) {
2282 processor_display.set_active (0);
2284 processor_display.set_active (*i);
2288 ProcessorWindowProxy::ProcessorWindowProxy (
2289 string const & name,
2290 XMLNode const * node,
2292 boost::weak_ptr<Processor> processor
2294 : WindowProxy<Gtk::Window> (name, node)
2296 , _processor_box (box)
2297 , _processor (processor)
2304 ProcessorWindowProxy::show ()
2306 boost::shared_ptr<Processor> p = _processor.lock ();
2311 _processor_box->toggle_edit_processor (p);