delete slave during Session::destroy
[ardour.git] / libs / surfaces / faderport8 / callbacks.cc
index 28fa9fd95448d8f0e5055569ba88df2e72baf33a..fd5d1407cbae09cd61203fac138dc98843e6fd69 100644 (file)
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 
+#include "ardour/plugin_insert.h"
 #include "ardour/session.h"
 #include "ardour/session_configuration.h"
 
@@ -65,7 +66,8 @@ FaderPort8::send_session_state ()
        notify_automation_mode_changed (); // XXX (stip specific, see below)
 }
 
-// TODO: AutomationState display of plugin & send automation ?!
+// TODO: AutomationState display of plugin & send automation
+// TODO: link/lock control AS.
 void
 FaderPort8::notify_automation_mode_changed ()
 {
@@ -98,6 +100,7 @@ FaderPort8::notify_automation_mode_changed ()
        _ctrls.button (FP8Controls::BtnATouch).set_active (as == Touch);
        _ctrls.button (FP8Controls::BtnARead).set_active (as == Play);
        _ctrls.button (FP8Controls::BtnAWrite).set_active (as == Write);
+       _ctrls.button (FP8Controls::BtnALatch).set_active (as == Latch);
 }
 
 void
@@ -185,6 +188,9 @@ void
 FaderPort8::notify_solo_changed ()
 {
        bool soloing = session->soloing() || session->listening();
+#ifdef MIXBUS
+       soloing |= session->mixbus_soloed();
+#endif
        _ctrls.button (FP8Controls::BtnSoloClear).set_active (soloing);
 #ifdef FP8_MUTESOLO_UNDO
        if (soloing) {
@@ -196,23 +202,7 @@ FaderPort8::notify_solo_changed ()
 void
 FaderPort8::notify_mute_changed ()
 {
-       bool muted = false;
-       StripableList all;
-       session->get_stripables (all);
-       for (StripableList::const_iterator i = all.begin(); i != all.end(); ++i) {
-               if ((*i)->is_auditioner() || (*i)->is_monitor()) {
-                       continue;
-               }
-               boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(*i);
-               if (r && !r->active()) {
-                       continue;
-               }
-               boost::shared_ptr<MuteControl> mc = (*i)->mute_control();
-               if (mc && mc->muted ()) {
-                       muted = true;
-                       break;
-               }
-       }
+       bool muted = session->muted ();
 #ifdef FP8_MUTESOLO_UNDO
        if (muted) {
                _mute_state.clear ();
@@ -220,3 +210,32 @@ FaderPort8::notify_mute_changed ()
 #endif
        _ctrls.button (FP8Controls::BtnMuteClear).set_active (muted);
 }
+
+void
+FaderPort8::notify_plugin_active_changed ()
+{
+       boost::shared_ptr<PluginInsert> pi = _plugin_insert.lock();
+       if (pi) {
+               _ctrls.button (FP8Controls::BtnBypass).set_active (true);
+               _ctrls.button (FP8Controls::BtnBypass).set_color (pi->enabled () ? 0x00ff00ff : 0xff0000ff);
+       } else {
+               _ctrls.button (FP8Controls::BtnBypass).set_active (false);
+               _ctrls.button (FP8Controls::BtnBypass).set_color (0x888888ff);
+       }
+}
+
+void
+FaderPort8::nofity_focus_control (boost::weak_ptr<PBD::Controllable> c)
+{
+       assert (_link_enabled && !_link_locked);
+       // TODO consider subscribing to c's DropReferences
+       // (in case the control goes away while it has focus, update the BtnColor)
+       _link_control = c;
+       if (c.expired () || 0 == boost::dynamic_pointer_cast<AutomationControl> (_link_control.lock ())) {
+               _ctrls.button (FP8Controls::BtnLink).set_color (0xff8800ff);
+               _ctrls.button (FP8Controls::BtnLock).set_color (0xff0000ff);
+       } else {
+               _ctrls.button (FP8Controls::BtnLink).set_color (0x88ff00ff);
+               _ctrls.button (FP8Controls::BtnLock).set_color (0x00ff88ff);
+       }
+}