IncDecButtons not properly sized

I’m using a custom LookAndFeel class to draw the buttons for an IncDecButton widget. The size I set does not correspond to the drawn buttons, and I can’t figure out how to change this, as there is no way to control the size of the buttons when createSliderButton is called.

This is easier to show than to tell.


Here is the corresponding code

The buttons on the left are what I expect to happen, the buttons on the right are what happens when I set the slider size to be twice the width of my buttons and the same height. As you can see, the dimensions are not equal and the text is not centered in each button.

My only solutions have been to figure out by trial and error how to place/size my sliders to be the correct height/width, or to roll my own IncDecButton class.

So is there an easier way to control the actual size of the buttons, without having to copy the slider class or work by trial and error?

bump?

Well, this is what it does…

What is the reason for this code: buttonRect.expand (0, -2);? I see that’s what’s causing my problem, but why is there a 2 pixel horizontal shrink hardcoded into the drawing?

Yeah, it’s pretty ancient code, probably needs to be shuffled into the look+feel classes instead