LookAndFeel tutorial?


#1

Hi all,

I am trying to understand how to work with LookAndFeel classes, is there some basic tutorial somewhere?
Specifically I need a combo box with transparent background. How can LookAndFeel help?

Thank you

Nathaniel


#2

The gui components are drawn by methods from look and feel classes. So there is one set as default and the component instances aggregate the drawing function using the LnF.
i.e. the code you are looking for is here:

So to alter this drawing you would derive from the look and feel class you prefer and override the drawComboBox method. Then you need to have an instance of your new look and feel class (using ScopedPointer is prefered) and set it to your component via Component::setLookAndFeel().

In your case you don’t need to override the drawComboBox, if you want to change the colours. Simply use Component::setColour() like this should work:
myComboBox.setColour (ComboBox::backgroundColourId, Colours::black.withAlpha (0.0));

Good luck

BTW @juce there used to be a tutorial for this IIRC, is it in a makeover or did it get lost?


#3

thanks for this very fast answer!!