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/stop_signal.h>
41 #include <gtkmm2ext/doi.h>
43 #include "ardour/amp.h"
44 #include "ardour/ardour.h"
45 #include "ardour/audio_diskstream.h"
46 #include "ardour/audio_track.h"
47 #include "ardour/audioengine.h"
48 #include "ardour/internal_send.h"
49 #include "ardour/ladspa_plugin.h"
50 #include "ardour/meter.h"
51 #include "ardour/plugin_insert.h"
52 #include "ardour/port_insert.h"
53 #include "ardour/profile.h"
54 #include "ardour/return.h"
55 #include "ardour/route.h"
56 #include "ardour/send.h"
57 #include "ardour/session.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 "processor_box.h"
70 #include "public_editor.h"
71 #include "return_ui.h"
72 #include "route_processor_selection.h"
78 #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 Glib::RefPtr<Gdk::Pixbuf> SendProcessorEntry::_slider;
94 ProcessorEntry::ProcessorEntry (boost::shared_ptr<Processor> p, Width w)
98 _hbox.pack_start (_active, false, false);
99 _event_box.add (_name);
100 _hbox.pack_start (_event_box, true, true);
101 _vbox.pack_start (_hbox);
103 _name.set_alignment (0, 0.5);
104 _name.set_text (name ());
105 _name.set_padding (2, 2);
107 _active.set_active (_processor->active ());
108 _active.signal_toggled().connect (mem_fun (*this, &ProcessorEntry::active_toggled));
110 _processor->ActiveChanged.connect (mem_fun (*this, &ProcessorEntry::processor_active_changed));
111 _processor->NameChanged.connect (mem_fun (*this, &ProcessorEntry::processor_name_changed));
115 ProcessorEntry::action_widget ()
121 ProcessorEntry::widget ()
127 ProcessorEntry::drag_text () const
132 boost::shared_ptr<Processor>
133 ProcessorEntry::processor () const
139 ProcessorEntry::set_width (Width w)
145 ProcessorEntry::active_toggled ()
147 if (_active.get_active ()) {
148 if (!_processor->active ()) {
149 _processor->activate ();
152 if (_processor->active ()) {
153 _processor->deactivate ();
159 ProcessorEntry::processor_active_changed ()
161 if (_active.get_active () != _processor->active ()) {
162 _active.set_active (_processor->active ());
167 ProcessorEntry::processor_name_changed ()
169 _name.set_text (name ());
173 ProcessorEntry::name () const
175 boost::shared_ptr<Send> send;
178 if (!_processor->active()) {
182 if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
183 !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
187 /* grab the send name out of its overall name */
189 string::size_type lbracket, rbracket;
190 lbracket = send->name().find ('[');
191 rbracket = send->name().find (']');
195 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
198 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
206 name_display += _processor->display_name();
209 name_display += PBD::short_version (_processor->display_name(), 5);
215 if (!_processor->active()) {
222 SendProcessorEntry::SendProcessorEntry (boost::shared_ptr<Send> s, Width w)
223 : ProcessorEntry (s, w),
225 _adjustment (0, 0, 1, 0.01, 0.1),
226 _fader (_slider, &_adjustment, false),
227 _ignore_gain_change (false)
229 _fader.set_controllable (_send->amp()->gain_control ());
230 _vbox.pack_start (_fader);
232 _adjustment.signal_value_changed().connect (mem_fun (*this, &SendProcessorEntry::gain_adjusted));
233 _send->amp()->gain_control()->Changed.connect (mem_fun (*this, &SendProcessorEntry::show_gain));
238 SendProcessorEntry::setup_slider_pix ()
240 _slider = ::get_icon ("fader_belt_h_thin");
245 SendProcessorEntry::show_gain ()
247 ENSURE_GUI_THREAD (mem_fun (*this, &SendProcessorEntry::show_gain));
249 float const value = gain_to_slider_position (_send->amp()->gain ());
251 if (_adjustment.get_value() != value) {
252 _ignore_gain_change = true;
253 _adjustment.set_value (value);
254 _ignore_gain_change = false;
259 SendProcessorEntry::gain_adjusted ()
261 if (_ignore_gain_change) {
265 _send->amp()->set_gain (slider_position_to_gain (_adjustment.get_value()), this);
270 ProcessorBox::ProcessorBox (ARDOUR::Session& sess, sigc::slot<PluginSelector*> get_plugin_selector,
271 RouteRedirectSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
273 , _parent_strip (parent)
274 , _owner_is_mixer (owner_is_mixer)
275 , ab_direction (true)
276 , _get_plugin_selector (get_plugin_selector)
277 , _placement(PreFader)
278 , _rr_selection(rsel)
282 send_action_menu = 0;
283 no_processor_redisplay = false;
285 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
286 processor_scroller.add (processor_display);
287 pack_start (processor_scroller, true, true);
289 processor_display.set_flags (CAN_FOCUS);
290 processor_display.set_name ("ProcessorSelector");
291 processor_display.set_size_request (48, -1);
292 processor_display.set_data ("processorbox", this);
294 processor_display.signal_enter_notify_event().connect (mem_fun(*this, &ProcessorBox::enter_notify), false);
295 processor_display.signal_leave_notify_event().connect (mem_fun(*this, &ProcessorBox::leave_notify), false);
297 processor_display.signal_key_press_event().connect (mem_fun(*this, &ProcessorBox::processor_key_press_event));
298 processor_display.signal_key_release_event().connect (mem_fun(*this, &ProcessorBox::processor_key_release_event));
300 processor_display.ButtonPress.connect (mem_fun (*this, &ProcessorBox::processor_button_press_event));
301 processor_display.ButtonRelease.connect (mem_fun (*this, &ProcessorBox::processor_button_release_event));
303 processor_display.Reordered.connect (mem_fun (*this, &ProcessorBox::reordered));
304 processor_display.DropFromAnotherBox.connect (mem_fun (*this, &ProcessorBox::object_drop));
305 processor_display.SelectionChanged.connect (mem_fun (*this, &ProcessorBox::selection_changed));
308 ProcessorBox::~ProcessorBox ()
313 ProcessorBox::set_route (boost::shared_ptr<Route> r)
315 connections.clear ();
317 /* new route: any existing block on processor redisplay must be meaningless */
318 no_processor_redisplay = false;
321 connections.push_back (_route->processors_changed.connect (
322 mem_fun(*this, &ProcessorBox::redisplay_processors)));
323 connections.push_back (_route->GoingAway.connect (
324 mem_fun (*this, &ProcessorBox::route_going_away)));
325 connections.push_back (_route->NameChanged.connect (
326 mem_fun(*this, &ProcessorBox::route_name_changed)));
328 redisplay_processors ();
332 ProcessorBox::route_going_away ()
334 /* don't keep updating display as processors are deleted */
335 no_processor_redisplay = true;
339 ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
341 boost::shared_ptr<Processor> p;
343 p = position->processor ();
346 list<ProcessorEntry*> children = source->selection ();
347 list<boost::shared_ptr<Processor> > procs;
348 for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
349 procs.push_back ((*i)->processor ());
352 for (list<boost::shared_ptr<Processor> >::const_iterator i = procs.begin(); i != procs.end(); ++i) {
353 XMLNode& state = (*i)->get_state ();
355 nlist.push_back (&state);
356 paste_processor_state (nlist, p);
360 /* since the dndvbox doesn't take care of this properly, we have to delete the originals
364 if ((context->get_suggested_action() == Gdk::ACTION_MOVE) && source) {
365 ProcessorBox* other = reinterpret_cast<ProcessorBox*> (source->get_data ("processorbox"));
367 cerr << "source was another processor box, delete the selected items\n";
368 other->delete_dragged_processors (procs);
374 ProcessorBox::update()
376 redisplay_processors ();
380 ProcessorBox::set_width (Width w)
388 list<ProcessorEntry*> children = processor_display.children ();
389 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
393 redisplay_processors ();
397 ProcessorBox::remove_processor_gui (boost::shared_ptr<Processor> processor)
399 boost::shared_ptr<Send> send;
400 boost::shared_ptr<Return> retrn;
401 boost::shared_ptr<PortInsert> port_insert;
403 if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
404 PortInsertUI *io_selector = reinterpret_cast<PortInsertUI *> (port_insert->get_gui());
405 port_insert->set_gui (0);
407 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
408 SendUIWindow *sui = reinterpret_cast<SendUIWindow*> (send->get_gui());
411 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
412 ReturnUIWindow *rui = reinterpret_cast<ReturnUIWindow*> (retrn->get_gui());
419 ProcessorBox::build_send_action_menu ()
421 using namespace Menu_Helpers;
423 send_action_menu = new Menu;
424 send_action_menu->set_name ("ArdourContextMenu");
425 MenuList& items = send_action_menu->items();
427 items.push_back (MenuElem (_("New send"), mem_fun(*this, &ProcessorBox::new_send)));
428 items.push_back (MenuElem (_("Show send controls"), mem_fun(*this, &ProcessorBox::show_send_controls)));
432 ProcessorBox::build_possible_aux_menu ()
434 boost::shared_ptr<RouteList> rl = _session.get_routes_with_internal_returns();
440 using namespace Menu_Helpers;
441 Menu* menu = manage (new Menu);
442 MenuList& items = menu->items();
444 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
445 if (!_route->internal_send_for (*r) && *r != _route) {
446 items.push_back (MenuElem ((*r)->name(), bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
454 ProcessorBox::show_send_controls ()
459 ProcessorBox::new_send ()
464 ProcessorBox::show_processor_menu (gint arg)
466 if (processor_menu == 0) {
467 processor_menu = build_processor_menu ();
470 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/processormenu/newplugin"));
472 if (plugin_menu_item) {
473 plugin_menu_item->set_submenu (*_get_plugin_selector()->plugin_menu());
476 Gtk::MenuItem* aux_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/processormenu/newaux"));
479 Menu* m = build_possible_aux_menu();
480 if (m && !m->items().empty()) {
481 aux_menu_item->set_submenu (*m);
482 aux_menu_item->set_sensitive (true);
484 /* stupid gtkmm: we need to pass a null reference here */
485 gtk_menu_item_set_submenu (aux_menu_item->gobj(), 0);
486 aux_menu_item->set_sensitive (false);
490 paste_action->set_sensitive (!_rr_selection.processors.empty());
492 processor_menu->popup (1, arg);
496 ProcessorBox::enter_notify (GdkEventCrossing*)
498 _current_processor_box = this;
499 Keyboard::magic_widget_grab_focus ();
500 processor_display.grab_focus ();
506 ProcessorBox::leave_notify (GdkEventCrossing* ev)
508 switch (ev->detail) {
509 case GDK_NOTIFY_INFERIOR:
512 Keyboard::magic_widget_drop_focus ();
519 ProcessorBox::processor_key_press_event (GdkEventKey *)
521 /* do real stuff on key release */
526 ProcessorBox::processor_key_release_event (GdkEventKey *ev)
529 ProcSelection targets;
531 get_selected_processors (targets);
533 if (targets.empty()) {
536 processor_display.get_pointer (x, y);
538 pair<ProcessorEntry *, int> const pointer = processor_display.get_child_at_position (x, y);
541 targets.push_back (pointer.first->processor ());
546 switch (ev->keyval) {
548 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
549 processor_display.select_all ();
555 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
556 copy_processors (targets);
562 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
563 cut_processors (targets);
569 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
570 if (targets.empty()) {
573 paste_processors (targets.front());
587 delete_processors (targets);
592 for (ProcSelection::iterator i = targets.begin(); i != targets.end(); ++i) {
593 if ((*i)->active()) {
615 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
617 boost::shared_ptr<Processor> processor;
619 processor = child->processor ();
623 bool selected = processor_display.selected (child);
625 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
627 if (_session.engine().connected()) {
628 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
629 edit_processor (processor);
633 } else if (processor && ev->button == 1 && selected) {
635 // this is purely informational but necessary for route params UI
636 ProcessorSelected (processor); // emit
638 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
641 _get_plugin_selector()->show_manager ();
648 ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry* child)
650 boost::shared_ptr<Processor> processor;
652 processor = child->processor ();
657 if (processor && Keyboard::is_delete_event (ev)) {
659 Glib::signal_idle().connect (bind (
660 mem_fun(*this, &ProcessorBox::idle_delete_processor),
661 boost::weak_ptr<Processor>(processor)));
664 } else if (Keyboard::is_context_menu_event (ev)) {
666 /* figure out if we are above or below the fader/amp processor,
667 and set the next insert position appropriately.
671 if (_route->processor_is_prefader (processor)) {
672 _placement = PreFader;
674 _placement = PostFader;
677 _placement = PostFader;
680 show_processor_menu (ev->time);
683 } else if (processor && Keyboard::is_button2_event (ev)
685 && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
689 /* button2-click with no/appropriate modifiers */
691 if (processor->active()) {
692 processor->deactivate ();
694 processor->activate ();
704 ProcessorBox::build_processor_menu ()
706 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/processormenu") );
707 processor_menu->set_name ("ArdourContextMenu");
711 return processor_menu;
715 ProcessorBox::selection_changed ()
717 bool sensitive = (processor_display.selection().empty()) ? false : true;
718 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
722 ProcessorBox::select_all_processors ()
724 processor_display.select_all ();
728 ProcessorBox::deselect_all_processors ()
730 processor_display.select_none ();
734 ProcessorBox::choose_plugin ()
736 _get_plugin_selector()->set_interested_object (*this);
740 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
742 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
744 boost::shared_ptr<Processor> processor (new PluginInsert (_session, *p));
746 Route::ProcessorStreams err_streams;
748 if (Config->get_new_plugins_active()) {
749 processor->activate ();
752 if (_route->add_processor (processor, _placement, &err_streams)) {
753 weird_plugin_dialog (**p, err_streams);
754 // XXX SHAREDPTR delete plugin here .. do we even need to care?
757 if (Profile->get_sae()) {
758 processor->activate ();
765 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
767 ArdourDialog dialog (_("ardour: weird plugin dialog"));
770 string text = string_compose(_("You attempted to add the plugin \"%1\" at index %2.\n"),
771 p.name(), streams.index);
773 bool has_midi = streams.count.n_midi() > 0 || p.get_info()->n_inputs.n_midi() > 0;
774 bool has_audio = streams.count.n_audio() > 0 || p.get_info()->n_inputs.n_audio() > 0;
776 text += _("\nThis plugin has:\n");
778 text += string_compose("\t%1 ", p.get_info()->n_inputs.n_midi()) + _("MIDI input(s)\n");
781 text += string_compose("\t%1 ", p.get_info()->n_inputs.n_audio()) + _("audio input(s)\n");
784 text += _("\nBut at the insertion point, there are:\n");
786 text += string_compose("\t%1 ", streams.count.n_midi()) + _("MIDI channel(s)\n");
789 text += string_compose("\t%1 ", streams.count.n_audio()) + _("audio channel(s)\n");
792 text += _("\nArdour is unable to insert this plugin here.\n");
793 label.set_text(text);
795 dialog.get_vbox()->pack_start (label);
796 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
798 dialog.set_name (X_("PluginIODialog"));
799 dialog.set_position (Gtk::WIN_POS_MOUSE);
800 dialog.set_modal (true);
807 ProcessorBox::choose_insert ()
809 boost::shared_ptr<Processor> processor (new PortInsert (_session, _route->mute_master()));
810 _route->add_processor (processor, _placement);
814 ProcessorBox::choose_send ()
816 boost::shared_ptr<Send> send (new Send (_session, _route->mute_master()));
818 /* make an educated guess at the initial number of outputs for the send */
819 ChanCount outs = (_session.master_out())
820 ? _session.master_out()->n_outputs()
821 : _route->n_outputs();
823 /* XXX need processor lock on route */
825 send->output()->ensure_io (outs, false, this);
826 } catch (AudioEngine::PortRegistrationFailure& err) {
827 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
831 /* let the user adjust the IO setup before creation.
833 Note: this dialog is NOT modal - we just leave it to run and it will
834 return when its Finished signal is emitted - typically when the window
838 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
841 /* keep a reference to the send so it doesn't get deleted while
842 the IOSelectorWindow is doing its stuff
844 _processor_being_created = send;
846 ios->selector().Finished.connect (bind (
847 mem_fun(*this, &ProcessorBox::send_io_finished),
848 boost::weak_ptr<Processor>(send), ios));
853 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
855 boost::shared_ptr<Processor> processor (weak_processor.lock());
857 /* drop our temporary reference to the new send */
858 _processor_being_created.reset ();
865 case IOSelector::Cancelled:
866 // processor will go away when all shared_ptrs to it vanish
869 case IOSelector::Accepted:
870 _route->add_processor (processor, _placement);
871 if (Profile->get_sae()) {
872 processor->activate ();
877 delete_when_idle (ios);
881 ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
883 boost::shared_ptr<Processor> processor (weak_processor.lock());
885 /* drop our temporary reference to the new return */
886 _processor_being_created.reset ();
893 case IOSelector::Cancelled:
894 // processor will go away when all shared_ptrs to it vanish
897 case IOSelector::Accepted:
898 _route->add_processor (processor, _placement);
899 if (Profile->get_sae()) {
900 processor->activate ();
905 delete_when_idle (ios);
909 ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
915 boost::shared_ptr<Route> target = wr.lock();
921 boost::shared_ptr<RouteList> rlist (new RouteList);
922 rlist->push_back (_route);
924 _session.add_internal_sends (target, PreFader, rlist);
928 ProcessorBox::redisplay_processors ()
930 ENSURE_GUI_THREAD (mem_fun(*this, &ProcessorBox::redisplay_processors));
932 if (no_processor_redisplay) {
936 processor_display.clear ();
938 _route->foreach_processor (mem_fun (*this, &ProcessorBox::add_processor_to_display));
940 build_processor_tooltip (processor_eventbox, _("Inserts, sends & plugins:"));
944 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
946 boost::shared_ptr<Processor> processor (p.lock ());
948 if (!processor || !processor->display_to_user()) {
952 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
954 processor_display.add_child (new SendProcessorEntry (send, _width));
956 processor_display.add_child (new ProcessorEntry (processor, _width));
962 ProcessorBox::build_processor_tooltip (EventBox& box, string start)
966 list<ProcessorEntry*> children = processor_display.children ();
967 for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
969 tip += (*i)->processor()->name();
972 ARDOUR_UI::instance()->tooltips().set_tip (box, tip);
976 ProcessorBox::reordered ()
978 compute_processor_sort_keys ();
982 ProcessorBox::compute_processor_sort_keys ()
984 list<ProcessorEntry*> children = processor_display.children ();
985 Route::ProcessorList our_processors;
987 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
988 our_processors.push_back ((*iter)->processor ());
991 if (_route->reorder_processors (our_processors)) {
993 /* reorder failed, so redisplay */
995 redisplay_processors ();
997 /* now tell them about the problem */
999 ArdourDialog dialog (_("ardour: weird plugin dialog"));
1002 label.set_text (_("\
1003 You cannot reorder this set of processors\n\
1004 in that way because the inputs and\n\
1005 outputs do not work correctly."));
1007 dialog.get_vbox()->pack_start (label);
1008 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
1010 dialog.set_name (X_("PluginIODialog"));
1011 dialog.set_position (Gtk::WIN_POS_MOUSE);
1012 dialog.set_modal (true);
1020 ProcessorBox::rename_processors ()
1022 ProcSelection to_be_renamed;
1024 get_selected_processors (to_be_renamed);
1026 if (to_be_renamed.empty()) {
1030 for (ProcSelection::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
1031 rename_processor (*i);
1036 ProcessorBox::cut_processors ()
1038 ProcSelection to_be_removed;
1040 get_selected_processors (to_be_removed);
1044 ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
1046 if (to_be_removed.empty()) {
1050 XMLNode* node = new XMLNode (X_("cut"));
1051 Route::ProcessorList to_cut;
1053 no_processor_redisplay = true;
1054 for (ProcSelection::const_iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
1055 // Cut only plugins, sends and returns
1056 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1057 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1058 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1060 void* gui = (*i)->get_gui ();
1063 static_cast<Gtk::Widget*>(gui)->hide ();
1066 XMLNode& child ((*i)->get_state());
1067 node->add_child_nocopy (child);
1068 to_cut.push_back (*i);
1072 if (_route->remove_processors (to_cut) != 0) {
1074 no_processor_redisplay = false;
1078 _rr_selection.set (node);
1080 no_processor_redisplay = false;
1081 redisplay_processors ();
1085 ProcessorBox::copy_processors ()
1087 ProcSelection to_be_copied;
1088 get_selected_processors (to_be_copied);
1089 copy_processors (to_be_copied);
1093 ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
1095 if (to_be_copied.empty()) {
1099 XMLNode* node = new XMLNode (X_("copy"));
1101 for (ProcSelection::const_iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
1102 // Copy only plugins, sends, returns
1103 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
1104 (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
1105 (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
1106 node->add_child_nocopy ((*i)->get_state());
1110 _rr_selection.set (node);
1114 ProcessorBox::delete_processors ()
1116 ProcSelection to_be_deleted;
1117 get_selected_processors (to_be_deleted);
1118 delete_processors (to_be_deleted);
1122 ProcessorBox::delete_processors (const ProcSelection& targets)
1124 if (targets.empty()) {
1128 no_processor_redisplay = true;
1130 for (ProcSelection::const_iterator i = targets.begin(); i != targets.end(); ++i) {
1132 void* gui = (*i)->get_gui ();
1135 static_cast<Gtk::Widget*>(gui)->hide ();
1138 _route->remove_processor(*i);
1141 no_processor_redisplay = false;
1142 redisplay_processors ();
1146 ProcessorBox::delete_dragged_processors (const list<boost::shared_ptr<Processor> >& procs)
1148 list<boost::shared_ptr<Processor> >::const_iterator x;
1150 no_processor_redisplay = true;
1151 for (x = procs.begin(); x != procs.end(); ++x) {
1153 void* gui = (*x)->get_gui ();
1156 static_cast<Gtk::Widget*>(gui)->hide ();
1159 _route->remove_processor(*x);
1162 no_processor_redisplay = false;
1163 redisplay_processors ();
1167 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
1169 boost::shared_ptr<Processor> processor (weak_processor.lock());
1175 /* NOT copied to _mixer.selection() */
1177 no_processor_redisplay = true;
1178 _route->remove_processor (processor);
1179 no_processor_redisplay = false;
1180 redisplay_processors ();
1186 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
1188 ArdourPrompter name_prompter (true);
1190 name_prompter.set_title (_("Rename Processor"));
1191 name_prompter.set_prompt (_("New name:"));
1192 name_prompter.set_initial_text (processor->name());
1193 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
1194 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
1195 name_prompter.show_all ();
1197 switch (name_prompter.run ()) {
1199 case Gtk::RESPONSE_ACCEPT:
1200 name_prompter.get_result (result);
1201 if (result.length()) {
1202 if (_session.route_by_name (result)) {
1203 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name."));
1206 processor->set_name (result);
1215 ProcessorBox::paste_processors ()
1217 if (_rr_selection.processors.empty()) {
1221 paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
1225 ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
1228 if (_rr_selection.processors.empty()) {
1232 paste_processor_state (_rr_selection.processors.get_node().children(), before);
1236 ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr<Processor> p)
1238 XMLNodeConstIterator niter;
1239 list<boost::shared_ptr<Processor> > copies;
1241 if (nlist.empty()) {
1245 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1247 XMLProperty const * type = (*niter)->property ("type");
1250 boost::shared_ptr<Processor> p;
1252 if (type->value() == "meter" ||
1253 type->value() == "main-outs" ||
1254 type->value() == "amp" ||
1255 type->value() == "intsend" || type->value() == "intreturn") {
1256 /* do not paste meter, main outs, amp or internal send/returns */
1259 } else if (type->value() == "send") {
1261 XMLNode n (**niter);
1262 Send::make_unique (n, _session);
1263 p.reset (new Send (_session, _route->mute_master(), n));
1265 } else if (type->value() == "return") {
1267 XMLNode n (**niter);
1268 Return::make_unique (n, _session);
1269 p.reset (new Return (_session, **niter));
1272 /* XXX its a bit limiting to assume that everything else
1275 p.reset (new PluginInsert (_session, **niter));
1278 copies.push_back (p);
1282 cerr << "plugin insert constructor failed\n";
1286 if (copies.empty()) {
1290 if (_route->add_processors (copies, p)) {
1293 "Copying the set of processors on the clipboard failed,\n\
1294 probably because the I/O configuration of the plugins\n\
1295 could not match the configuration of this track.");
1296 MessageDialog am (msg);
1302 ProcessorBox::activate_processor (boost::shared_ptr<Processor> r)
1308 ProcessorBox::deactivate_processor (boost::shared_ptr<Processor> r)
1314 ProcessorBox::get_selected_processors (ProcSelection& processors)
1316 list<ProcessorEntry*> selection = processor_display.selection ();
1317 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
1318 processors.push_back ((*i)->processor ());
1323 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
1325 list<ProcessorEntry*> selection = processor_display.selection ();
1326 for (list<ProcessorEntry*>::iterator i = selection.begin(); i != selection.end(); ++i) {
1327 (this->*method) ((*i)->processor ());
1332 ProcessorBox::all_processors_active (bool state)
1334 _route->all_processors_active (_placement, state);
1338 ProcessorBox::ab_plugins ()
1340 _route->ab_plugins (ab_direction);
1341 ab_direction = !ab_direction;
1346 ProcessorBox::clear_processors ()
1349 vector<string> choices;
1351 prompt = string_compose (_("Do you really want to remove all processors from %1?\n"
1352 "(this cannot be undone)"), _route->name());
1354 choices.push_back (_("Cancel"));
1355 choices.push_back (_("Yes, remove them all"));
1357 Gtkmm2ext::Choice prompter (prompt, choices);
1359 if (prompter.run () == 1) {
1360 _route->clear_processors (PreFader);
1361 _route->clear_processors (PostFader);
1366 ProcessorBox::clear_processors (Placement p)
1369 vector<string> choices;
1371 if (p == PreFader) {
1372 prompt = string_compose (_("Do you really want to remove all pre-fader processors from %1?\n"
1373 "(this cannot be undone)"), _route->name());
1375 prompt = string_compose (_("Do you really want to remove all post-fader processors from %1?\n"
1376 "(this cannot be undone)"), _route->name());
1379 choices.push_back (_("Cancel"));
1380 choices.push_back (_("Yes, remove them all"));
1382 Gtkmm2ext::Choice prompter (prompt, choices);
1384 if (prompter.run () == 1) {
1385 _route->clear_processors (p);
1390 ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
1392 boost::shared_ptr<Send> send;
1393 boost::shared_ptr<Return> retrn;
1394 boost::shared_ptr<PluginInsert> plugin_insert;
1395 boost::shared_ptr<PortInsert> port_insert;
1398 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
1400 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
1405 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
1407 if (!_session.engine().connected()) {
1411 #ifdef OLD_SEND_EDITING
1412 SendUIWindow *send_ui;
1414 if (send->get_gui() == 0) {
1415 send_ui = new SendUIWindow (send, _session);
1416 send_ui->set_title (send->name());
1417 send->set_gui (send_ui);
1420 send_ui = reinterpret_cast<SendUIWindow *> (send->get_gui());
1425 if (_parent_strip) {
1426 _parent_strip->show_send (send);
1430 } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
1432 if (!_session.engine().connected()) {
1436 boost::shared_ptr<Return> retrn = boost::dynamic_pointer_cast<Return> (processor);
1438 ReturnUIWindow *return_ui;
1440 if (retrn->get_gui() == 0) {
1442 return_ui = new ReturnUIWindow (retrn, _session);
1443 return_ui->set_title (retrn->name ());
1444 send->set_gui (return_ui);
1447 return_ui = reinterpret_cast<ReturnUIWindow *> (retrn->get_gui());
1452 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
1454 PluginUIWindow *plugin_ui;
1456 /* these are both allowed to be null */
1458 Container* toplevel = get_toplevel();
1459 Window* win = dynamic_cast<Gtk::Window*>(toplevel);
1461 if (plugin_insert->get_gui() == 0) {
1463 plugin_ui = new PluginUIWindow (win, plugin_insert);
1464 plugin_ui->set_title (generate_processor_title (plugin_insert));
1465 plugin_insert->set_gui (plugin_ui);
1468 plugin_ui = reinterpret_cast<PluginUIWindow *> (plugin_insert->get_gui());
1469 plugin_ui->set_parent (win);
1474 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
1476 if (!_session.engine().connected()) {
1477 MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible"));
1482 PortInsertWindow *io_selector;
1484 if (port_insert->get_gui() == 0) {
1485 io_selector = new PortInsertWindow (_session, port_insert);
1486 port_insert->set_gui (io_selector);
1489 io_selector = reinterpret_cast<PortInsertWindow *> (port_insert->get_gui());
1492 gidget = io_selector;
1496 if (gidget->is_visible()) {
1497 gidget->get_window()->raise ();
1499 gidget->show_all ();
1506 ProcessorBox::register_actions ()
1508 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("processormenu"));
1509 Glib::RefPtr<Action> act;
1512 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin"),
1513 sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
1515 act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"),
1516 sigc::ptr_fun (ProcessorBox::rb_choose_insert));
1517 ActionManager::jack_sensitive_actions.push_back (act);
1518 act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New Send ..."),
1519 sigc::ptr_fun (ProcessorBox::rb_choose_send));
1520 ActionManager::jack_sensitive_actions.push_back (act);
1522 ActionManager::register_action (popup_act_grp, X_("newaux"), _("New Aux Send ..."));
1524 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear (all)"),
1525 sigc::ptr_fun (ProcessorBox::rb_clear));
1526 ActionManager::register_action (popup_act_grp, X_("clear_pre"), _("Clear (pre-fader)"),
1527 sigc::ptr_fun (ProcessorBox::rb_clear_pre));
1528 ActionManager::register_action (popup_act_grp, X_("clear_post"), _("Clear (post-fader)"),
1529 sigc::ptr_fun (ProcessorBox::rb_clear_post));
1531 /* standard editing stuff */
1532 act = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"),
1533 sigc::ptr_fun (ProcessorBox::rb_cut));
1534 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1535 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),
1536 sigc::ptr_fun (ProcessorBox::rb_copy));
1537 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1539 act = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"),
1540 sigc::ptr_fun (ProcessorBox::rb_delete));
1541 ActionManager::plugin_selection_sensitive_actions.push_back(act); // ??
1543 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"),
1544 sigc::ptr_fun (ProcessorBox::rb_paste));
1545 act = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"),
1546 sigc::ptr_fun (ProcessorBox::rb_rename));
1547 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1548 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"),
1549 sigc::ptr_fun (ProcessorBox::rb_select_all));
1550 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"),
1551 sigc::ptr_fun (ProcessorBox::rb_deselect_all));
1553 /* activation etc. */
1555 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate all"),
1556 sigc::ptr_fun (ProcessorBox::rb_activate_all));
1557 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate all"),
1558 sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
1559 ActionManager::register_action (popup_act_grp, X_("ab_plugins"), _("A/B Plugins"),
1560 sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
1563 act = ActionManager::register_action (popup_act_grp, X_("edit"), _("Edit"),
1564 sigc::ptr_fun (ProcessorBox::rb_edit));
1565 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1567 ActionManager::add_action_group (popup_act_grp);
1571 ProcessorBox::rb_ab_plugins ()
1573 if (_current_processor_box == 0) {
1577 _current_processor_box->ab_plugins ();
1581 ProcessorBox::rb_choose_plugin ()
1583 if (_current_processor_box == 0) {
1586 _current_processor_box->choose_plugin ();
1590 ProcessorBox::rb_choose_insert ()
1592 if (_current_processor_box == 0) {
1595 _current_processor_box->choose_insert ();
1599 ProcessorBox::rb_choose_send ()
1601 if (_current_processor_box == 0) {
1604 _current_processor_box->choose_send ();
1608 ProcessorBox::rb_choose_aux (boost::weak_ptr<Route> wr)
1610 if (_current_processor_box == 0) {
1614 _current_processor_box->choose_aux (wr);
1618 ProcessorBox::rb_clear ()
1620 if (_current_processor_box == 0) {
1624 _current_processor_box->clear_processors ();
1629 ProcessorBox::rb_clear_pre ()
1631 if (_current_processor_box == 0) {
1635 _current_processor_box->clear_processors (PreFader);
1640 ProcessorBox::rb_clear_post ()
1642 if (_current_processor_box == 0) {
1646 _current_processor_box->clear_processors (PostFader);
1650 ProcessorBox::rb_cut ()
1652 if (_current_processor_box == 0) {
1656 _current_processor_box->cut_processors ();
1660 ProcessorBox::rb_delete ()
1662 if (_current_processor_box == 0) {
1666 _current_processor_box->delete_processors ();
1670 ProcessorBox::rb_copy ()
1672 if (_current_processor_box == 0) {
1675 _current_processor_box->copy_processors ();
1679 ProcessorBox::rb_paste ()
1681 if (_current_processor_box == 0) {
1685 _current_processor_box->paste_processors ();
1689 ProcessorBox::rb_rename ()
1691 if (_current_processor_box == 0) {
1694 _current_processor_box->rename_processors ();
1698 ProcessorBox::rb_select_all ()
1700 if (_current_processor_box == 0) {
1704 _current_processor_box->select_all_processors ();
1708 ProcessorBox::rb_deselect_all ()
1710 if (_current_processor_box == 0) {
1714 _current_processor_box->deselect_all_processors ();
1718 ProcessorBox::rb_activate_all ()
1720 if (_current_processor_box == 0) {
1724 _current_processor_box->all_processors_active (true);
1728 ProcessorBox::rb_deactivate_all ()
1730 if (_current_processor_box == 0) {
1733 _current_processor_box->all_processors_active (false);
1737 ProcessorBox::rb_edit ()
1739 if (_current_processor_box == 0) {
1743 _current_processor_box->for_selected_processors (&ProcessorBox::edit_processor);
1747 ProcessorBox::route_name_changed ()
1749 ENSURE_GUI_THREAD (mem_fun (*this, &ProcessorBox::route_name_changed));
1751 boost::shared_ptr<Processor> processor;
1752 boost::shared_ptr<PluginInsert> plugin_insert;
1753 boost::shared_ptr<Send> send;
1755 list<ProcessorEntry*> children = processor_display.children();
1757 for (list<ProcessorEntry*>::iterator iter = children.begin(); iter != children.end(); ++iter) {
1759 processor = (*iter)->processor ();
1761 void* gui = processor->get_gui();
1767 /* rename editor windows for sends and plugins */
1769 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
1770 static_cast<Window*>(gui)->set_title (send->name ());
1771 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
1772 static_cast<Window*>(gui)->set_title (generate_processor_title (plugin_insert));
1778 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
1780 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
1781 string::size_type email_pos;
1783 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
1784 maker = maker.substr (0, email_pos - 1);
1787 if (maker.length() > 32) {
1788 maker = maker.substr (0, 32);
1792 return string_compose(_("%1: %2 (by %3)"), _route->name(), pi->name(), maker);