Browse Source

MidiKeyboardComponent: Avoid triggering assertions when painting

v6.1.6
reuk 3 years ago
parent
commit
fc6bfaf79e
1 changed files with 12 additions and 2 deletions
  1. +12
    -2
      modules/juce_audio_utils/gui/juce_KeyboardComponentBase.cpp

+ 12
- 2
modules/juce_audio_utils/gui/juce_KeyboardComponentBase.cpp 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));
}
}
}


Loading…
Cancel
Save