redesign/reimplement selection knowledge in MackieControlProtocol object
[ardour.git] / libs / surfaces / mackie / strip.cc
index a201d253758d49d29e885242098418466e126592..c43875028916d0c9ce9872f8d8bf372684b4738a 100644 (file)
@@ -44,6 +44,7 @@
 #include "ardour/panner_shell.h"
 #include "ardour/phase_control.h"
 #include "ardour/rc_configuration.h"
+#include "ardour/record_enable_control.h"
 #include "ardour/route.h"
 #include "ardour/session.h"
 #include "ardour/send.h"
@@ -214,19 +215,18 @@ Strip::set_stripable (boost::shared_ptr<Stripable> r, bool /*with_messages*/)
 
        _stripable->gain_control()->Changed.connect(stripable_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_gain_changed, this, false), ui_context());
        _stripable->PropertyChanged.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_property_changed, this, _1), ui_context());
+       _stripable->presentation_info().PropertyChanged.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_property_changed, this, _1), ui_context());
 
-       boost::shared_ptr<Track> trk = boost::dynamic_pointer_cast<ARDOUR::Track>(_stripable);
+       boost::shared_ptr<AutomationControl> rec_enable_control = _stripable->rec_enable_control ();
 
-       if (trk) {
-               _recenable->set_control (trk->rec_enable_control());
-               trk->rec_enable_control()->Changed .connect(stripable_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_record_enable_changed, this), ui_context());
+       if (rec_enable_control) {
+               _recenable->set_control (rec_enable_control);
+               rec_enable_control->Changed.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_record_enable_changed, this), ui_context());
        }
 
        // TODO this works when a currently-banked stripable is made inactive, but not
        // when a stripable is activated which should be currently banked.
 
-       // XXX Stripable
-       // _stripable->active_changed.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_active_changed, this), ui_context());
        _stripable->DropReferences.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_stripable_deleted, this), ui_context());
 
        /* setup legal VPot modes for this stripable */
@@ -276,6 +276,7 @@ Strip::notify_all()
        notify_mute_changed ();
        notify_gain_changed ();
        notify_property_changed (PBD::PropertyChange (ARDOUR::Properties::name));
+       notify_property_changed (PBD::PropertyChange (ARDOUR::Properties::selected));
        notify_panner_azi_changed ();
        notify_panner_width_changed ();
        notify_record_enable_changed ();
@@ -313,12 +314,6 @@ Strip::notify_record_enable_changed ()
        }
 }
 
-void
-Strip::notify_active_changed ()
-{
-       _surface->mcp().refresh_current_bank();
-}
-
 void
 Strip::notify_stripable_deleted ()
 {
@@ -379,11 +374,16 @@ Strip::notify_processor_changed (bool force_update)
 void
 Strip::notify_property_changed (const PropertyChange& what_changed)
 {
-       if (!what_changed.contains (ARDOUR::Properties::name)) {
-               return;
+       if (what_changed.contains (ARDOUR::Properties::name)) {
+               show_stripable_name ();
        }
 
-       show_stripable_name ();
+       if (what_changed.contains (ARDOUR::Properties::selected)) {
+               if (_stripable) {
+                       _surface->write (_select->set_state (_stripable->presentation_info().selected()));
+                       _surface->mcp().update_selected (_stripable, _stripable->presentation_info().selected());
+               }
+       }
 }
 
 void
@@ -1313,19 +1313,6 @@ Strip::unlock_controls ()
        _controls_locked = false;
 }
 
-void
-Strip::gui_selection_changed (const ARDOUR::StrongStripableNotificationList& rl)
-{
-       for (ARDOUR::StrongStripableNotificationList::const_iterator i = rl.begin(); i != rl.end(); ++i) {
-               if ((*i) == _stripable) {
-                       _surface->write (_select->set_state (on));
-                       return;
-               }
-       }
-
-       _surface->write (_select->set_state (off));
-}
-
 string
 Strip::vpot_mode_string ()
 {
@@ -1366,24 +1353,26 @@ Strip::flip_mode_changed ()
                boost::shared_ptr<AutomationControl> fader_control = _fader->control();
 
                if (pot_control && fader_control) {
+
                        _vpot->set_control (fader_control);
                        _fader->set_control (pot_control);
-               }
 
-               if (_surface->mcp().flip_mode() == MackieControlProtocol::Normal) {
-                       do_parameter_display (GainAutomation, fader_control->get_value());
-               } else {
-                       do_parameter_display (BusSendLevel, fader_control->get_value());
-               }
+                       /* update fader with pot value */
+
+                       _surface->write (_fader->set_position (pot_control->internal_to_interface (pot_control->get_value ())));
 
-               /* update fader */
+                       /* update pot with fader value */
 
-               _surface->write (_fader->set_position (pot_control->internal_to_interface (pot_control->get_value ())));
+                       _surface->write (_vpot->set (fader_control->internal_to_interface (fader_control->get_value()), true, Pot::wrap));
 
-               /* update pot */
 
-               _surface->write (_vpot->set (fader_control->internal_to_interface (fader_control->get_value()), true, Pot::wrap));
+                       if (_surface->mcp().flip_mode() == MackieControlProtocol::Normal) {
+                               do_parameter_display (GainAutomation, fader_control->get_value());
+                       } else {
+                               do_parameter_display (BusSendLevel, pot_control->get_value());
+                       }
 
+               }
 
        } else {
                /* do nothing */