Request for MidiKeyboardComponent::drawWhiteNote


Hello Jules,

I was wondering, if you could make a small change in the MidiKeyboardComponent::drawWhiteNote function.

Right now it says (right after the entry):

Colour c (Colours::transparentWhite);

But instead I would like it to be:

Colour c = findColour (whiteNoteColourId);

Well, I am making an instrument plugin. And I want to colour the keys according to the instruments playing range.
Right now I have only the option to change the colour of all keys together. With the modification it would be possible to change the colour of single keys.

Or is there maybe another way, that I am missing? (apart from copying the whole drawWhiteNote function)


I don’t see how your suggestion would make any difference there, it’d still only be one colour for all the notes.

If you need a really customised keyboard, I’d say just overload the whole function and do whatever you need to.


Well, I was thinking to subclass the MidiKeyboardComponent, overload the drawWhiteNote function and then do something along the following lines:

void OverloadedKeyboard::drawWhiteNote(lots of params here)
        if ( isInPlayableRange(midiNoteNumber) )
            keyColour =  Colours::blue;
            keyColour = Colours::white;             
        setColour(MidiKeyboardComponent::whiteNoteColourId, keyColour);
        MidiKeyboardComponent::drawWhiteNote(midiNoteNumber, g, x, y, w, h, isDown, isOver, lineColour, textColour);

But I realized that, at least in Debug mode, this is really slow, because of the setColour() function.

So I will take your advice and reimplement the drawWhiteNote() function.