Different behavior of fillRect on Windows and OSX



This code below, an extract from the vertical slider header, behaves different on Windows and OSX.

if (slider.isMouseOverOrDragging())
g.setColour (Colour(205,205,205));
g.fillRect(float(x),float(y+height),10.f,float((sliderPos - minSliderPos)));
} else {
g.setColour (sliderActivePart);
g.fillRect(float(x),float(y+height),10.f,float((sliderPos - minSliderPos)));

The project code in total is the exact copy between OSX and Windows. As you see the Windows version shows dash lines where the OSX version has the full vertical slider look.

Any idea how this can be fixed ? I have tried to place numbers as parameters however coudln’t progress further.



(if you indent your code by 4 spaces, the forum displays it correctly)

You’re not just trying to draw a rectangle with a negative height, are you?



The values are positive, but in any case I have tried to fill in flat numbers to be sure. The behavior is the same. I can put negative numbers to check how it looks in OSX though !


Well, I can’t really think of a reason why a function as ubiquitous as fillRect would do anything strange, unless you’re feeding it silly numbers… Maybe try to create a short test-case piece of code that we could try, which reproduces the problem.


OK, I will tell if I can fix it. At least it is good to know what gets tolerated on OSX and not in Windows.


Well, if you are just feeding it incorrect numbers then we should add an assertion to catch that, so that nobody does anything that isn’t the same on all platforms.


Hi, this worked as a fix both on OSX and Windows;


Still there is a weird situation in the behavior. At the first code case, I was trying to start at the bottom (screen wise ) of the defined rectangle area and slide the rectangle towards to upper part of the screen.

Now I start to draw from the upper part towards to bottom part. And I don’t think there are any negative numbers in both cases.

I am not sure if I clearly understand the LinearVertical Slider type however after the experiments this was the solution which works both on OSX and Windows.


There’s nothing weird about it - like I said in my first reply, you’re obviously passing in negative height values.

If you had been running in debug mode, you would have hit an assertion in coordsToRectangle() to warn you about the coords being out-of-bounds, as this is undefined behaviour.