Bug? Problem with setting Sliders opaque and the number box redraw

I have some Sliders set to IncDec Mode in a separate component (moduleComponent) that is replicated a number of times in the parent component (like channel strips). I have the paint() method for the moduleComponent set to fill it with Colours::darkgrey.

By default, this means that the number box of the Slider (which is I guess transparent) will be filled with the dark grey, unlike comboboxes and buttons. However, when set like this, I increment the values and they redrawn the value properly.


If I set the Slider to opaque (slider->setOpaque(true)), then it keeps the default LookAndFeel background (almost black). However, when set like this, you increment the values and they draw on top of each other, making a mess.


What am I missing here?

Edit: I should mention this is a GUI App standalone on Mac OS X.

I managed to fix it by NOT using Slider::setOpaque(), and just setting the textBoxBackgroundColourId the same as the other UI objects:

    getLookAndFeel().setColour (Slider::textBoxBackgroundColourId, Colour (0xff29303a));


But it still seems like a bug with setOpaque().

That is a misunderstanding. The setting setOpaque() doesn’t make a component opaque. It rather tells the system, that it must not bother painting the obstructed parent component for that area. (Sometimes it still does though).
A component not marked opaque will always call paint() for the parent first to have the background updated.

If you mark a Component being opaque, but you don’t paint all pixels (e.g. not calling fillAll() at the beginning, or using transparent colours), you will see artefacts shining through.

I see! Thanks for explaining that. Makes sense.