serialize/deserialize MIDISceneChange color; put out of bounds color into static...
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 11 Nov 2014 02:22:05 +0000 (21:22 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 11 Nov 2014 04:17:08 +0000 (23:17 -0500)
libs/ardour/ardour/midi_scene_change.h
libs/ardour/midi_scene_change.cc

index 9c8f5ca01fe997bd5318763bba31fb91aa19c7d2..69f7b05d293aab3b425b3f3e380e14abfdd7ac44 100644 (file)
@@ -57,6 +57,7 @@ class MIDISceneChange : public SceneChange
 
         uint32_t color() const;
         void set_color (uint32_t);
 
         uint32_t color() const;
         void set_color (uint32_t);
+        static const uint32_t out_of_bound_color;
         PBD::Signal0<void> ColorChanged;
 
   private:
         PBD::Signal0<void> ColorChanged;
 
   private:
index db7e8263842cd32839a38f34b5c0c4a965f362e1..db903c21ebe5628f3a8060d2465732ca47888ec8 100644 (file)
 using namespace PBD;
 using namespace ARDOUR;
 
 using namespace PBD;
 using namespace ARDOUR;
 
+const uint32_t MIDISceneChange::out_of_bound_color = 0x00000000; /* note: zero alpha means invisible, which acts as out-of-bound signal */
+
 MIDISceneChange::MIDISceneChange (int c, int b, int p)
        : _bank (b)
        , _program (p)
        , _channel (c & 0xf)
 MIDISceneChange::MIDISceneChange (int c, int b, int p)
        : _bank (b)
        , _program (p)
        , _channel (c & 0xf)
-        , _color (0x00000000) /* note: zero alpha means invisible, which acts as out-of-bound signal */
+        , _color (out_of_bound_color)
 {
        if (_bank > 16384) {
                _bank = -1;
 {
        if (_bank > 16384) {
                _bank = -1;
@@ -47,6 +49,7 @@ MIDISceneChange::MIDISceneChange (const XMLNode& node, int version)
        : _bank (-1)
        , _program (-1)
        , _channel (-1)
        : _bank (-1)
        , _program (-1)
        , _channel (-1)
+        , _color (out_of_bound_color)
 {
        set_state (node, version);
 }
 {
        set_state (node, version);
 }
@@ -111,6 +114,8 @@ MIDISceneChange::get_state ()
        node->add_property (X_("bank"), buf);
        snprintf (buf, sizeof (buf), "%d", (int) _channel);
        node->add_property (X_("channel"), buf);
        node->add_property (X_("bank"), buf);
        snprintf (buf, sizeof (buf), "%d", (int) _channel);
        node->add_property (X_("channel"), buf);
+       snprintf (buf, sizeof (buf), "%u", _color);
+       node->add_property (X_("color"), buf);
 
        return *node;
 }
 
        return *node;
 }
@@ -139,6 +144,12 @@ MIDISceneChange::set_state (const XMLNode& node, int /* version-ignored */)
        }
        _channel = atoi (prop->value());
 
        }
        _channel = atoi (prop->value());
 
+       if ((prop = node.property (X_("color"))) != 0) {
+                _color = atoi (prop->value());
+        } else {
+                _color = out_of_bound_color;
+        }
+
        return 0;
 }
 
        return 0;
 }