Periodic infinite juce::Slider?

I would like to have a slider, which controls the phase offset of a value beetween zero and 2PI.
Is there a way to have a periodic slider, where a user can scroll to a value higher than 2
PI, which is mapped into the value range again.
…So you can scroll infinitelly, adjusting for example the rotation of an object.


1 Like

When you make it, add it to JUCE_LIVE_CONSTANT editor.

I think this is pretty simple with a few overrides.

This looks good, thanks… unfortunately, in my UI a rotary slider does not fit, so I have to use a horizontal slider. But this looping feature is not supported for this style!?

Do you know a solution for this?
I just saw this , where someone proposed a solution… but it seems to be not inside the juce::Slider class so far. Any other ideas?

Oh, the lovely Slider::pimpl implementation…
I don’t know, If I were in the same situation (and I wouldn’t want to hack the juce code) I would probably add a transparent Component on top of the Slider.
Then I would register as a MouseListener to it and set the Slider’s value according to the mouse drag distance. So basically it’s sort of “changing the Slider’s value without actually touching it”.
Keep in mind that you would need to forward also the mouse down/up events in case the Slider is attached to an AudioProcessorParameter, otherwise you’d end up losing begin/end gestures.

EDIT: another option could be to use another Slider instead of this Component. Configure it as RotaryHorizontalDrag, make it completely transparent (via custom LookAndFeel, or subclass a Slider, override the paint function and do nothing in it) and add it on top of your Slider, with the same bounds. In this way you don’t need to do any calculations with mouse events.

1 Like

If you have little space on the UI, you could use a rotary slider but it just looks like a horizontal dial, like an old radio tuner thing.
In the forum, I 'm sure someone posted some film-strip rendering code for a slider.
You could do a dial like this, where it animates left and right, continuously:-

I used your approach with an invisible rotary slider on Top. it works, with not too much effort, Thank you!

…but I would really like to have juce providing this rotaryParameter feature independent of the slider style!