Slider smoother

Hi all, this should be a quick one:

I want a Slider that moves slowly from value to value so it also goes back from max to min through the track, not a straight jump.

Probably the obvious solution is to create a custom slider with a smoother on the value.
Is there any simpler & faster way to do this on the generic Juce Slider class?

Thanks in advance.

You mean something like this?

2020-07-22 22.46.39

In sliderDragEnded can’t you start a timer that will start to change to current value of your slider? In this example it always moves back to 0, but you could also check if the new value is greater than the last one allowing it to pick a direction.

Apologies if this isn’t at all what you were asking about!

Hmmm not exactly, but I think I can make it work with your approach.

Let me explain it again: imagine the slider is at it’s maximum value and the user sets it to the minimum through the entry textbox. I want it to move it slowly to the minimum and through the track. Not snapping instantly to the new value as the default slider does.

Would it work if I start a timer to smooth the value on sliderValueChanged()?

It could, but you should make sure that when your Timer regularly updates the slider value during the smoothing, that doesn’t trigger a sliderValueChanged() that in turn interferes with the smoothing currently in progress.

Also, an issue that I see is this: suppose you’re at max value and you set to min. Before the smoothing Timer kicks in and starts decreasing the value from max to min, the Slider will have assumed the min value for a small time interval, effectively causing its value to jump from max to min as a result of your change, then abruptly to brought back to max again by the smoothing Timer which will decrease it back to min again.
The initial jump from max to min and then back to max sounds like something you’d like to avoid, preferring the value to stay at max and then decreasing towards its intended target min value by effect of the Timer only. but I cannot imagine an easy way to obtain that

1 Like

I’ll give it a try with a custom slider class :thinking: