From 0f243d5f7c1201377460d1b46aed4f10e68ef0cf Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 10 Nov 2014 21:22:05 -0500 Subject: [PATCH] serialize/deserialize MIDISceneChange color; put out of bounds color into static const --- libs/ardour/ardour/midi_scene_change.h | 1 + libs/ardour/midi_scene_change.cc | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libs/ardour/ardour/midi_scene_change.h b/libs/ardour/ardour/midi_scene_change.h index 9c8f5ca01f..69f7b05d29 100644 --- a/libs/ardour/ardour/midi_scene_change.h +++ b/libs/ardour/ardour/midi_scene_change.h @@ -57,6 +57,7 @@ class MIDISceneChange : public SceneChange uint32_t color() const; void set_color (uint32_t); + static const uint32_t out_of_bound_color; PBD::Signal0 ColorChanged; private: diff --git a/libs/ardour/midi_scene_change.cc b/libs/ardour/midi_scene_change.cc index db7e826384..db903c21eb 100644 --- a/libs/ardour/midi_scene_change.cc +++ b/libs/ardour/midi_scene_change.cc @@ -28,11 +28,13 @@ 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) - , _color (0x00000000) /* note: zero alpha means invisible, which acts as out-of-bound signal */ + , _color (out_of_bound_color) { if (_bank > 16384) { _bank = -1; @@ -47,6 +49,7 @@ MIDISceneChange::MIDISceneChange (const XMLNode& node, int version) : _bank (-1) , _program (-1) , _channel (-1) + , _color (out_of_bound_color) { 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); + snprintf (buf, sizeof (buf), "%u", _color); + node->add_property (X_("color"), buf); return *node; } @@ -139,6 +144,12 @@ MIDISceneChange::set_state (const XMLNode& node, int /* version-ignored */) } _channel = atoi (prop->value()); + if ((prop = node.property (X_("color"))) != 0) { + _color = atoi (prop->value()); + } else { + _color = out_of_bound_color; + } + return 0; }