LookAndFeel & resized?


I am wondering: what is the best way to make your resized() functions depend on the current LookAndFeel ?

I have an application, where the user can choose between two LookAndFeels. One “retro” and one “modern”.

My application has several sliders. When the user chooses the “retro” look, I want the sliders to be positioned close together. But if the user chooses the “modern” look, there should be more space between the sliders.

The position of the sliders I set in my resized() function ( by calling slider.setBounds() ). But as far as I can see, the JUCE LookAndFeel class only has paint() functions, but no resized() functions.

What is a good way to make the resized() functions depend on your LookAndFeel?

Have you tried implementing an override of:

virtual void Component::lookAndFeelChanged 	( 		) 	


(sorry, I don’t know why the embedded link won’t preview, but click on it.)

With this, I think you can respond to a lookAndFeel change by calling your own resized method.

Ah, thanks for the hint. :slight_smile:

Another idea, if both LookAndFeel are your owns, you can change Slider::LookAndFeelMethods::getSliderLayout()

That will allow you to place the knobs slightly different (or smaller) in a specific layout).

Oh, interesting.
Is this new? Missed getSliderLayout.

About 6 years now :slight_smile:

Haha ok :smiley:

There’s nothing stopping you adding custom methods to your sub-class of LookAndFeel.

You could create a base that has pure-virtual declarations for a whatever method(s) you need, and then your Retro and Modern L&Fs would implement them accordingly.

Currently I am doing this:
In the resized() function I get the look and feel, and try to cast it to my “Retro” look and feel. If that works, I know the UI is using the retro look. If it fails, I know that the UI is using the modern look:

void resized()
   if (auto lf = dynamic_cast<RetroLnF*>(&getLookAndFeel))
      //... do retro positioning
      //... do modern positioning