1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

MPEKeyboardComponent: Avoid asserting when clicking on highest visible key

This commit is contained in:
reuk 2024-04-29 19:53:53 +01:00
parent c5b428dfe9
commit 34adc50472
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C

View file

@ -387,14 +387,11 @@ void MPEKeyboardComponent::updateNoteComponentBounds (const MPENote& note, MPENo
const auto currentNote = note.initialNote + (float) note.totalPitchbendInSemitones;
const auto noteBend = currentNote - std::floor (currentNote);
const auto averageKeySize = (float) getTotalKeyboardWidth() / (float) (1 + getRangeEnd() - getRangeStart());
const auto distance = noteBend * averageKeySize;
const auto noteBounds = getRectangleForKey ((int) currentNote);
const auto nextNoteBounds = getRectangleForKey ((int) currentNote + 1);
const auto horizontal = isHorizontal();
const auto distance = noteBend * (horizontal ? nextNoteBounds.getCentreX() - noteBounds.getCentreX()
: nextNoteBounds.getCentreY() - noteBounds.getCentreY());
return (horizontal ? noteBounds.getCentreX() : noteBounds.getCentreY()) + distance;
}();