Hello,
I have problem to understand how to properly use the LookAndFeel_V4::getDefaultLookAndFeel()
In my default look and feel I have override method drawButtonBackground(), like that:
class MyDefaultLAF : public LookAndFeel_V4
{
// ... some code ...
void drawButtonBackground (Graphics& g, Button& b, const Colour& backgroundColour,
bool mouseOver, bool mouseDown) override
{
// some drawings
}
}
But my Button class looks like that:
class MyButton : public Button
{
MyButton() { setLookAndFeel(&LookAndFeel_V4::getDefaultLookAndFeel()); };
// ... some code
}
And this of course will not even compile, because in MyButton class I need to override paintButton().
But if I override paintButton() then it is used instead MyDefaultLAF::drawButtonBackground().
So I can’t understand how can I use one default look and feel for all my components?
Button is a common base class for e.g. TextButton, DrawableButton, etc.
If you use one of the subclasses, they will have the paintButton implemented so they use your LNF method.
If you want to inherit from Button, you need to call the drawButtonBackground() yourself from your paintButton. I would recommend choosing the best fitting subclass of Button, but it’s a matter of preference.
I just did a full text search for drawButtonBackground().
Only the TextButton ever calls that method, which makes sense: the background for the other buttons is most likely not identical.
It is probably historical or an oversight that drawButtonBackground() is not in TextButton::LookAndFeelMethods.