change PropertyChange from a bitfield into a real object, with all the many widesprea...
[ardour.git] / gtk2_ardour / processor_box.cc
index 0f4da400ca436482a46888dcce8a18d2a70e6b88..c4d01e4458479078135821e4cc178d2ad0975df0 100644 (file)
@@ -80,7 +80,6 @@ class AUPluginUI;
 #endif
 
 using namespace std;
-using namespace sigc;
 using namespace ARDOUR;
 using namespace PBD;
 using namespace Gtk;
@@ -105,10 +104,10 @@ ProcessorEntry::ProcessorEntry (boost::shared_ptr<Processor> p, Width w)
        _name.set_padding (2, 2);
        
        _active.set_active (_processor->active ());
-       _active.signal_toggled().connect (mem_fun (*this, &ProcessorEntry::active_toggled));
+       _active.signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::active_toggled));
        
-       _processor->ActiveChanged.connect (mem_fun (*this, &ProcessorEntry::processor_active_changed));
-       _processor->NameChanged.connect (mem_fun (*this, &ProcessorEntry::processor_name_changed));
+       _processor->ActiveChanged.connect (active_connection, boost::bind (&ProcessorEntry::processor_active_changed, this), gui_context());
+       _processor->PropertyChanged.connect (name_connection, 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
@@ -229,8 +230,8 @@ SendProcessorEntry::SendProcessorEntry (boost::shared_ptr<Send> s, Width w)
        _fader.set_controllable (_send->amp()->gain_control ());
        _vbox.pack_start (_fader);
 
-       _adjustment.signal_value_changed().connect (mem_fun (*this, &SendProcessorEntry::gain_adjusted));
-       _send->amp()->gain_control()->Changed.connect (mem_fun (*this, &SendProcessorEntry::show_gain));
+       _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &SendProcessorEntry::gain_adjusted));
+       _send->amp()->gain_control()->Changed.connect (send_gain_connection, boost::bind (&SendProcessorEntry::show_gain, this), gui_context());
        show_gain ();
 }
 
@@ -244,7 +245,7 @@ SendProcessorEntry::setup_slider_pix ()
 void
 SendProcessorEntry::show_gain ()
 {
-       ENSURE_GUI_THREAD (mem_fun (*this, &SendProcessorEntry::show_gain));
+       ENSURE_GUI_THREAD (*this, &SendProcessorEntry::show_gain)
        
        float const value = gain_to_slider_position (_send->amp()->gain ());
 
@@ -271,16 +272,17 @@ SendProcessorEntry::set_pixel_width (int p)
        _fader.set_fader_length (p);
 }
 
-ProcessorBox::ProcessorBox (ARDOUR::Session& sess, sigc::slot<PluginSelector*> get_plugin_selector,
-                       RouteRedirectSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
-       : _session(sess)
-       , _parent_strip (parent)
+ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> 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;
@@ -295,18 +297,18 @@ ProcessorBox::ProcessorBox (ARDOUR::Session& sess, sigc::slot<PluginSelector*> g
        processor_display.set_size_request (48, -1);
        processor_display.set_data ("processorbox", this);
 
-       processor_display.signal_enter_notify_event().connect (mem_fun(*this, &ProcessorBox::enter_notify), false);
-       processor_display.signal_leave_notify_event().connect (mem_fun(*this, &ProcessorBox::leave_notify), false);
+       processor_display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::enter_notify), false);
+       processor_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &ProcessorBox::leave_notify), false);
 
-       processor_display.signal_key_press_event().connect (mem_fun(*this, &ProcessorBox::processor_key_press_event));
-       processor_display.signal_key_release_event().connect (mem_fun(*this, &ProcessorBox::processor_key_release_event));
+       processor_display.signal_key_press_event().connect (sigc::mem_fun(*this, &ProcessorBox::processor_key_press_event));
+       processor_display.signal_key_release_event().connect (sigc::mem_fun(*this, &ProcessorBox::processor_key_release_event));
 
-       processor_display.ButtonPress.connect (mem_fun (*this, &ProcessorBox::processor_button_press_event));
-       processor_display.ButtonRelease.connect (mem_fun (*this, &ProcessorBox::processor_button_release_event));
+       processor_display.ButtonPress.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_press_event));
+       processor_display.ButtonRelease.connect (sigc::mem_fun (*this, &ProcessorBox::processor_button_release_event));
 
-       processor_display.Reordered.connect (mem_fun (*this, &ProcessorBox::reordered));
-       processor_display.DropFromAnotherBox.connect (mem_fun (*this, &ProcessorBox::object_drop));
-       processor_display.SelectionChanged.connect (mem_fun (*this, &ProcessorBox::selection_changed));
+       processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
+       processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
+       processor_display.SelectionChanged.connect (sigc::mem_fun (*this, &ProcessorBox::selection_changed));
 }
 
 ProcessorBox::~ProcessorBox ()
@@ -316,17 +318,19 @@ ProcessorBox::~ProcessorBox ()
 void
 ProcessorBox::set_route (boost::shared_ptr<Route> r)
 {
-       connections.clear ();
+       if (_route == r) {
+               return;
+       }
+       
+       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 (mem_fun (*this, &ProcessorBox::route_processors_changed)));
-       connections.push_back (_route->GoingAway.connect (
-                       mem_fun (*this, &ProcessorBox::route_going_away)));
-       connections.push_back (_route->NameChanged.connect (
-                       mem_fun(*this, &ProcessorBox::route_name_changed)));
+       _route->processors_changed.connect (connections, ui_bind (&ProcessorBox::route_processors_changed, this, _1), gui_context());
+       _route->DropReferences.connect (connections, boost::bind (&ProcessorBox::route_going_away, this), gui_context());
+       _route->PropertyChanged.connect (connections, ui_bind (&ProcessorBox::route_property_changed, this, _1), gui_context());
 
        redisplay_processors ();
 }
@@ -427,14 +431,14 @@ ProcessorBox::build_send_action_menu ()
        send_action_menu->set_name ("ArdourContextMenu");
        MenuList& items = send_action_menu->items();
 
-       items.push_back (MenuElem (_("New send"), mem_fun(*this, &ProcessorBox::new_send)));
-       items.push_back (MenuElem (_("Show send controls"), mem_fun(*this, &ProcessorBox::show_send_controls)));
+       items.push_back (MenuElem (_("New send"), sigc::mem_fun(*this, &ProcessorBox::new_send)));
+       items.push_back (MenuElem (_("Show send controls"), sigc::mem_fun(*this, &ProcessorBox::show_send_controls)));
 }
 
 Gtk::Menu*
 ProcessorBox::build_possible_aux_menu ()
 {
-       boost::shared_ptr<RouteList> rl = _session.get_routes_with_internal_returns();
+       boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
 
        if (rl->empty()) {
                return 0;
@@ -446,7 +450,7 @@ ProcessorBox::build_possible_aux_menu ()
 
        for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
                if (!_route->internal_send_for (*r) && *r != _route) {
-                       items.push_back (MenuElem ((*r)->name(), bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
+                       items.push_back (MenuElem ((*r)->name(), sigc::bind (sigc::ptr_fun (ProcessorBox::rb_choose_aux), boost::weak_ptr<Route>(*r))));
                }
        }
 
@@ -627,7 +631,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);
                }
@@ -659,8 +663,8 @@ ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry
 
        if (processor && Keyboard::is_delete_event (ev)) {
 
-               Glib::signal_idle().connect (bind (
-                               mem_fun(*this, &ProcessorBox::idle_delete_processor),
+               Glib::signal_idle().connect (sigc::bind (
+                               sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
                                boost::weak_ptr<Processor>(processor)));
                ret = true;
 
@@ -744,7 +748,7 @@ ProcessorBox::use_plugins (const SelectedPlugins& plugins)
 {
        for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
 
-               boost::shared_ptr<Processor> processor (new PluginInsert (_session, *p));
+               boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
 
                Route::ProcessorStreams err_streams;
 
@@ -809,18 +813,18 @@ ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
 void
 ProcessorBox::choose_insert ()
 {
-       boost::shared_ptr<Processor> processor (new PortInsert (_session, _route->mute_master()));
+       boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->mute_master()));
        _route->add_processor (processor, _placement);
 }
 
 void
 ProcessorBox::choose_send ()
 {
-       boost::shared_ptr<Send> send (new Send (_session, _route->mute_master()));
+       boost::shared_ptr<Send> 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 */
@@ -846,8 +850,8 @@ ProcessorBox::choose_send ()
        */
        _processor_being_created = send;
 
-       ios->selector().Finished.connect (bind (
-                       mem_fun(*this, &ProcessorBox::send_io_finished),
+       ios->selector().Finished.connect (sigc::bind (
+                       sigc::mem_fun(*this, &ProcessorBox::send_io_finished),
                        boost::weak_ptr<Processor>(send), ios));
 
 }
@@ -924,7 +928,7 @@ ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
        boost::shared_ptr<RouteList> rlist (new RouteList);
        rlist->push_back (_route);
 
-       _session.add_internal_sends (target, PreFader, rlist);
+       _session->add_internal_sends (target, PreFader, rlist);
 }
 
 void
@@ -941,7 +945,7 @@ ProcessorBox::route_processors_changed (RouteProcessorChange c)
 void
 ProcessorBox::redisplay_processors ()
 {
-       ENSURE_GUI_THREAD (mem_fun(*this, &ProcessorBox::redisplay_processors));
+       ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors)
 
        if (no_processor_redisplay) {
                return;
@@ -949,7 +953,7 @@ ProcessorBox::redisplay_processors ()
 
        processor_display.clear ();
 
-       _route->foreach_processor (mem_fun (*this, &ProcessorBox::add_processor_to_display));
+       _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
 
        build_processor_tooltip (processor_eventbox, _("Inserts, sends & plugins:"));
 }
@@ -986,7 +990,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,10 +1021,11 @@ ProcessorBox::compute_processor_sort_keys ()
                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);
 
@@ -1216,7 +1221,7 @@ ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
        case Gtk::RESPONSE_ACCEPT:
                name_prompter.get_result (result);
                if (result.length()) {
-                       if (_session.route_by_name (result)) {
+                       if (_session->route_by_name (result)) {
                                ARDOUR_UI::instance()->popup_error (_("A track already exists with that name."));
                                return;
                        }
@@ -1276,20 +1281,20 @@ 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);
+                               p.reset (new Send (*_session, _route->mute_master(), n));
 
                        } else if (type->value() == "return") {
 
                                XMLNode n (**niter);
-                               Return::make_unique (n, _session);
-                               p.reset (new Return (_session, **niter));
+                               Return::make_unique (n, *_session);
+                               p.reset (new Return (*_session, **niter));
 
                        } 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, **niter));
                        }
 
                        copies.push_back (p);
@@ -1371,7 +1376,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);
@@ -1396,7 +1401,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);
@@ -1421,7 +1426,7 @@ ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
 
        if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
 
-               if (!_session.engine().connected()) {
+               if (!_session->engine().connected()) {
                        return;
                }
 
@@ -1446,7 +1451,7 @@ ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
 
        } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
 
-               if (!_session.engine().connected()) {
+               if (!_session->engine().connected()) {
                        return;
                }
 
@@ -1490,7 +1495,7 @@ ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
 
        } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (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;
@@ -1761,9 +1766,13 @@ ProcessorBox::rb_edit ()
 }
 
 void
-ProcessorBox::route_name_changed ()
+ProcessorBox::route_property_changed (const PropertyChange& what_changed)
 {
-       ENSURE_GUI_THREAD (mem_fun (*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> processor;
        boost::shared_ptr<PluginInsert> plugin_insert;