1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

MidiKeyboardComponent: Avoid triggering assertions when painting

This commit is contained in:
reuk 2022-01-24 16:47:24 +00:00
parent 65b649225d
commit fc6bfaf79e

View file

@ -360,10 +360,20 @@ void KeyboardComponentBase::paint (Graphics& g)
for (int octaveBase = 0; octaveBase < 128; octaveBase += 12)
{
for (auto noteNum : whiteNotes)
drawWhiteKey (octaveBase + noteNum, g, getRectangleForKey (octaveBase + noteNum));
{
const auto key = octaveBase + noteNum;
if (rangeStart <= key && key <= rangeEnd)
drawWhiteKey (key, g, getRectangleForKey (key));
}
for (auto noteNum : blackNotes)
drawBlackKey (octaveBase + noteNum, g, getRectangleForKey (octaveBase + noteNum));
{
const auto key = octaveBase + noteNum;
if (rangeStart <= key && key <= rangeEnd)
drawBlackKey (key, g, getRectangleForKey (key));
}
}
}