How to get the current angle of a rotary slider

Is there any way to get the current position of a rotary slider? We can set the start and end angle but I would like to get the current angular position.

With linear sliders this is easy enough - just call getPositionOfValue(getValue()). Sadly this cannot be used for a rotary slider.

My aim is to have a master slider that controls a group of other sliders. This master slider will act like an endless encoder and adjust the others relatively. I have managed to get the rotary slider to appear like an endless encoder when moving it and the other sliders are updated when I turn it. The only thing left is to set the grouped sliders values to change relative to the main slider and not for them all to simply acquire the same value. For this I would like to reset the start and end angles each time the mouse is clicked so that I can add/subtract the main sliders value to the individual sliders values. I’ll need the current angle for this though.

Another way to get that functionality, is to simply forward the mouse-event when dragging, like:

void mouseDrag (const MouseEvent& e) override
    for (int i = 0; i < elements.size(); ++i)
        if (elements[i] != nullptr)
        elements[i]->mouseDrag (e);

I used that here, not a rotary master component, but similar :slight_smile:

1 Like

Wow, that is a neat idea! But for this the sliders to be controlled would need to be members of this main slider right? It wouldn’t be possible to forward the mouse dragging event with the standard Slider Listener/Broadcaster approach would it?

Ok, I tried forwarding the mouseDrag event but I haven’t got it working. The event does get forwarded to the slave slider but it’s not changing it’s position. I must be missing something crucial here?

I just saw that I also forwarded mouseDown and mouseUp, maybe that’s crucial for the drag to start and stop correctly

1 Like

yeah that makes sense - the slaves would probably need the mouseDown before the drag :slight_smile:

FWIW: this is how you get the current angle:

const auto parameters = slider.getRotaryParameters();
auto radians = jmap (slider.valueToProportionOfLength (slider.getValue()),

But I don’t think the slider can have an endless value, so I guess the values will wrap around…

1 Like

Very nice but I’ve gone with the forwarding mouse events approach - it works brilliantly!

many thanks to you both :wink: