From 018a2d41be17e9827b85fc4482bd1aa7a39ba198 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 8 Sep 2015 21:13:47 +0100 Subject: [PATCH] MidiKeyboardComponent: avoid drawing lines if the colour is transparent. --- .../gui/juce_MidiKeyboardComponent.cpp | 46 +++++++++++-------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp index 0de520bab9..13fda79f95 100644 --- a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp @@ -401,14 +401,17 @@ void MidiKeyboardComponent::paint (Graphics& g) } } - g.setColour (lineColour); - - switch (orientation) + if (! lineColour.isTransparent()) { - case horizontalKeyboard: g.fillRect (0, height - 1, x, 1); break; - case verticalKeyboardFacingLeft: g.fillRect (0, 0, 1, x); break; - case verticalKeyboardFacingRight: g.fillRect (width - 1, 0, 1, x); break; - default: break; + g.setColour (lineColour); + + switch (orientation) + { + case horizontalKeyboard: g.fillRect (0, height - 1, x, 1); break; + case verticalKeyboardFacingLeft: g.fillRect (0, 0, 1, x); break; + case verticalKeyboardFacingRight: g.fillRect (width - 1, 0, 1, x); break; + default: break; + } } const Colour blackNoteColour (findColour (blackNoteColourId)); @@ -472,25 +475,28 @@ void MidiKeyboardComponent::drawWhiteNote (int midiNoteNumber, } } - g.setColour (lineColour); - - switch (orientation) + if (! lineColour.isTransparent()) { - case horizontalKeyboard: g.fillRect (x, y, 1, h); break; - case verticalKeyboardFacingLeft: g.fillRect (x, y, w, 1); break; - case verticalKeyboardFacingRight: g.fillRect (x, y + h - 1, w, 1); break; - default: break; - } + g.setColour (lineColour); - if (midiNoteNumber == rangeEnd) - { switch (orientation) { - case horizontalKeyboard: g.fillRect (x + w, y, 1, h); break; - case verticalKeyboardFacingLeft: g.fillRect (x, y + h, w, 1); break; - case verticalKeyboardFacingRight: g.fillRect (x, y - 1, w, 1); break; + case horizontalKeyboard: g.fillRect (x, y, 1, h); break; + case verticalKeyboardFacingLeft: g.fillRect (x, y, w, 1); break; + case verticalKeyboardFacingRight: g.fillRect (x, y + h - 1, w, 1); break; default: break; } + + if (midiNoteNumber == rangeEnd) + { + switch (orientation) + { + case horizontalKeyboard: g.fillRect (x + w, y, 1, h); break; + case verticalKeyboardFacingLeft: g.fillRect (x, y + h, w, 1); break; + case verticalKeyboardFacingRight: g.fillRect (x, y - 1, w, 1); break; + default: break; + } + } } }