Creating Multiple Slider Styles

gui

#1

I’m just starting out with Juce. I’m wanting to create a bunch of different types of sliders and knobs.

I’ve created an image based knob, by making my own look and feel class, and overriding drawRotarySlider like this:

void drawRotarySlider (Graphics& g, int x, int y, int width, int height, float sliderPos, const float rotaryStartAngle, const float rotaryEndAngle, Slider& slider) override;

But what I want to do is make multiple types of knobs, and be able to add them to my components.

What would be the best way to go about this?

Many thanks!


#2

A look and feel class can deliver one version for each SliderType. But you can have different LookAndFeel classes in parallel assigned to individual sliders.

Every Component will first try to use it’s own look and feel, which was set with Component::setLookAndFeel(). If none was set, it will look up in it’s parent class, and so on. As a last resort it will use the one which was set with LookAndFeel::setDefaultLookAndFeel(). If it wasn’t, there is a fallback for a default in place.

Remember, you only need one instance per lookAndFeel, you can assign it to as many components as you like.


#3

Ahh - thank you for the prompt reply, that’s perfect. Cheers :slight_smile: