What I would like to do is be able to set the color of a key in the MidiKeyboardComponent.
I’ve not had luck with my searches. I’ve seen drawWhiteNote an drawBlackNote. They seem to have the parameters to do what I would like, but the actual API call to set the color eludes me.
I’m looking for something like
setColour( int keyNumber, juce::colourid);
Very high level thought but overriding those two methods, even though you have a color parameter, you can paint the color of your choice.
Overriding those two methods means you use the Graphics instance passed and actually draw the rectangle and color you have setup earlier in your code or dynamically figure it out based on some changed state.
Simply you could have a map that creates a relationship between the pitch and color, use that to draw the key’s color when asked.
The component ‘calls’ the two draw* methods.
Also, maybe there is Look & Feel for this, but still could accomplish the dirty way.
(I don’t know if the above is the correct way, never tried it)
I would guess that if you want a custom layout of keys, then you would override paint() but just drawing keys, override the above and they should get called automatically from super’s paint() or elsewhere.
The MidiKeyboardComponent doesn’t seem to use LookAndFeel at all.
The drawWhiteNote and drawBlackNote get the colour as parameter provided.
That means you will have to override the paint() method, start by copying the original and change the code in the loop drawing to pick up your bespoke per-note-colour.