refactor MIDISceneChange color property addition by moving it into SceneChange to anticipate other types of SceneChange objects (e.g. OSC)
This commit is contained in:
parent
e27651d315
commit
9254e80c39
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user