Merge pull request #743 from jpcima/display-overlaps
Display overlap of key range and switches on VK
This commit is contained in:
commit
9386ed2f09
2 changed files with 27 additions and 14 deletions
|
|
@ -33,6 +33,7 @@ struct SPiano::Impl {
|
||||||
|
|
||||||
float keyUsedHue_ = 0.55;
|
float keyUsedHue_ = 0.55;
|
||||||
float keySwitchHue_ = 0.0;
|
float keySwitchHue_ = 0.0;
|
||||||
|
float keyUsedAndSwitchHue_ = 0.85;
|
||||||
float whiteKeyChroma_ = 0.9;
|
float whiteKeyChroma_ = 0.9;
|
||||||
float blackKeyChroma_ = 0.75;
|
float blackKeyChroma_ = 0.75;
|
||||||
float whiteKeyLuma_ = 0.9;
|
float whiteKeyLuma_ = 0.9;
|
||||||
|
|
@ -125,19 +126,19 @@ void SPiano::setKeyValue(unsigned key, float value)
|
||||||
invalid();
|
invalid();
|
||||||
}
|
}
|
||||||
|
|
||||||
SPiano::KeyRole SPiano::getKeyRole(unsigned key)
|
int SPiano::getKeyRole(unsigned key)
|
||||||
{
|
{
|
||||||
Impl& impl = *impl_;
|
Impl& impl = *impl_;
|
||||||
|
int role = 0;
|
||||||
|
|
||||||
if (key >= 128)
|
if (key < 128) {
|
||||||
return KeyRole::Unused;
|
if (impl.keyUsed_.test(key))
|
||||||
|
role |= KeyRole::Note;
|
||||||
|
if (impl.keyswitchUsed_.test(key))
|
||||||
|
role |= KeyRole::Switch;
|
||||||
|
}
|
||||||
|
|
||||||
if (impl.keyUsed_.test(key))
|
return role;
|
||||||
return KeyRole::Note;
|
|
||||||
if (impl.keyswitchUsed_.test(key))
|
|
||||||
return KeyRole::Switch;
|
|
||||||
|
|
||||||
return KeyRole::Unused;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPiano::draw(CDrawContext* dc)
|
void SPiano::draw(CDrawContext* dc)
|
||||||
|
|
@ -170,6 +171,12 @@ void SPiano::draw(CDrawContext* dc)
|
||||||
goto whiteKeyDefault;
|
goto whiteKeyDefault;
|
||||||
hcy.h = impl.keyUsedHue_;
|
hcy.h = impl.keyUsedHue_;
|
||||||
break;
|
break;
|
||||||
|
case KeyRole::Note|KeyRole::Switch:
|
||||||
|
if (!allKeysUsed) {
|
||||||
|
hcy.h = impl.keyUsedAndSwitchHue_;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// fall through
|
||||||
case KeyRole::Switch:
|
case KeyRole::Switch:
|
||||||
hcy.h = impl.keySwitchHue_;
|
hcy.h = impl.keySwitchHue_;
|
||||||
break;
|
break;
|
||||||
|
|
@ -210,6 +217,12 @@ void SPiano::draw(CDrawContext* dc)
|
||||||
goto blackKeyDefault;
|
goto blackKeyDefault;
|
||||||
hcy.h = impl.keyUsedHue_;
|
hcy.h = impl.keyUsedHue_;
|
||||||
break;
|
break;
|
||||||
|
case KeyRole::Note|KeyRole::Switch:
|
||||||
|
if (!allKeysUsed) {
|
||||||
|
hcy.h = impl.keyUsedAndSwitchHue_;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// fall through
|
||||||
case KeyRole::Switch:
|
case KeyRole::Switch:
|
||||||
hcy.h = impl.keySwitchHue_;
|
hcy.h = impl.keySwitchHue_;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -29,13 +29,13 @@ public:
|
||||||
void setKeyswitchUsed(unsigned key, bool used);
|
void setKeyswitchUsed(unsigned key, bool used);
|
||||||
void setKeyValue(unsigned key, float value);
|
void setKeyValue(unsigned key, float value);
|
||||||
|
|
||||||
enum class KeyRole {
|
enum KeyRole : int {
|
||||||
Unused,
|
Unused = 0,
|
||||||
Note,
|
Note = 1 << 0,
|
||||||
Switch,
|
Switch = 1 << 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
KeyRole getKeyRole(unsigned key);
|
int getKeyRole(unsigned key);
|
||||||
|
|
||||||
std::function<void(unsigned, float)> onKeyPressed;
|
std::function<void(unsigned, float)> onKeyPressed;
|
||||||
std::function<void(unsigned, float)> onKeyReleased;
|
std::function<void(unsigned, float)> onKeyReleased;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue