Continously rotating knob/dial

I need to create a continuously rotating knob. I have searched examples and the forum and can’t say I found anything on this. Most of the discussions are related to subclassing LookAndFeel to replace graphics and talk about filmstrip vs. SVG’s vs. raw graphics.

A very long time ago (going back to Windows development with MFC) I wrote what I then called a DataKnob class that did exactly this. Here’s a short video from an old test program:

It was a test application, never mind the raw graphics. It’s two images, one for the larger knob --which never moves-- and the other for the indentation, which is simply repositioned during rotation.

How do I approach this with JUCE? I am OK rotating the entire image (it won’t have a shadow or gradient) or taking a similar approach. I see JUCE has AffineTransform. Is that the best way to rotate a PNG with a transparent background?

What I think I know from reading through posts is that I have to subclass LookAndFeel and then draw the new graphics there.

Can a slider be configured for continuous rotation? How?

If not, I think it can be configured for a range of 359 degrees. Some logic on top of that might be able to fully simulate continuous rotation…don’t know.

If anyone is interested, I am happy to post my old MFC code for the knob here.


AFAIK, the best way is to override the function LookAndFeel::drawRotarySlider() (since you do have two images).

You may provide the slider a rotaryStartAngle and rotaryEndAngle with Slider::setRotaryParameters(). Then you can calculate the rotation angle from the arguments of LookAndFeel::drawRotarySlider() and draw it.

For continuous rotation, check out Slider::setRotaryParameters(), which takes two angles and boolean which you can set to false.

If you want an example of how to do this yourself, I used the AffineTransform technique described here:

In my case it was for a ‘trim slider’ with continual rotation on the vertical axes, but you can easily modify the same AffineTransform to do a rotation instead of the translation I use …

Thanks for sharing. I was looking for a video of the trim slider in operation. I can’t find any. Has it been removed from the interface?

Cool microphones and headphones BTW. If your business headphone was offered in a wireless option I would buy one for general use.

The new UI hasn’t been released officially, so there is no video of it yet. :slight_smile: But you can easily use that code independently and see for yourself - only thing you need to do is modify the Transform to rotate instead of offset …

Re: headphones - thanks for checking them out - the HiX25BT’s are our only wireless headphones at the moment, but stay tuned, there’s always more fun stuff around the corner … :wink: