X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fprocessor_box.cc;h=cc322df13d060a00583ed68ee4f7c0df7cf1f13f;hb=3600f60a030de8bd5cca3fa983f3e926a084a1c0;hp=900579e419b42ea975213ecb61c090469eeecb6d;hpb=64dc5427e4f5339a16a018692dd94f476c53cae9;p=ardour.git diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index 900579e419..cc322df13d 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -37,12 +37,10 @@ #include #include #include -#include #include #include "ardour/amp.h" #include "ardour/ardour.h" -#include "ardour/audio_diskstream.h" #include "ardour/audio_track.h" #include "ardour/audioengine.h" #include "ardour/internal_send.h" @@ -80,7 +78,6 @@ class AUPluginUI; #endif using namespace std; -using namespace sigc; using namespace ARDOUR; using namespace PBD; using namespace Gtk; @@ -89,6 +86,8 @@ using namespace Gtkmm2ext; ProcessorBox* ProcessorBox::_current_processor_box = 0; RefPtr ProcessorBox::paste_action; +RefPtr ProcessorBox::cut_action; +RefPtr ProcessorBox::rename_action; Glib::RefPtr SendProcessorEntry::_slider; ProcessorEntry::ProcessorEntry (boost::shared_ptr p, Width w) @@ -107,8 +106,8 @@ ProcessorEntry::ProcessorEntry (boost::shared_ptr p, Width w) _active.set_active (_processor->active ()); _active.signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::active_toggled)); - _processor->ActiveChanged.connect (sigc::mem_fun (*this, &ProcessorEntry::processor_active_changed)); - _processor->NameChanged.connect (sigc::mem_fun (*this, &ProcessorEntry::processor_name_changed)); + _processor->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_active_changed, this), gui_context()); + _processor->PropertyChanged.connect (name_connection, invalidator (*this), ui_bind (&ProcessorEntry::processor_property_changed, this, _1), gui_context()); } EventBox& @@ -164,9 +163,11 @@ ProcessorEntry::processor_active_changed () } void -ProcessorEntry::processor_name_changed () +ProcessorEntry::processor_property_changed (const PropertyChange& what_changed) { - _name.set_text (name ()); + if (what_changed.contains (ARDOUR::Properties::name)) { + _name.set_text (name ()); + } } string @@ -175,10 +176,6 @@ ProcessorEntry::name () const boost::shared_ptr send; string name_display; - if (!_processor->active()) { - name_display = " ("; - } - if ((send = boost::dynamic_pointer_cast (_processor)) != 0 && !boost::dynamic_pointer_cast(_processor)) { @@ -212,10 +209,6 @@ ProcessorEntry::name () const } - if (!_processor->active()) { - name_display += ')'; - } - return name_display; } @@ -230,7 +223,7 @@ SendProcessorEntry::SendProcessorEntry (boost::shared_ptr s, Width w) _vbox.pack_start (_fader); _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &SendProcessorEntry::gain_adjusted)); - _send->amp()->gain_control()->Changed.connect (sigc::mem_fun (*this, &SendProcessorEntry::show_gain)); + _send->amp()->gain_control()->Changed.connect (send_gain_connection, invalidator (*this), boost::bind (&SendProcessorEntry::show_gain, this), gui_context()); show_gain (); } @@ -271,16 +264,17 @@ SendProcessorEntry::set_pixel_width (int p) _fader.set_fader_length (p); } -ProcessorBox::ProcessorBox (ARDOUR::Session& sess, sigc::slot get_plugin_selector, - RouteRedirectSelection& rsel, MixerStrip* parent, bool owner_is_mixer) - : _session(sess) - , _parent_strip (parent) +ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function get_plugin_selector, + RouteRedirectSelection& rsel, MixerStrip* parent, bool owner_is_mixer) + : _parent_strip (parent) , _owner_is_mixer (owner_is_mixer) , ab_direction (true) , _get_plugin_selector (get_plugin_selector) , _placement(PreFader) , _rr_selection(rsel) { + set_session (sess); + _width = Wide; processor_menu = 0; send_action_menu = 0; @@ -320,17 +314,15 @@ ProcessorBox::set_route (boost::shared_ptr r) return; } - connections.clear (); + connections.drop_connections(); /* new route: any existing block on processor redisplay must be meaningless */ no_processor_redisplay = false; _route = r; - connections.push_back (_route->processors_changed.connect (sigc::mem_fun (*this, &ProcessorBox::route_processors_changed))); - connections.push_back (_route->GoingAway.connect ( - sigc::mem_fun (*this, &ProcessorBox::route_going_away))); - connections.push_back (_route->NameChanged.connect ( - sigc::mem_fun(*this, &ProcessorBox::route_name_changed))); + _route->processors_changed.connect (connections, invalidator (*this), ui_bind (&ProcessorBox::route_processors_changed, this, _1), gui_context()); + _route->DropReferences.connect (connections, invalidator (*this), boost::bind (&ProcessorBox::route_going_away, this), gui_context()); + _route->PropertyChanged.connect (connections, invalidator (*this), ui_bind (&ProcessorBox::route_property_changed, this, _1), gui_context()); redisplay_processors (); } @@ -438,7 +430,7 @@ ProcessorBox::build_send_action_menu () Gtk::Menu* ProcessorBox::build_possible_aux_menu () { - boost::shared_ptr rl = _session.get_routes_with_internal_returns(); + boost::shared_ptr rl = _session->get_routes_with_internal_returns(); if (rl->empty()) { return 0; @@ -494,6 +486,7 @@ ProcessorBox::show_processor_menu (gint arg) } } + cut_action->set_sensitive (can_cut()); paste_action->set_sensitive (!_rr_selection.processors.empty()); processor_menu->popup (1, arg); @@ -631,7 +624,7 @@ ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) { - if (_session.engine().connected()) { + if (_session->engine().connected()) { /* XXX giving an error message here is hard, because we may be in the midst of a button press */ edit_processor (processor); } @@ -723,6 +716,11 @@ ProcessorBox::selection_changed () { bool sensitive = (processor_display.selection().empty()) ? false : true; ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive); + + /* disallow rename for multiple selections and for plugin inserts */ + rename_action->set_sensitive ( + processor_display.selection().size() == 1 && boost::dynamic_pointer_cast (processor_display.selection().front()->processor()) == 0 + ); } void @@ -743,12 +741,13 @@ ProcessorBox::choose_plugin () _get_plugin_selector()->set_interested_object (*this); } -void +/** @return true if an error occurred, otherwise false */ +bool ProcessorBox::use_plugins (const SelectedPlugins& plugins) { for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) { - boost::shared_ptr processor (new PluginInsert (_session, *p)); + boost::shared_ptr processor (new PluginInsert (*_session, *p)); Route::ProcessorStreams err_streams; @@ -758,6 +757,7 @@ ProcessorBox::use_plugins (const SelectedPlugins& plugins) if (_route->add_processor (processor, _placement, &err_streams)) { weird_plugin_dialog (**p, err_streams); + return true; // XXX SHAREDPTR delete plugin here .. do we even need to care? } else { @@ -766,12 +766,14 @@ ProcessorBox::use_plugins (const SelectedPlugins& plugins) } } } + + return false; } void ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams) { - ArdourDialog dialog (_("ardour: weird plugin dialog")); + ArdourDialog dialog (_("Plugin Incompatibility")); Label label; string text = string_compose(_("You attempted to add the plugin \"%1\" at index %2.\n"), @@ -796,7 +798,7 @@ ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams) text += string_compose("\t%1 ", streams.count.n_audio()) + _("audio channel(s)\n"); } - text += _("\nArdour is unable to insert this plugin here.\n"); + text += string_compose (_("\n%1 is unable to insert this plugin here.\n"), PROGRAM_NAME); label.set_text(text); dialog.get_vbox()->pack_start (label); @@ -813,18 +815,18 @@ ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams) void ProcessorBox::choose_insert () { - boost::shared_ptr processor (new PortInsert (_session, _route->mute_master())); + boost::shared_ptr processor (new PortInsert (*_session, _route->mute_master())); _route->add_processor (processor, _placement); } void ProcessorBox::choose_send () { - boost::shared_ptr send (new Send (_session, _route->mute_master())); + boost::shared_ptr send (new Send (*_session, _route->mute_master())); /* make an educated guess at the initial number of outputs for the send */ - ChanCount outs = (_session.master_out()) - ? _session.master_out()->n_outputs() + ChanCount outs = (_session->master_out()) + ? _session->master_out()->n_outputs() : _route->n_outputs(); /* XXX need processor lock on route */ @@ -842,7 +844,7 @@ ProcessorBox::choose_send () is closed. */ - IOSelectorWindow *ios = new IOSelectorWindow (&_session, send->output(), true); + IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true); ios->show_all (); /* keep a reference to the send so it doesn't get deleted while @@ -928,7 +930,7 @@ ProcessorBox::choose_aux (boost::weak_ptr wr) boost::shared_ptr rlist (new RouteList); rlist->push_back (_route); - _session.add_internal_sends (target, PreFader, rlist); + _session->add_internal_sends (target, PreFader, rlist); } void @@ -990,7 +992,7 @@ ProcessorBox::build_processor_tooltip (EventBox& box, string start) tip += (*i)->processor()->name(); } - ARDOUR_UI::instance()->tooltips().set_tip (box, tip); + ARDOUR_UI::instance()->set_tip (box, tip); } void @@ -1017,14 +1019,15 @@ ProcessorBox::compute_processor_sort_keys () /* now tell them about the problem */ - ArdourDialog dialog (_("ardour: weird plugin dialog")); + ArdourDialog dialog (_("Plugin Incompatibility")); Label label; label.set_text (_("\ -You cannot reorder this set of processors\n\ +You cannot reorder these plugins/sends/inserts\n\ in that way because the inputs and\n\ -outputs do not work correctly.")); +outputs will not work correctly.")); + dialog.get_vbox()->set_border_width (12); dialog.get_vbox()->pack_start (label); dialog.add_button (Stock::OK, RESPONSE_ACCEPT); @@ -1053,6 +1056,27 @@ ProcessorBox::rename_processors () } } +bool +ProcessorBox::can_cut () const +{ + vector > sel; + + get_selected_processors (sel); + + /* cut_processors () does not cut inserts */ + + for (vector >::const_iterator i = sel.begin (); i != sel.end (); ++i) { + + if (boost::dynamic_pointer_cast((*i)) != 0 || + (boost::dynamic_pointer_cast((*i)) != 0) || + (boost::dynamic_pointer_cast((*i)) != 0)) { + return true; + } + } + + return false; +} + void ProcessorBox::cut_processors () { @@ -1220,11 +1244,27 @@ ProcessorBox::rename_processor (boost::shared_ptr processor) case Gtk::RESPONSE_ACCEPT: name_prompter.get_result (result); if (result.length()) { - if (_session.route_by_name (result)) { - ARDOUR_UI::instance()->popup_error (_("A track already exists with that name.")); - return; - } - processor->set_name (result); + + int tries = 0; + string test = result; + + while (tries < 100) { + if (_session->io_name_is_legal (test)) { + result = test; + break; + } + tries++; + + test = string_compose ("%1-%2", result, tries); + } + + if (tries < 100) { + processor->set_name (result); + } else { + /* unlikely! */ + ARDOUR_UI::instance()->popup_error + (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result)); + } } break; } @@ -1280,20 +1320,36 @@ ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr } else if (type->value() == "send") { XMLNode n (**niter); - Send::make_unique (n, _session); - p.reset (new Send (_session, _route->mute_master(), n)); + Send::make_unique (n, *_session); + Send* s = new Send (*_session, _route->mute_master()); + if (s->set_state (n, Stateful::loading_state_version)) { + delete s; + return; + } + + p.reset (s); + } else if (type->value() == "return") { XMLNode n (**niter); - Return::make_unique (n, _session); - p.reset (new Return (_session, **niter)); + Return::make_unique (n, *_session); + Return* r = new Return (*_session); + + if (r->set_state (n, Stateful::loading_state_version)) { + delete r; + return; + } + + p.reset (r); } else { /* XXX its a bit limiting to assume that everything else is a plugin. */ - p.reset (new PluginInsert (_session, **niter)); + + p.reset (new PluginInsert (*_session)); + p->set_state (**niter, Stateful::current_state_version); } copies.push_back (p); @@ -1332,10 +1388,10 @@ ProcessorBox::deactivate_processor (boost::shared_ptr r) } void -ProcessorBox::get_selected_processors (ProcSelection& processors) +ProcessorBox::get_selected_processors (ProcSelection& processors) const { - list selection = processor_display.selection (); - for (list::iterator i = selection.begin(); i != selection.end(); ++i) { + const list selection = processor_display.selection (); + for (list::const_iterator i = selection.begin(); i != selection.end(); ++i) { processors.push_back ((*i)->processor ()); } } @@ -1375,7 +1431,7 @@ ProcessorBox::clear_processors () choices.push_back (_("Cancel")); choices.push_back (_("Yes, remove them all")); - Gtkmm2ext::Choice prompter (prompt, choices); + Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices); if (prompter.run () == 1) { _route->clear_processors (PreFader); @@ -1400,7 +1456,7 @@ ProcessorBox::clear_processors (Placement p) choices.push_back (_("Cancel")); choices.push_back (_("Yes, remove them all")); - Gtkmm2ext::Choice prompter (prompt, choices); + Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices); if (prompter.run () == 1) { _route->clear_processors (p); @@ -1425,7 +1481,7 @@ ProcessorBox::edit_processor (boost::shared_ptr processor) if ((send = boost::dynamic_pointer_cast (processor)) != 0) { - if (!_session.engine().connected()) { + if (!_session->engine().connected()) { return; } @@ -1450,7 +1506,7 @@ ProcessorBox::edit_processor (boost::shared_ptr processor) } else if ((retrn = boost::dynamic_pointer_cast (processor)) != 0) { - if (!_session.engine().connected()) { + if (!_session->engine().connected()) { return; } @@ -1494,7 +1550,7 @@ ProcessorBox::edit_processor (boost::shared_ptr processor) } else if ((port_insert = boost::dynamic_pointer_cast (processor)) != 0) { - if (!_session.engine().connected()) { + if (!_session->engine().connected()) { MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible")); msg.run (); return; @@ -1503,7 +1559,7 @@ ProcessorBox::edit_processor (boost::shared_ptr processor) PortInsertWindow *io_selector; if (port_insert->get_gui() == 0) { - io_selector = new PortInsertWindow (&_session, port_insert); + io_selector = new PortInsertWindow (_session, port_insert); port_insert->set_gui (io_selector); } else { @@ -1550,9 +1606,9 @@ ProcessorBox::register_actions () sigc::ptr_fun (ProcessorBox::rb_clear_post)); /* standard editing stuff */ - act = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"), - sigc::ptr_fun (ProcessorBox::rb_cut)); - ActionManager::plugin_selection_sensitive_actions.push_back(act); + cut_action = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"), + sigc::ptr_fun (ProcessorBox::rb_cut)); + ActionManager::plugin_selection_sensitive_actions.push_back(cut_action); act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"), sigc::ptr_fun (ProcessorBox::rb_copy)); ActionManager::plugin_selection_sensitive_actions.push_back(act); @@ -1563,9 +1619,8 @@ ProcessorBox::register_actions () paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"), sigc::ptr_fun (ProcessorBox::rb_paste)); - act = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"), + rename_action = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"), sigc::ptr_fun (ProcessorBox::rb_rename)); - ActionManager::plugin_selection_sensitive_actions.push_back(act); ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"), sigc::ptr_fun (ProcessorBox::rb_select_all)); ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"), @@ -1765,9 +1820,13 @@ ProcessorBox::rb_edit () } void -ProcessorBox::route_name_changed () +ProcessorBox::route_property_changed (const PropertyChange& what_changed) { - ENSURE_GUI_THREAD (*this, &ProcessorBox::route_name_changed) + if (!what_changed.contains (ARDOUR::Properties::name)) { + return; + } + + ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed); boost::shared_ptr processor; boost::shared_ptr plugin_insert;