Slider request : "rotaryHorizontalVerticalDrag"


As much as I enjoy the rotary slider class of JUCE, I’m looking for a “drag” variant that IMHO is missing in the current options.

There is already rotary, RotaryHorizontalDrag, and RotaryVerticalDrag options, but would it possible to add a rotaryHorizontalVerticalDrag variant ? So the rotary slider would respond to both vertical & horizontal drag ?

Thanks !


How would that work, exactly?.. Wouldn’t it just be equivalent to a ‘diagonal’ drag?

I guess Salvator means something like

(it’s pseudo code, it’s not meant to work as is, of course)

[code]mouseDrag() // called on mouse drag

if ( abs(deltaX) > abs(deltaY) )
    // operate as in the case of rotaryHorizontalDrag
else   // movement along Y axis is greater than movement on X axis
    // operate as in the case of rotaryVerticalDrag


Don’t you think that’d be a bit jumpy when the mouse touches the diagonal boundary line between the two axes?

Well, I’m not particularly in favour of this solution, I was only trying to guess what was meant.

BTW, if you’re at the boundary where deltaX and deltaY are close to each other, that means that even the calculated value for the slider position shouldn’t differ either way, right?

That’s true for the SW->NE axis, but at the SE->NW one, it’d be jumping between positive and negative values.

Ah, true… didn’t think about it! :oops:


It’s something that just look at the mouse “delta” mouvement from the moment the user click and start to drag, and then it add together the x+y “delta” value to modify knob position. Not an if/else, but summing.

FWIW here’s bellow for illustration something I use in a javasprit.
x and y are mouse coordinate in pixel.

{delta = (last_y-y + x-last_x)*0.3; // add mouse tracking vert & hor + slow down

last_x = x;	//reset x position (to calcul delta on drag)
last_y = y;//reset y position

Thanks for listening,


Hmm… I’ve never really liked relative distances in sliders, it always seems to make it drift as you move the mouse at different speeds. Unless the pointer is hidden, I much prefer to see a relationship between a screen position and a slider value, it feels more controllable.

There must be some other cunning way to do it…