Big Wacky Sliders


#1

I’m making some waqcky big sliders for touchscreen use. Problem is, they seem to get very small when I increase the sliderthumb size (in a look and feel class).

Am I the only one making big sliders and to run into this?

The problem seems to be that the slider does this:

const int indent = getLookAndFeel().getSliderThumbRadius (*this) + 2;

Which seems redundant, since another set of code then makes sure the slider and thumb draw within the slider rect. So this may have been there a while? I’m guessing that this:

int LookAndFeel::getSliderThumbRadius (Slider& slider) { return jmin (7, slider.getHeight() / 2, slider.getWidth() / 2); }
has forced it to ‘7’ for a while.

Jules, can we ‘fix’ this? Would it break anything else? Seems like the ‘7’ is just working as a hard-coded minimum amount of breathing room around the slider. If in Slider::resized we set an indent (used to inset the slider itself) then the demo seems OK but my app overlaps:

What would the real fix be?

Bruce


#2

It’s not quite that simple - the resize() callback needs to define the sliderRect region correctly so that the mouse dragging matches what gets drawn. Isn’t it enough to write a l+f that removes the 7 from the getSliderThumbRadius?


#3

Well, I wanted a big thumb, so I used the current L+F draw and overrode the draw background and draw thumb. With that and a large thumb radius, it works the way I want except for the smaller rect.

The mouse and thumb do match though. It seems as if the slider thumb radius is doing 2 jobs? I’m not seeing the design. I used radius so that my thumb is always inside the background, and that works.

Otherwise I’d have to do that math myself. Do you see what I’m getting at?

Bruce


#4

erm… sorry, I think I’m probably being a bit dumb, can’t see what you mean…


#5

No, it’s a bit odd all round, and I don’t quite get it.

OK, so I tried to mod the standard L+F to demonstrate what I mean, and just changing the thumb size does what I’d expect. Shoot.

So maybe I’m just messing up. Can I just get advice then - if I want my thumb to always be within the background ‘channel’ do I want to change the thumb radius or just draw a bigger thumb?

Bruce

PS OK, probably/certainly I’m messing up


#6

I’d say that if you want it inside the channel thing, then draw a bigger channel rather than a smaller thumb.