Rotary that has central position and draws arc to the left or right of center


Hi, is there a standard version of this kind of rotary or do I need to draw this myself?



Just derive a class from Slider and override getValue()



Hi, this is more a drawing thing than a value issue. Encoders with a center value draw from the center outwards in both directions...


You set the min and max values… say 0 through 100 and make 50 your center value… in getValue you calculate the value based on the your min and max and the position of the fader.

If you want a different look then you can use a LookAndFeel to draw the changes (see drawRotarySlider) or use Knobman to create other options.



Hi, I understand that. I think I know the answer, just I'm not being clear.

See attached file. The center value here is 64 and the knob is shown at 45. It is drawing from the center of the dial, not from the start of the arc. I wondered if there was any default setting to enable knobs to draw like this or whether I need to draw them myself, and I think it's the latter...







So you are actually missing tickmarks if I understand that right. I didn't see there any, but I would love the possibility to add default tickmarks (and for your case to emphasize the center position e.g.).

It's probably left to do in our own Look and Feel classes. But I'm happy if somebody corrects me :-)


He needs to create his own LookAndFeel derived from LookAndFeel_V2 and override drawRotarySlider and duplicate the LookAndFeel_V2:: drawRotarySlider() code and replace the code where it creates the filledArc Path…

            Path filledArc;
            filledArc.addPieSegment (rx, ry, rw, rw, rotaryStartAngle, angle, thickness);
            g.fillPath (filledArc);

Of course, it may be just as easy to use a Knobman LookAndFeel and have your own custom knob.



...yes I got that. But looking at the OP's images, I guess he wants rather the tickmarks than different knobs.

I was proposing, if one could enhance the standard look and feel so you can simply say

Slider::setTickmarksEnabled( bool showTickmarks );

And have the default Slider class (respectively the default LookAndFeel classes) paint tickmarks according to Slider::getMaximum(), getMinimum(), getInterval() and last but not least getSkewFactor().

Up to now I simply left tickmarks aside, but often wished to show some in one line of code. I just thought the OP and I are not the only ones who wish simple default tickmarks...


Hi guys.. thanks for the replies - I was referring to the drawing, not the tickmarks, but they're good as well...

Will check out the knobman stuff, but I think I have my answer, which is, these options are not provided by default which is what I was after...


thanks again!


ok, sorry for confusing...