enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / libs / surfaces / osc / osc_route_observer.cc
index f0758ba71a0e063299f88f3a5325b5497adcbe2c..067e84986aac3632e72631db143c702e904acfc9 100644 (file)
@@ -28,7 +28,7 @@
 #include "osc.h"
 #include "osc_route_observer.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace PBD;
@@ -69,7 +69,8 @@ OSCRouteObserver::OSCRouteObserver (boost::shared_ptr<Stripable> s, lo_address a
                        recsafe_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, bind (&OSCRouteObserver::send_change_message, this, X_("/strip/record_safe"), _strip->rec_safe_control()), OSC::instance());
                        send_change_message ("/strip/record_safe", _strip->rec_safe_control());
                }
-               send_select_status ();
+               _strip->presentation_info().PropertyChanged.connect (strip_connections, MISSING_INVALIDATOR, bind (&OSCRouteObserver::send_select_status, this, _1), OSC::instance());
+               send_select_status (ARDOUR::Properties::selected);
        }
 
        if (feedback[1]) { // level controls
@@ -101,6 +102,7 @@ OSCRouteObserver::~OSCRouteObserver ()
 
        strip_connections.drop_connections ();
        // all strip buttons should be off and faders 0 and etc.
+       clear_strip ("/strip/expand", 0);
        if (feedback[0]) { // buttons are separate feedback
                lo_message msg = lo_message_new ();
                // name is a string do it first
@@ -153,7 +155,12 @@ OSCRouteObserver::tick ()
 {
        if (feedback[7] || feedback[8] || feedback[9]) { // meters enabled
                // the only meter here is master
-               float now_meter = _strip->peak_meter()->meter_level(0, MeterMCP);
+               float now_meter;
+               if (_strip->peak_meter()) {
+                       now_meter = _strip->peak_meter()->meter_level(0, MeterMCP);
+               } else {
+                       now_meter = -193;
+               }
                if (now_meter < -193) now_meter = -193;
                if (_last_meter != now_meter) {
                        if (feedback[7] || feedback[8]) {
@@ -364,21 +371,21 @@ OSCRouteObserver::clear_strip (string path, float val)
 }
 
 void
-OSCRouteObserver::send_select_status ()
+OSCRouteObserver::send_select_status (const PropertyChange& what)
 {
-       // waiting for _strip->is_selected to start working
-       if (_strip) {
-               string path = "/strip/gui_select";
-
-               lo_message msg = lo_message_new ();
-               if (feedback[2]) {
-                       path = set_path (path);
-               } else {
-                       lo_message_add_int32 (msg, ssid);
+       if (what == PropertyChange(ARDOUR::Properties::selected)) {
+               if (_strip) {
+                       string path = "/strip/select";
+
+                       lo_message msg = lo_message_new ();
+                       if (feedback[2]) {
+                               path = set_path (path);
+                       } else {
+                               lo_message_add_int32 (msg, ssid);
+                       }
+                       lo_message_add_float (msg, _strip->is_selected());
+                       lo_send_message (addr, path.c_str(), msg);
+                       lo_message_free (msg);
                }
-               //std::cout << "strip: " << ssid << " strip name: " << _strip->name() << " select: " << _strip->is_selected() << "\n";
-               lo_message_add_float (msg, _strip->is_selected());
-               lo_send_message (addr, path.c_str(), msg);
-               lo_message_free (msg);
        }
 }