Slider thumb get top/bottom clipped by component boundaries


#1

Tinkering with LookandFeel of sliders:

As an experiment in my own LookandFeel class, I have overridden the slider functions where I have resized the thumb radius vertically - all is well except that it get clipped (top and bottom) - the new thumb size I have is the size I need for my experiment but after hours of trial and errors I haven’t been able to figure out how to increase the gap between the min and max position of the thumb so it is not clipped by the boundaries of the component - what am I missing? any help, guidance, example would be greatly appreciated.

Thanks in advance :slight_smile:


#2

Well, it’s impossible to draw beyond the edges of a component… If you need a bigger thumb, you need to make the scrollbar bigger to fit it.


#3

Thank you Jules for your prompt reply, greatly appreciated.

I am still stuck though and re-reading my first post, I am not sure it was actually very explicit of what I am after, I am therefore rephrasing it in more details here - please bear with me - thank you :slight_smile:

From what I understand, when a slider’s bounds (in my case, a vertical slider) is set to a specific dimension, all its inner elements are sized relatively to these dimensions. The default gap between the top and bottom of the track and the top and bottom of the sliders component’s boundaries seems to be somewhat too small to accommodate taller than large thumbs.

So, really, what I am after is a way (either via a parameter or calculation in the slider and/or preferably the L&F class) to reduce or interact directly with the length of a slider’s track (without altering its range and independently of the slider’s global bounds) so any non 1:1 ratio Thumb buttons can be accommodated to fit within the boundaries of the slider component without been cropped.
What would be the best way to achieve this ?

Thanks again in advance for your time :slight_smile:


#4

I’d have thought you could just return a large value from LookAndFeel::getSliderThumbRadius() (i.e. a value that’s too wide to fit, but it the length you want) and then draw the thumb appropriately…?


#5

Yayyy!! thank you Jules, you hit the nail on the head and put me on the right track :slight_smile:

The reason I had so many problems is because I bypassed and didn’t override the getSliderThumbRadius() function in my own L&F class and functions thinking it was used by my L&F functions only and not by the slider component itself as well.
The default dimension of 9 was therefore always returned by the default LookAndFeel::getSliderThumbRadius() to the slider component which of course was not enough to handle the taller size of my thumb and was getting cropped in the process - :roll:

Well sorry for the waste of time - thanks again for your patience and guidance - all the best!!