Hello, JUCEy people.
My GUI is resizable at various levels and involves sliders for continuous parameters like gain, in dB, and time stretch, in %.
Unfortunately, at some sizes of fader it’s impossible to actually use it to set 0.0dB or 100% stretch! - it jumps from -0.1 to 0.1 or 99% to 101%.
There’s nothing at all wrong with the Slider code, the calculations seem to be exactly correct, but this is simply an artefact of division and not quite enough pixels to cover every point in the range of travel. The trouble is that JUCE has no way to know that 0.0dB or 100% are special numbers that you always need to be able to hit on that slider.
Thus the idea of a software detent - if it were a physical dial, there’d be a little click when you got to 100% or 0.0.
On a quick look, changing Slider would be pretty easy. You’d have a new setter and getter for two values, “detent”, which might not be set at all, and “detent width”, which defaults to 1. In the code for computing the “value”, if you are within 1/2 “detent width” of the slider value which would give the detent value, then you return the detent value instead.