summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@qt.io>2017-04-18 10:41:48 -0700
committerGabriel de Dietrich <gabriel.dedietrich@qt.io>2017-04-21 16:52:22 +0000
commit5cde07350c99d68c9d1f3d92e0a5057e2bcba0db (patch)
tree76e70c5ee56a0194dfa0b721a60541fe22c68d6a
parent9cad7b6eac9aba1d70069af4d59f73697deeb2b0 (diff)
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>
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm6
1 files 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()
});