summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-11-10 21:44:02 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2014-11-10 23:17:27 -0500
commit9254e80c396265f484adb3b7bf5f0b502d096107 (patch)
tree0404ffd8e40d884a5241d82c0a72589b398c98a4 /libs/ardour
parente27651d31521a527a2acaf570512a44163b5c638 (diff)
refactor MIDISceneChange color property addition by moving it into SceneChange to anticipate other types of SceneChange objects (e.g. OSC)
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/midi_scene_change.h6
-rw-r--r--libs/ardour/ardour/scene_change.h14
-rw-r--r--libs/ardour/midi_scene_change.cc17
-rw-r--r--libs/ardour/midi_scene_changer.cc6
-rw-r--r--libs/ardour/scene_change.cc19
5 files changed, 35 insertions, 27 deletions
diff --git a/libs/ardour/ardour/midi_scene_change.h b/libs/ardour/ardour/midi_scene_change.h
index 69f7b05d29..450f18d3f2 100644
--- a/libs/ardour/ardour/midi_scene_change.h
+++ b/libs/ardour/ardour/midi_scene_change.h
@@ -55,16 +55,10 @@ class MIDISceneChange : public SceneChange
bool operator==(const MIDISceneChange& other) const;
- uint32_t color() const;
- void set_color (uint32_t);
- static const uint32_t out_of_bound_color;
- PBD::Signal0<void> ColorChanged;
-
private:
int _bank;
int _program;
uint8_t _channel;
- uint32_t _color;
};
} /* namespace */
diff --git a/libs/ardour/ardour/scene_change.h b/libs/ardour/ardour/scene_change.h
index 1f856beedf..4ad0ce5f39 100644
--- a/libs/ardour/ardour/scene_change.h
+++ b/libs/ardour/ardour/scene_change.h
@@ -30,11 +30,23 @@ namespace ARDOUR
class SceneChange : public PBD::Stateful
{
public:
- SceneChange () {};
+ SceneChange ();
virtual ~SceneChange () {};
static boost::shared_ptr<SceneChange> factory (const XMLNode&, int version);
static std::string xml_node_name;
+
+ uint32_t color() const;
+ void set_color (uint32_t);
+ bool color_out_of_bounds() const { return _color == out_of_bound_color; }
+ static const uint32_t out_of_bound_color;
+
+ PBD::Signal0<void> ColorChanged;
+
+ protected:
+ /* derived classes are responsible for serializing & deserializing this value */
+ uint32_t _color;
+
};
} /* namespace */
diff --git a/libs/ardour/midi_scene_change.cc b/libs/ardour/midi_scene_change.cc
index db903c21eb..aede5c4b90 100644
--- a/libs/ardour/midi_scene_change.cc
+++ b/libs/ardour/midi_scene_change.cc
@@ -28,13 +28,10 @@
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 (out_of_bound_color)
{
if (_bank > 16384) {
_bank = -1;
@@ -49,7 +46,6 @@ MIDISceneChange::MIDISceneChange (const XMLNode& node, int version)
: _bank (-1)
, _program (-1)
, _channel (-1)
- , _color (out_of_bound_color)
{
set_state (node, version);
}
@@ -160,16 +156,3 @@ MIDISceneChange::operator==(const MIDISceneChange& other) const
_bank == other._bank &&
_channel == other._channel;
}
-
-void
-MIDISceneChange::set_color (uint32_t c)
-{
- _color = c;
- ColorChanged (); /* EMIT SIGNAL */
-}
-
-uint32_t
-MIDISceneChange::color() const
-{
- return _color;
-}
diff --git a/libs/ardour/midi_scene_changer.cc b/libs/ardour/midi_scene_changer.cc
index e799b5a2ce..285a370402 100644
--- a/libs/ardour/midi_scene_changer.cc
+++ b/libs/ardour/midi_scene_changer.cc
@@ -315,10 +315,10 @@ MIDISceneChanger::program_change_input (MIDI::Parser& parser, MIDI::byte program
Locations::LocationList copy (locations->list());
for (Locations::LocationList::const_iterator l = copy.begin(); l != copy.end(); ++l) {
- boost::shared_ptr<MIDISceneChange> m = boost::dynamic_pointer_cast<MIDISceneChange>((*l)->scene_change());
+ boost::shared_ptr<MIDISceneChange> sc = boost::dynamic_pointer_cast<MIDISceneChange>((*l)->scene_change());
- if (m && (*m.get()) == *msc) {
- msc->set_color (m->color ());
+ if (sc && (*sc.get()) == *msc) {
+ msc->set_color (sc->color ());
break;
}
}
diff --git a/libs/ardour/scene_change.cc b/libs/ardour/scene_change.cc
index eda260382b..6560a7ca2f 100644
--- a/libs/ardour/scene_change.cc
+++ b/libs/ardour/scene_change.cc
@@ -25,6 +25,7 @@ using namespace PBD;
using namespace ARDOUR;
std::string SceneChange::xml_node_name = X_("SceneChange");
+const uint32_t SceneChange::out_of_bound_color = 0x00000000; /* note: zero alpha means invisible, which acts as out-of-bound signal */
boost::shared_ptr<SceneChange>
SceneChange::factory (const XMLNode& node, int version)
@@ -37,3 +38,21 @@ SceneChange::factory (const XMLNode& node, int version)
return boost::shared_ptr<SceneChange>();
}
+
+SceneChange::SceneChange ()
+ : _color (out_of_bound_color)
+{
+}
+
+void
+SceneChange::set_color (uint32_t c)
+{
+ _color = c;
+ ColorChanged (); /* EMIT SIGNAL */
+}
+
+uint32_t
+SceneChange::color() const
+{
+ return _color;
+}