macOS: Don't assume NSSlider is never flipped
We need to take into account the possibility that the slider is flipped, otherwise we end up with inverted rects, as noticed in Big Sur. The logic to use the ticks as input to whether the bar rect should be inverted didn't make sense. If the graphics context has been flipped, then we should reflect that through the slider. Pick-to: 5.15 Pick-to: 5.12 Change-Id: I3574027c14807460affb42a9763211981c4ed528 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>bb10
parent
7c1f94f387
commit
e4f647e272
|
|
@ -506,7 +506,7 @@ static void fixStaleGeometry(NSSlider *slider)
|
|||
return;
|
||||
|
||||
NSSliderCell *cell = slider.cell;
|
||||
const NSRect barRect = [cell barRectFlipped:NO];
|
||||
const NSRect barRect = [cell barRectFlipped:slider.isFlipped];
|
||||
const NSSize sliderSize = slider.frame.size;
|
||||
CGFloat difference = 0.;
|
||||
if (slider.vertical)
|
||||
|
|
@ -5328,7 +5328,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
|
|||
|
||||
CGPoint pressPoint;
|
||||
if (isPressed) {
|
||||
const CGRect knobRect = [slider.cell knobRectFlipped:NO];
|
||||
const CGRect knobRect = [slider.cell knobRectFlipped:slider.isFlipped];
|
||||
pressPoint.x = CGRectGetMidX(knobRect);
|
||||
pressPoint.y = CGRectGetMidY(knobRect);
|
||||
[slider.cell startTrackingAt:pressPoint inView:slider];
|
||||
|
|
@ -5386,7 +5386,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
|
|||
if (hasDoubleTicks)
|
||||
slider.numberOfTickMarks = 0;
|
||||
|
||||
const CGRect barRect = [cell barRectFlipped:hasTicks];
|
||||
const CGRect barRect = [cell barRectFlipped:slider.isFlipped];
|
||||
if (drawBar) {
|
||||
if (!isHorizontal && !sl->upsideDown && (hasDoubleTicks || !hasTicks)) {
|
||||
// The logic behind verticalFlip and upsideDown is the twisted one.
|
||||
|
|
@ -5773,8 +5773,8 @@ QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc,
|
|||
break;
|
||||
|
||||
NSSliderCell *cell = slider.cell;
|
||||
const auto barRect = QRectF::fromCGRect([cell barRectFlipped:hasTicks]);
|
||||
const auto knobRect = QRectF::fromCGRect([cell knobRectFlipped:NO]);
|
||||
const auto barRect = QRectF::fromCGRect([cell barRectFlipped:slider.isFlipped]);
|
||||
const auto knobRect = QRectF::fromCGRect([cell knobRectFlipped:slider.isFlipped]);
|
||||
if (knobRect.contains(pt)) {
|
||||
sc = SC_SliderHandle;
|
||||
} else if (barRect.contains(pt)) {
|
||||
|
|
@ -5878,7 +5878,7 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
|
|||
|
||||
NSSliderCell *cell = slider.cell;
|
||||
if (sc == SC_SliderHandle) {
|
||||
ret = QRectF::fromCGRect([cell knobRectFlipped:NO]).toRect();
|
||||
ret = QRectF::fromCGRect([cell knobRectFlipped:slider.isFlipped]).toRect();
|
||||
if (isHorizontal) {
|
||||
ret.setTop(sl->rect.top());
|
||||
ret.setBottom(sl->rect.bottom());
|
||||
|
|
@ -5887,7 +5887,7 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
|
|||
ret.setRight(sl->rect.right());
|
||||
}
|
||||
} else if (sc == SC_SliderGroove) {
|
||||
ret = QRectF::fromCGRect([cell barRectFlipped:hasTicks]).toRect();
|
||||
ret = QRectF::fromCGRect([cell barRectFlipped:slider.isFlipped]).toRect();
|
||||
} else if (hasTicks && sc == SC_SliderTickmarks) {
|
||||
const auto tickMarkRect = QRectF::fromCGRect([cell rectOfTickMarkAtIndex:0]);
|
||||
if (isHorizontal)
|
||||
|
|
|
|||
Loading…
Reference in New Issue