Bug with Slider::setRotaryParameters

I have a bug with the stopAtEnd parameter of setRotaryParameters:

If I do:

theKnob->setSliderStyle (Slider::Rotary);
theKnob->setRotaryParameters( float_Pi, float_Pi *3, false);

the knob do rotate indefinitely, but if I do:

theKnob->setSliderStyle (Slider::RotaryVerticalDrag);
theKnob->setRotaryParameters( float_Pi, float_Pi *3, false);

The value doesn’t wrap around, even if stopAtEnd is set to false. Tested on iOS and Android.

Not really a bug… If the slider’s in vertical drag mode, then it won’t wrap the value. The stopAtEnd parameter only really has a meaning when the mouse is being moved in a circle and can end up back at its starting point.

I found this post after searching to discover if this behavior was a known bug or not.  I agree with @shini, this seems like a bug to me, and should be fixed so that as you're dragging, the slider will wrap around if it reaches one end and the user continues the dragging gesture in the same direction.  Alternatively, if the documentation for stopAtEnd would mention that it only has meaning for Rotary style, not other styles such as RotaryHorizontalVerticalDrag, that would also be acceptable.

I really don't see it as a bug!

The only reason that stopAtEnd exists is because when the motion is circular, you can end up back where you started - you can't do that when moving linearly, so it seems odd to me that you'd expect the value to keep snapping back.

(I will update the docs though!)

I, too, see this as a bug.  There are certainly valid use cases where you would not want a rotary slider to hit a hard stop at any point along its rotation.  One example: Azimuth.  You wouldn't want to force the user to go back a full rotation to go from 359 degrees to 1 degree.  And the preference for circular vs. linear drag to manipulate knobs on UIs is about 50/50 - enough that on more than one project I've made it a user preference.

stopAtEnd exists, so why *not* honor it for linearly manipulated controls?

2 Likes

I would like to emulate a hardware synth where you can turn a dial forever to manipulate a value. And I expected stopAtEnd to work for linear control.

At the end of ‘handleAbsoluteDrag’

		if (rotaryParams.stopAtEnd)
		{
			valueWhenLastDragged = owner.proportionOfLengthToValue (jlimit (0.0, 1.0, newPos));
		}else
		{
			valueWhenLastDragged = owner.proportionOfLengthToValue (newPos - floor(newPos));
		}

And in ‘getMouseWheelDelta’

   	    auto newPos = currentPos + proportionDelta;
		if (rotaryParams.stopAtEnd)
			return owner.proportionOfLengthToValue(jlimit(0.0, 1.0, newPos)) - value;
		else
			return owner.proportionOfLengthToValue(newPos - floor(newPos)) - value;

And any other I haven’t thought of. :slight_smile: