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.
24 #include <sigc++/bind.h>
26 #include <pbd/convert.h>
28 #include <glibmm/miscutils.h>
30 #include <gtkmm/messagedialog.h>
32 #include <gtkmm2ext/gtk_ui.h>
33 #include <gtkmm2ext/utils.h>
34 #include <gtkmm2ext/choice.h>
35 #include <gtkmm2ext/utils.h>
36 #include <gtkmm2ext/stop_signal.h>
37 #include <gtkmm2ext/doi.h>
38 #include <gtkmm2ext/window_title.h>
40 #include <ardour/ardour.h>
41 #include <ardour/session.h>
42 #include <ardour/audioengine.h>
43 #include <ardour/route.h>
44 #include <ardour/audio_track.h>
45 #include <ardour/audio_diskstream.h>
46 #include <ardour/send.h>
47 #include <ardour/plugin_insert.h>
48 #include <ardour/port_insert.h>
49 #include <ardour/ladspa_plugin.h>
50 #include <ardour/profile.h>
52 #include "ardour_ui.h"
53 #include "ardour_dialog.h"
54 #include "public_editor.h"
55 #include "processor_box.h"
57 #include "plugin_selector.h"
58 #include "route_processor_selection.h"
61 #include "plugin_ui.h"
62 #include "io_selector.h"
64 #include "gui_thread.h"
68 #ifdef HAVE_AUDIOUNITS
73 using namespace ARDOUR;
77 using namespace Gtkmm2ext;
79 ProcessorBox* ProcessorBox::_current_processor_box = 0;
80 RefPtr<Action> ProcessorBox::paste_action;
81 bool ProcessorBox::get_colors = true;
82 Gdk::Color* ProcessorBox::active_processor_color;
83 Gdk::Color* ProcessorBox::inactive_processor_color;
85 ProcessorBox::ProcessorBox (Placement pcmnt, Session& sess, PluginSelector &plugsel,
86 RouteRedirectSelection & rsel, bool owner_is_mixer)
88 _owner_is_mixer (owner_is_mixer),
90 _plugin_selector(plugsel),
94 active_processor_color = new Gdk::Color;
95 inactive_processor_color = new Gdk::Color;
96 set_color (*active_processor_color, rgba_from_style ("ProcessorSelector", 0xff, 0, 0, 0, "fg", Gtk::STATE_ACTIVE, false ));
97 set_color (*inactive_processor_color, rgba_from_style ("ProcessorSelector", 0xff, 0, 0, 0, "fg", Gtk::STATE_NORMAL, false ));
103 send_action_menu = 0;
104 processor_drag_in_progress = false;
105 no_processor_redisplay = false;
106 ignore_delete = false;
108 model = ListStore::create(columns);
110 RefPtr<TreeSelection> selection = processor_display.get_selection();
111 selection->set_mode (Gtk::SELECTION_MULTIPLE);
112 selection->signal_changed().connect (mem_fun (*this, &ProcessorBox::selection_changed));
114 processor_display.set_model (model);
115 processor_display.append_column (X_("notshown"), columns.text);
116 processor_display.set_name ("ProcessorSelector");
117 processor_display.set_headers_visible (false);
118 processor_display.set_reorderable (true);
119 processor_display.set_size_request (-1, 40);
120 processor_display.get_column(0)->set_sizing(TREE_VIEW_COLUMN_FIXED);
121 processor_display.get_column(0)->set_fixed_width(48);
122 processor_display.add_object_drag (columns.processor.index(), "processors");
123 processor_display.signal_drop.connect (mem_fun (*this, &ProcessorBox::object_drop));
125 TreeViewColumn* name_col = processor_display.get_column(0);
126 CellRendererText* renderer = dynamic_cast<CellRendererText*>(processor_display.get_column_cell_renderer (0));
127 name_col->add_attribute(renderer->property_foreground_gdk(), columns.color);
129 processor_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
131 model->signal_row_deleted().connect (mem_fun (*this, &ProcessorBox::row_deleted));
133 processor_scroller.add (processor_display);
134 processor_eventbox.add (processor_scroller);
136 processor_scroller.set_size_request (-1, 40);
138 pack_start (processor_eventbox, true, true);
140 processor_eventbox.signal_enter_notify_event().connect (bind (sigc::ptr_fun (ProcessorBox::enter_box), this));
142 processor_display.signal_button_press_event().connect (mem_fun(*this, &ProcessorBox::processor_button_press_event), false);
143 processor_display.signal_button_release_event().connect (mem_fun(*this, &ProcessorBox::processor_button_release_event));
146 ProcessorBox::~ProcessorBox ()
151 ProcessorBox::set_route (boost::shared_ptr<Route> r)
153 connections.clear ();
157 connections.push_back (_route->processors_changed.connect (mem_fun(*this, &ProcessorBox::redisplay_processors)));
158 connections.push_back (_route->GoingAway.connect (mem_fun (*this, &ProcessorBox::route_going_away)));
160 redisplay_processors ();
164 ProcessorBox::route_going_away ()
166 /* don't keep updating display as processors are deleted */
167 no_processor_redisplay = true;
172 ProcessorBox::object_drop (const list<boost::shared_ptr<Processor> >& procs)
174 paste_processor_list (procs);
178 ProcessorBox::update()
180 redisplay_processors ();
185 ProcessorBox::set_width (Width w)
192 redisplay_processors ();
196 ProcessorBox::remove_processor_gui (boost::shared_ptr<Processor> processor)
198 boost::shared_ptr<Send> send;
199 boost::shared_ptr<PortInsert> port_insert;
201 if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
203 PortInsertUI *io_selector = reinterpret_cast<PortInsertUI *> (port_insert->get_gui());
204 port_insert->set_gui (0);
207 } else if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
208 SendUIWindow *sui = reinterpret_cast<SendUIWindow*> (send->get_gui());
215 ProcessorBox::build_send_action_menu ()
218 using namespace Menu_Helpers;
220 send_action_menu = new Menu;
221 send_action_menu->set_name ("ArdourContextMenu");
222 MenuList& items = send_action_menu->items();
224 items.push_back (MenuElem (_("New send"), mem_fun(*this, &ProcessorBox::new_send)));
225 items.push_back (MenuElem (_("Show send controls"), mem_fun(*this, &ProcessorBox::show_send_controls)));
229 ProcessorBox::show_send_controls ()
235 ProcessorBox::new_send ()
241 ProcessorBox::show_processor_menu (gint arg)
243 if (processor_menu == 0) {
244 processor_menu = build_processor_menu ();
247 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/processormenu/newplugin"));
249 if (plugin_menu_item) {
250 plugin_menu_item->set_submenu (_plugin_selector.plugin_menu());
253 paste_action->set_sensitive (!_rr_selection.processors.empty());
255 processor_menu->popup (1, arg);
259 ProcessorBox::processor_drag_begin (GdkDragContext *context)
261 processor_drag_in_progress = true;
265 ProcessorBox::processor_drag_end (GdkDragContext *context)
267 processor_drag_in_progress = false;
271 ProcessorBox::processor_button_press_event (GdkEventButton *ev)
274 TreeModel::Path path;
275 TreeViewColumn* column;
278 boost::shared_ptr<Processor> processor;
280 bool selected = false;
282 if (processor_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
283 if ((iter = model->get_iter (path))) {
284 processor = (*iter)[columns.processor];
285 selected = processor_display.get_selection()->is_selected (iter);
290 if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
292 if (_session.engine().connected()) {
293 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
294 edit_processor (processor);
298 } else if (processor && ev->button == 1 && selected) {
300 // this is purely informational but necessary
301 ProcessorSelected (processor); // emit
303 } else if (!processor && ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
306 _plugin_selector.show_manager ();
314 ProcessorBox::processor_button_release_event (GdkEventButton *ev)
317 TreeModel::Path path;
318 TreeViewColumn* column;
321 boost::shared_ptr<Processor> processor;
325 if (processor_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
326 if ((iter = model->get_iter (path))) {
327 processor = (*iter)[columns.processor];
331 if (processor && Keyboard::is_delete_event (ev)) {
333 Glib::signal_idle().connect (bind (mem_fun(*this, &ProcessorBox::idle_delete_processor), boost::weak_ptr<Processor>(processor)));
336 } else if (Keyboard::is_context_menu_event (ev)) {
338 show_processor_menu(ev->time);
341 } else if (processor && Keyboard::is_button2_event (ev) && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))) {
343 /* button2-click with no modifiers */
345 if (processor->active()) {
346 processor->deactivate ();
348 processor->activate ();
358 ProcessorBox::build_processor_menu ()
360 processor_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/processormenu") );
361 processor_menu->set_name ("ArdourContextMenu");
365 return processor_menu;
369 ProcessorBox::selection_changed ()
371 bool sensitive = (processor_display.get_selection()->count_selected_rows()) ? true : false;
372 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
376 ProcessorBox::select_all_processors ()
378 processor_display.get_selection()->select_all();
382 ProcessorBox::deselect_all_processors ()
384 processor_display.get_selection()->unselect_all();
388 ProcessorBox::choose_plugin ()
390 _plugin_selector.set_interested_object (*this);
394 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
396 for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
398 boost::shared_ptr<Processor> processor (new PluginInsert (_session, *p, _placement));
400 Route::ProcessorStreams err_streams;
402 if (Config->get_new_plugins_active()) {
403 processor->activate ();
406 if (_route->add_processor (processor, &err_streams)) {
407 weird_plugin_dialog (**p, err_streams, _route);
408 // XXX SHAREDPTR delete plugin here .. do we even need to care?
411 if (Profile->get_sae()) {
412 processor->activate ();
414 processor->ActiveChanged.connect (bind (mem_fun (*this, &ProcessorBox::show_processor_active), boost::weak_ptr<Processor>(processor)));
420 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams, boost::shared_ptr<IO> io)
422 ArdourDialog dialog (_("ardour: weird plugin dialog"));
425 /* i hate this kind of code */
427 if (streams.count > p.get_info()->n_inputs) {
428 label.set_text (string_compose (_(
429 "You attempted to add a plugin (%1).\n"
430 "The plugin has %2 inputs\n"
431 "but at the processorion point, there are\n"
432 "%3 active signal streams.\n"
434 "This makes no sense - you are throwing away\n"
435 "part of the signal."),
437 p.get_info()->n_inputs.n_total(),
438 streams.count.n_total()));
439 } else if (streams.count < p.get_info()->n_inputs) {
440 label.set_text (string_compose (_(
441 "You attempted to add a plugin (%1).\n"
442 "The plugin has %2 inputs\n"
443 "but at the processorion point there are\n"
444 "only %3 active signal streams.\n"
446 "This makes no sense - unless the plugin supports\n"
447 "side-chain inputs. A future version of Ardour will\n"
448 "support this type of configuration."),
450 p.get_info()->n_inputs.n_total(),
451 streams.count.n_total()));
453 label.set_text (string_compose (_(
454 "You attempted to add a plugin (%1).\n"
456 "The I/O configuration doesn't make sense:\n"
458 "The plugin has %2 inputs and %3 outputs.\n"
459 "The track/bus has %4 inputs and %5 outputs.\n"
460 "The processorion point, has %6 active signals.\n"
462 "Ardour does not understand what to do in such situations.\n"),
464 p.get_info()->n_inputs.n_total(),
465 p.get_info()->n_outputs.n_total(),
466 io->n_inputs().n_total(),
467 io->n_outputs().n_total(),
468 streams.count.n_total()));
471 dialog.get_vbox()->pack_start (label);
472 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
474 dialog.set_name (X_("PluginIODialog"));
475 dialog.set_position (Gtk::WIN_POS_MOUSE);
476 dialog.set_modal (true);
483 ProcessorBox::choose_insert ()
485 boost::shared_ptr<Processor> processor (new PortInsert (_session, _placement));
486 processor->ActiveChanged.connect (bind (mem_fun(*this, &ProcessorBox::show_processor_active), boost::weak_ptr<Processor>(processor)));
487 _route->add_processor (processor);
491 ProcessorBox::choose_send ()
493 boost::shared_ptr<Send> send (new Send (_session, _placement));
494 //send->set_default_type(_route->default_type());
498 /* make an educated guess at the initial number of outputs for the send */
500 if (_session.master_out()) {
501 outs = _session.master_out()->n_outputs();
503 outs = _route->n_outputs();
506 /* XXX need processor lock on route */
509 send->io()->ensure_io (ChanCount::ZERO, outs, false, this);
510 } catch (AudioEngine::PortRegistrationFailure& err) {
511 error << string_compose (_("Cannot set up new send: %1"), err.what()) << endmsg;
515 /* let the user adjust the output setup (number and connections) before passing
516 it along to the Route
519 IOSelectorWindow *ios = new IOSelectorWindow (_session, send->io(), false, true);
523 /* bit of a hack; keep a shared_ptr to send around so that it doesn't get deleted while
524 the IOSelectorWindow is doing its stuff */
525 _send_being_created = send;
527 boost::shared_ptr<Processor> r = boost::static_pointer_cast<Processor>(send);
529 ios->selector().Finished.connect (bind (mem_fun(*this, &ProcessorBox::send_io_finished), boost::weak_ptr<Processor>(r), ios));
533 ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor> weak_processor, IOSelectorWindow* ios)
535 boost::shared_ptr<Processor> processor (weak_processor.lock());
537 /* now we can lose the dummy shared_ptr */
538 _send_being_created.reset ();
545 case IOSelector::Cancelled:
546 // processor will go away when all shared_ptrs to it vanish
549 case IOSelector::Accepted:
550 _route->add_processor (processor);
551 if (Profile->get_sae()) {
552 processor->activate ();
557 delete_when_idle (ios);
561 ProcessorBox::redisplay_processors ()
563 ENSURE_GUI_THREAD (mem_fun(*this, &ProcessorBox::redisplay_processors));
565 if (no_processor_redisplay) {
569 ignore_delete = true;
571 ignore_delete = false;
573 processor_active_connections.clear ();
574 processor_name_connections.clear ();
576 _route->foreach_processor (mem_fun (*this, &ProcessorBox::add_processor_to_display));
578 switch (_placement) {
580 build_processor_tooltip(processor_eventbox, _("Pre-fader inserts, sends & plugins:"));
583 build_processor_tooltip(processor_eventbox, _("Post-fader inserts, sends & plugins:"));
589 ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
591 boost::shared_ptr<Processor> processor (p.lock ());
596 if (processor->placement() != _placement) {
600 Gtk::TreeModel::Row row = *(model->append());
601 row[columns.text] = processor_name (processor);
602 row[columns.processor] = processor;
604 show_processor_active (processor);
606 processor_active_connections.push_back (processor->ActiveChanged.connect (bind (mem_fun(*this, &ProcessorBox::show_processor_active), boost::weak_ptr<Processor>(processor))));
607 processor_name_connections.push_back (processor->NameChanged.connect (bind (mem_fun(*this, &ProcessorBox::show_processor_name), boost::weak_ptr<Processor>(processor))));
611 ProcessorBox::processor_name (boost::weak_ptr<Processor> weak_processor)
613 boost::shared_ptr<Processor> processor (weak_processor.lock());
619 boost::shared_ptr<Send> send;
622 if (!processor->active()) {
626 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
630 /* grab the send name out of its overall name */
632 string::size_type lbracket, rbracket;
633 lbracket = send->name().find ('[');
634 rbracket = send->name().find (']');
638 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
641 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
649 name_display += processor->name();
652 name_display += PBD::short_version (processor->name(), 5);
658 if (!processor->active()) {
666 ProcessorBox::build_processor_tooltip (EventBox& box, string start)
670 Gtk::TreeModel::Children children = model->children();
671 for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
672 Gtk::TreeModel::Row row = *iter;
674 tip += row[columns.text];
676 ARDOUR_UI::instance()->tooltips().set_tip (box, tip);
680 ProcessorBox::show_processor_name (boost::weak_ptr<Processor> processor)
682 ENSURE_GUI_THREAD(bind (mem_fun(*this, &ProcessorBox::show_processor_name), processor));
683 show_processor_active (processor);
687 ProcessorBox::show_processor_active (boost::weak_ptr<Processor> weak_processor)
689 boost::shared_ptr<Processor> processor (weak_processor.lock());
695 ENSURE_GUI_THREAD(bind (mem_fun(*this, &ProcessorBox::show_processor_active), weak_processor));
697 Gtk::TreeModel::Children children = model->children();
698 Gtk::TreeModel::Children::iterator iter = children.begin();
700 while (iter != children.end()) {
702 boost::shared_ptr<Processor> r = (*iter)[columns.processor];
704 if (r == processor) {
705 (*iter)[columns.text] = processor_name (r);
707 if (processor->active()) {
708 (*iter)[columns.color] = *active_processor_color;
710 (*iter)[columns.color] = *inactive_processor_color;
720 ProcessorBox::row_deleted (const Gtk::TreeModel::Path& path)
722 if (!ignore_delete) {
723 compute_processor_sort_keys ();
728 ProcessorBox::compute_processor_sort_keys ()
730 uint32_t sort_key = 0;
731 Gtk::TreeModel::Children children = model->children();
733 for (Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
734 boost::shared_ptr<Processor> r = (*iter)[columns.processor];
735 r->set_sort_key (sort_key);
739 if (_route->sort_processors ()) {
741 redisplay_processors ();
743 /* now tell them about the problem */
745 ArdourDialog dialog (_("ardour: weird plugin dialog"));
749 You cannot reorder this set of processors\n\
750 in that way because the inputs and\n\
751 outputs do not work correctly."));
753 dialog.get_vbox()->pack_start (label);
754 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
756 dialog.set_name (X_("PluginIODialog"));
757 dialog.set_position (Gtk::WIN_POS_MOUSE);
758 dialog.set_modal (true);
766 ProcessorBox::rename_processors ()
768 vector<boost::shared_ptr<Processor> > to_be_renamed;
770 get_selected_processors (to_be_renamed);
772 if (to_be_renamed.empty()) {
776 for (vector<boost::shared_ptr<Processor> >::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
777 rename_processor (*i);
782 ProcessorBox::cut_processors ()
784 vector<boost::shared_ptr<Processor> > to_be_removed;
785 XMLNode* node = new XMLNode (X_("cut"));
787 get_selected_processors (to_be_removed);
789 if (to_be_removed.empty()) {
793 no_processor_redisplay = true;
794 for (vector<boost::shared_ptr<Processor> >::iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
795 // Do not cut inserts
796 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
797 (boost::dynamic_pointer_cast<Send>((*i)) != 0)) {
799 void* gui = (*i)->get_gui ();
802 static_cast<Gtk::Widget*>(gui)->hide ();
805 XMLNode& child ((*i)->get_state());
807 if (_route->remove_processor (*i) == 0) {
809 node->add_child_nocopy (child);
816 _rr_selection.set (node);
818 no_processor_redisplay = false;
819 redisplay_processors ();
823 ProcessorBox::copy_processors ()
825 vector<boost::shared_ptr<Processor> > to_be_copied;
826 XMLNode* node = new XMLNode (X_("copy"));
828 get_selected_processors (to_be_copied);
830 if (to_be_copied.empty()) {
834 for (vector<boost::shared_ptr<Processor> >::iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
835 // Do not copy inserts
836 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
837 (boost::dynamic_pointer_cast<Send>((*i)) != 0)) {
838 node->add_child_nocopy ((*i)->get_state());
842 _rr_selection.set (node);
846 ProcessorBox::delete_processors ()
848 vector<boost::shared_ptr<Processor> > to_be_deleted;
850 get_selected_processors (to_be_deleted);
852 if (to_be_deleted.empty()) {
856 for (vector<boost::shared_ptr<Processor> >::iterator i = to_be_deleted.begin(); i != to_be_deleted.end(); ++i) {
858 void* gui = (*i)->get_gui ();
861 static_cast<Gtk::Widget*>(gui)->hide ();
864 _route->remove_processor(*i);
867 no_processor_redisplay = false;
868 redisplay_processors ();
872 ProcessorBox::idle_delete_processor (boost::weak_ptr<Processor> weak_processor)
874 boost::shared_ptr<Processor> processor (weak_processor.lock());
880 /* NOT copied to _mixer.selection() */
882 no_processor_redisplay = true;
883 _route->remove_processor (processor);
884 no_processor_redisplay = false;
885 redisplay_processors ();
891 ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
893 ArdourPrompter name_prompter (true);
895 name_prompter.set_prompt (_("rename processor"));
896 name_prompter.set_initial_text (processor->name());
897 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
898 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
899 name_prompter.show_all ();
901 switch (name_prompter.run ()) {
903 case Gtk::RESPONSE_ACCEPT:
904 name_prompter.get_result (result);
905 if (result.length()) {
906 processor->set_name (result);
915 ProcessorBox::paste_processors ()
917 if (_rr_selection.processors.empty()) {
921 cerr << "paste from node called " << _rr_selection.processors.get_node().name() << endl;
923 paste_processor_state (_rr_selection.processors.get_node());
927 ProcessorBox::paste_processor_list (const list<boost::shared_ptr<Processor> >& processors)
929 list<boost::shared_ptr<Processor> > copies;
931 for (list<boost::shared_ptr<Processor> >::const_iterator i = processors.begin(); i != processors.end(); ++i) {
933 boost::shared_ptr<Processor> copy = Processor::clone (*i);
935 copy->set_placement (_placement);
936 copies.push_back (copy);
939 if (_route->add_processors (copies)) {
942 "Copying the set of processors on the clipboard failed,\n\
943 probably because the I/O configuration of the plugins\n\
944 could not match the configuration of this track.");
945 MessageDialog am (msg);
951 ProcessorBox::paste_processor_state (const XMLNode& node)
954 XMLNodeConstIterator niter;
955 list<boost::shared_ptr<Processor> > copies;
957 nlist = node.children();
959 cerr << "Pasting processor selection containing " << nlist.size() << endl;
965 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
966 cerr << "try using " << (*niter)->name() << endl;
967 XMLProperty const * type = (*niter)->property ("type");
970 if (type->value() == "send") {
972 Send::make_unique (n, _session);
973 copies.push_back (boost::shared_ptr<Processor> (new Send (_session, n)));
975 copies.push_back (boost::shared_ptr<Processor> (new PluginInsert (_session, **niter)));
979 cerr << "plugin insert constructor failed\n";
983 if (_route->add_processors (copies)) {
986 "Copying the set of processors on the clipboard failed,\n\
987 probably because the I/O configuration of the plugins\n\
988 could not match the configuration of this track.");
989 MessageDialog am (msg);
995 ProcessorBox::activate_processor (boost::shared_ptr<Processor> r)
1001 ProcessorBox::deactivate_processor (boost::shared_ptr<Processor> r)
1007 ProcessorBox::get_selected_processors (vector<boost::shared_ptr<Processor> >& processors)
1009 vector<Gtk::TreeModel::Path> pathlist = processor_display.get_selection()->get_selected_rows();
1011 for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter) {
1012 processors.push_back ((*(model->get_iter(*iter)))[columns.processor]);
1017 ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::shared_ptr<Processor>))
1019 vector<Gtk::TreeModel::Path> pathlist = processor_display.get_selection()->get_selected_rows();
1021 for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter) {
1022 boost::shared_ptr<Processor> processor = (*(model->get_iter(*iter)))[columns.processor];
1023 (this->*method)(processor);
1028 ProcessorBox::clone_processors ()
1030 RouteSelection& routes (_rr_selection.routes);
1032 if (!routes.empty()) {
1033 if (_route->copy_processors (*routes.front(), _placement)) {
1035 "Copying the set of processors on the clipboard failed,\n\
1036 probably because the I/O configuration of the plugins\n\
1037 could not match the configuration of this track.");
1038 MessageDialog am (msg);
1045 ProcessorBox::all_processors_active (bool state)
1047 _route->all_processors_active (_placement, state);
1051 ProcessorBox::ab_plugins ()
1053 _route->ab_plugins (ab_direction);
1054 ab_direction = !ab_direction;
1059 ProcessorBox::clear_processors ()
1062 vector<string> choices;
1064 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
1065 if (_placement == PreFader) {
1066 prompt = _("Do you really want to remove all pre-fader processors from this track?\n"
1067 "(this cannot be undone)");
1069 prompt = _("Do you really want to remove all post-fader processors from this track?\n"
1070 "(this cannot be undone)");
1073 if (_placement == PreFader) {
1074 prompt = _("Do you really want to remove all pre-fader processors from this bus?\n"
1075 "(this cannot be undone)");
1077 prompt = _("Do you really want to remove all post-fader processors from this bus?\n"
1078 "(this cannot be undone)");
1082 choices.push_back (_("Cancel"));
1083 choices.push_back (_("Yes, remove them all"));
1085 Gtkmm2ext::Choice prompter (prompt, choices);
1087 if (prompter.run () == 1) {
1088 _route->clear_processors (_placement);
1093 ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
1095 boost::shared_ptr<Send> send;
1096 boost::shared_ptr<PluginInsert> plugin_insert;
1097 boost::shared_ptr<PortInsert> port_insert;
1100 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
1102 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
1107 if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
1109 if (!_session.engine().connected()) {
1113 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
1115 SendUIWindow *send_ui;
1117 if (send->get_gui() == 0) {
1119 send_ui = new SendUIWindow (send, _session);
1121 WindowTitle title(Glib::get_application_name());
1122 title += send->name();
1123 send_ui->set_title (title.get_string());
1125 send->set_gui (send_ui);
1128 send_ui = reinterpret_cast<SendUIWindow *> (send->get_gui());
1133 } else if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor)) != 0) {
1135 PluginUIWindow *plugin_ui;
1137 /* these are both allowed to be null */
1139 Container* toplevel = get_toplevel();
1140 Window* win = dynamic_cast<Gtk::Window*>(toplevel);
1142 if (plugin_insert->get_gui() == 0) {
1144 plugin_ui = new PluginUIWindow (win, plugin_insert);
1146 WindowTitle title(Glib::get_application_name());
1147 title += generate_processor_title (plugin_insert);
1148 plugin_ui->set_title (title.get_string());
1150 plugin_insert->set_gui (plugin_ui);
1152 // change window title when route name is changed
1153 _route->NameChanged.connect (bind (mem_fun(*this, &ProcessorBox::route_name_changed), plugin_ui, boost::weak_ptr<PluginInsert> (plugin_insert)));
1156 plugin_ui = reinterpret_cast<PluginUIWindow *> (plugin_insert->get_gui());
1157 plugin_ui->set_parent (win);
1162 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
1164 if (!_session.engine().connected()) {
1165 MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible"));
1170 PortInsertWindow *io_selector;
1172 if (port_insert->get_gui() == 0) {
1173 io_selector = new PortInsertWindow (_session, port_insert);
1174 port_insert->set_gui (io_selector);
1177 io_selector = reinterpret_cast<PortInsertWindow *> (port_insert->get_gui());
1180 gidget = io_selector;
1184 if (gidget->is_visible()) {
1185 gidget->get_window()->raise ();
1187 gidget->show_all ();
1194 ProcessorBox::enter_box (GdkEventCrossing *ev, ProcessorBox* rb)
1196 switch (ev->detail) {
1197 case GDK_NOTIFY_INFERIOR:
1200 case GDK_NOTIFY_VIRTUAL:
1204 _current_processor_box = rb;
1211 ProcessorBox::register_actions ()
1213 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("processormenu"));
1214 Glib::RefPtr<Action> act;
1217 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin"), sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
1219 act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"), sigc::ptr_fun (ProcessorBox::rb_choose_insert));
1220 ActionManager::jack_sensitive_actions.push_back (act);
1221 act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New Send ..."), sigc::ptr_fun (ProcessorBox::rb_choose_send));
1222 ActionManager::jack_sensitive_actions.push_back (act);
1224 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear"), sigc::ptr_fun (ProcessorBox::rb_clear));
1226 /* standard editing stuff */
1227 act = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"), sigc::ptr_fun (ProcessorBox::rb_cut));
1228 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1229 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"), sigc::ptr_fun (ProcessorBox::rb_copy));
1230 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1232 act = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"), sigc::ptr_fun (ProcessorBox::rb_delete));
1233 ActionManager::plugin_selection_sensitive_actions.push_back(act); // ??
1235 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"), sigc::ptr_fun (ProcessorBox::rb_paste));
1236 act = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"), sigc::ptr_fun (ProcessorBox::rb_rename));
1237 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1238 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"), sigc::ptr_fun (ProcessorBox::rb_select_all));
1239 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"), sigc::ptr_fun (ProcessorBox::rb_deselect_all));
1242 act = ActionManager::register_action (popup_act_grp, X_("activate"), _("Activate"), sigc::ptr_fun (ProcessorBox::rb_activate));
1243 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1244 act = ActionManager::register_action (popup_act_grp, X_("deactivate"), _("Deactivate"), sigc::ptr_fun (ProcessorBox::rb_deactivate));
1245 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1246 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate all"), sigc::ptr_fun (ProcessorBox::rb_activate_all));
1247 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate all"), sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
1250 act = ActionManager::register_action (popup_act_grp, X_("edit"), _("Edit"), sigc::ptr_fun (ProcessorBox::rb_edit));
1251 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1253 ActionManager::add_action_group (popup_act_grp);
1259 ProcessorBox::rb_choose_plugin ()
1261 if (_current_processor_box == 0) {
1264 _current_processor_box->choose_plugin ();
1268 ProcessorBox::rb_choose_insert ()
1270 if (_current_processor_box == 0) {
1273 _current_processor_box->choose_insert ();
1277 ProcessorBox::rb_choose_send ()
1279 if (_current_processor_box == 0) {
1282 _current_processor_box->choose_send ();
1286 ProcessorBox::rb_clear ()
1288 if (_current_processor_box == 0) {
1292 _current_processor_box->clear_processors ();
1296 ProcessorBox::rb_cut ()
1298 if (_current_processor_box == 0) {
1302 _current_processor_box->cut_processors ();
1306 ProcessorBox::rb_delete ()
1308 if (_current_processor_box == 0) {
1312 _current_processor_box->delete_processors ();
1316 ProcessorBox::rb_copy ()
1318 if (_current_processor_box == 0) {
1321 _current_processor_box->copy_processors ();
1325 ProcessorBox::rb_paste ()
1327 if (_current_processor_box == 0) {
1331 _current_processor_box->paste_processors ();
1335 ProcessorBox::rb_rename ()
1337 if (_current_processor_box == 0) {
1340 _current_processor_box->rename_processors ();
1344 ProcessorBox::rb_select_all ()
1346 if (_current_processor_box == 0) {
1350 _current_processor_box->select_all_processors ();
1354 ProcessorBox::rb_deselect_all ()
1356 if (_current_processor_box == 0) {
1360 _current_processor_box->deselect_all_processors ();
1364 ProcessorBox::rb_activate ()
1366 if (_current_processor_box == 0) {
1370 _current_processor_box->for_selected_processors (&ProcessorBox::activate_processor);
1374 ProcessorBox::rb_deactivate ()
1376 if (_current_processor_box == 0) {
1379 _current_processor_box->for_selected_processors (&ProcessorBox::deactivate_processor);
1383 ProcessorBox::rb_activate_all ()
1385 if (_current_processor_box == 0) {
1389 _current_processor_box->all_processors_active (true);
1393 ProcessorBox::rb_deactivate_all ()
1395 if (_current_processor_box == 0) {
1398 _current_processor_box->all_processors_active (false);
1402 ProcessorBox::rb_edit ()
1404 if (_current_processor_box == 0) {
1408 _current_processor_box->for_selected_processors (&ProcessorBox::edit_processor);
1412 ProcessorBox::route_name_changed (PluginUIWindow* plugin_ui, boost::weak_ptr<PluginInsert> wpi)
1414 ENSURE_GUI_THREAD(bind (mem_fun (*this, &ProcessorBox::route_name_changed), plugin_ui, wpi));
1416 boost::shared_ptr<PluginInsert> pi (wpi.lock());
1419 WindowTitle title(Glib::get_application_name());
1420 title += generate_processor_title (pi);
1421 plugin_ui->set_title (title.get_string());
1426 ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
1428 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
1429 string::size_type email_pos;
1431 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
1432 maker = maker.substr (0, email_pos - 1);
1435 if (maker.length() > 32) {
1436 maker = maker.substr (0, 32);
1440 return string_compose(_("%1: %2 (by %3)"), _route->name(), pi->name(), maker);