From 5cde07350c99d68c9d1f3d92e0a5057e2bcba0db Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 18 Apr 2017 10:41:48 -0700 Subject: 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 --- src/widgets/styles/qmacstyle_mac.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index a9aab10e0f..a3b394a291 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -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() }); -- cgit v1.2.3