setMinValue and setMaxValue weirdness


#1

Preamble: I’ve searched the forums for this topic, and I’ve read the bug-reporting guidelines. (I am using JUCE v1.52)

The bug:
This is pertinent to a 2-valued slider (maybe also 3-valued?) when changing the range and upper and lower slider values.
When using Slider::setMinValue or Slider::setMaxValue the order of the calls seems to be dependent on past values. Let me explain this with an example.

[0 40=minVal 60=maxVal 100]: a slider with a range of [0,100] and two slider values of 40 and 60.

If, e.g., the following code is used:

slider->setRange(0,50);
slider->setMaxValue(30);
slider->setMinValue(20);

what happens, is instead, somehow the maxValue gets “stuck” at 40 (or the old minVal). If the order of calls is switched (i.e., call setMinValue THEN call setMaxValue) for this particular example, then there doesn’t seem to be an issue.

And similarly, the converse is true if the new minVal is exceeding the old maxVal and setMinValue is called prior to setMaxValue.

A simple workaround can be used to test the call order of the two methods by testing the new values to the old values. However it is slightly tedious, and I think could be implemented in the API proper.

Thanks, and let me know if I can be of any help in this!


#2

That’s the way it’s designed to work, to stop you setting them so that they’re the wrong way round. I guess a good solution wouldn’t be to change the existing methods, but to add a new method that sets both values at once.


#3

I agree, an additional “setMinMaxValues(double, bool, bool, bool)” method would be great! Thanks for taking the time to read my request, and thanks for such a great API! :!: