QMacStyle: Properly flip vertical sliders

Cocoa is better than us at vertically flipping views,
so we use that API instead of fiddling with the graphics
context transforms. But only so from 10.12 onwards. Go
figure.

This also fixes a one pixel offset with horizontal sliders
handle on non-retina displays.

Change-Id: Ia3da8431ad0499a4b6fb7bf6973ed353d91c2905
Task-number: QTBUG-59666
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
This commit is contained in:
Gabriel de Dietrich 2017-04-18 10:41:48 -07:00
parent 9cad7b6eac
commit 5cde07350c

View File

@ -5564,16 +5564,18 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
sl.intValue = slider->sliderValue;
sl.enabled = slider->state & QStyle::State_Enabled;
d->drawNSViewInRect(cw, sl, opt->rect, p, widget != 0, ^(NSRect rect, CGContextRef ctx) {
const bool isSierraOrLater = QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSSierra;
if (slider->upsideDown) {
if (isHorizontal) {
CGContextTranslateCTM(ctx, rect.size.width, 0);
CGContextScaleCTM(ctx, -1, 1);
}
} else if (!isHorizontal) {
} else if (!isHorizontal && !isSierraOrLater) {
CGContextTranslateCTM(ctx, 0, rect.size.height);
CGContextScaleCTM(ctx, 1, -1);
}
[sl.cell drawBarInside:NSRectFromCGRect(tdi.bounds) flipped:NO];
const bool shouldFlip = isHorizontal || (slider->upsideDown && isSierraOrLater);
[sl.cell drawBarInside:NSRectFromCGRect(tdi.bounds) flipped:shouldFlip];
// No need to restore the CTM later, the context has been saved
// and will be restored at the end of drawNSViewInRect()
});