LnF stub/fowarder


#1

Would be great to add by default a LookAndFeelForwarder which forward all functions to an instance given in the ctor but still allowing to override couple of functions by deriving from it.

It allows to only override the current LnF for couples of functions without knowing what is the current class used.

Hope you see what I mean.
The tricky part is that it should be maintained with the trunk as it should forward all the LookAndFeel interface functions.

Thanks !


#2

Can you show an example snippet of what you mean? Maybe I read that too fast, but that was really confusing to me lol


#3

Something along

class LookAndFeelForwarder : public LookAndFeel
{
public:
LookAndFeelForwarder(LookAndFeel *pLnf) : mpLnf(pLnf)
{
}

 virtual void drawPropertyPanelSectionHeader (juce::Graphics& g, const juce::String& name,
                                                 bool isOpen, int width, int height) override
{
return mpLnf->drawPropertyPanelSectionHeader(g, name, isOpen, width; height);
}

virtual void drawPropertyComponentBackground (juce::Graphics& g, int width, int height,
                                                  juce::PropertyComponent& component) override
{
return mpLnf->drawPropertyComponentBackground (g, width, height, component);
}
private:
LookAndFeel *mpLnf;
}

but for all functions


#4

How is that different from just subclassing LookAndFeel and calling LookAndFeel::paintButton in your overridden paintButton call? what am I not getting?

struct MyLookAndFeel : public LookAndFeel
{
   void paintButton(Graphics& g, bool a, bool b) override { LookAndFeel::paintButton(g, a, b); } 
}

#5

In case you want to customize the LnF of a widget in a hierarchy where you don’t know what the current LnF is and can only get its pointer by asking the parent widget.
If you do custom widget, they can be used in different context hence different base LnF


#6

can’t you just make your widget that you want customized (differently from your existing LnF) just override the paintButton or paintWhatever directly?

struct MyButton : public Button
{
    MyButton() { setLookAndFeel( myLookAndFeel ); }
    void paintButton(Graphics& g, bool, bool ) override { /* customize however */ }
};

is that not something we are allowed to do if we use LookAndFeel?


#7

Probably not the most maintenable solution and only works for virtual function like the painting ones.