Fix CC_Slider rendering on macOS
QSlider rendering is currently broken as the context used to render it is not properly translated. This patch fixes that. Fixes: QTBUG-72970 Change-Id: I30896ceee1f37f6dfcf01a342d10af3bb279ac8a Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
7cf9f4e3d3
commit
036e9d66f5
@ -5273,9 +5273,20 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
|
|||||||
}
|
}
|
||||||
|
|
||||||
d->drawNSViewInRect(slider, opt->rect, p, ^(CGContextRef ctx, const CGRect &rect) {
|
d->drawNSViewInRect(slider, opt->rect, p, ^(CGContextRef ctx, const CGRect &rect) {
|
||||||
if (isHorizontal && sl->upsideDown) {
|
|
||||||
CGContextTranslateCTM(ctx, rect.size.width, 0);
|
// Since the GC is flipped, upsideDown means *not* inverted when vertical.
|
||||||
CGContextScaleCTM(ctx, -1, 1);
|
const bool verticalFlip = !isHorizontal && !sl->upsideDown; // FIXME: && !isSierraOrLater
|
||||||
|
|
||||||
|
if (isHorizontal) {
|
||||||
|
if (sl->upsideDown) {
|
||||||
|
CGContextTranslateCTM(ctx, rect.size.width, rect.origin.y);
|
||||||
|
CGContextScaleCTM(ctx, -1, 1);
|
||||||
|
} else {
|
||||||
|
CGContextTranslateCTM(ctx, 0, rect.origin.y);
|
||||||
|
}
|
||||||
|
} else if (verticalFlip) {
|
||||||
|
CGContextTranslateCTM(ctx, rect.origin.x, rect.size.height);
|
||||||
|
CGContextScaleCTM(ctx, 1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasDoubleTicks) {
|
if (hasDoubleTicks) {
|
||||||
@ -5286,9 +5297,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
|
|||||||
CGContextTranslateCTM(ctx, 1, 0);
|
CGContextTranslateCTM(ctx, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since the GC is flipped, upsideDown means *not* inverted when vertical.
|
|
||||||
const bool verticalFlip = !isHorizontal && !sl->upsideDown; // FIXME: && !isSierraOrLater
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// FIXME: Sadly, this part doesn't work. It seems to somehow polute the
|
// FIXME: Sadly, this part doesn't work. It seems to somehow polute the
|
||||||
// NSSlider's internal state and, when we need to use the "else" part,
|
// NSSlider's internal state and, when we need to use the "else" part,
|
||||||
@ -5352,9 +5360,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
|
|||||||
// This ain't HIG kosher: force round knob look.
|
// This ain't HIG kosher: force round knob look.
|
||||||
if (hasDoubleTicks)
|
if (hasDoubleTicks)
|
||||||
slider.numberOfTickMarks = 0;
|
slider.numberOfTickMarks = 0;
|
||||||
// Draw the knob in the symmetrical position instead of flipping.
|
|
||||||
if (verticalFlip)
|
|
||||||
slider.intValue = slider.maxValue - slider.intValue + slider.minValue;
|
|
||||||
[cell drawKnob];
|
[cell drawKnob];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user