From cad9ba218f04bc3de14a08e93bfa2ff33164e6fd Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 4 May 2021 14:36:57 +0200 Subject: macOS, Slider: draw a focus rect, and not a focus ring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the mac style, we draw the focus ring for a slider from QML around the handle. This has shown to be fragile, since UIKit doesn't draw the handle in the center of the rect we get when we query UIKit (using the [cell knobRectFlipped:slider.isFlipped]). And then the focus ring will be offset as well. While we could try to adjust the rect manually from QQuickMacStyle, this will only be quaranteed to work on top of the current macOS SDK (macosx11.1). So for that reason, this patch falls back to use the less correct, but more future safe, solution of drawng the focus ring as a rect around the handle instead. While this doesn't look native, it still looks better (and correct, for the uninformed) compared to an eliptic ring that is misplaced on the target. Fixes: QTBUG-93423 Pick-to: 6.1 6.0 Change-Id: Ibc00f12f9606cd66c8ff384967aa3ea0d7727964 Reviewed-by: Jan Arve Sæther --- src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/imports') diff --git a/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm b/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm index 47fac5b3..5d061667 100644 --- a/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm +++ b/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm @@ -2227,8 +2227,11 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt) const ret = 10; break; case PM_SliderFocusFrameRadius: - if (const QStyleOptionSlider *sliderOpt = qstyleoption_cast(opt)) - ret = sliderOpt->tickPosition == QStyleOptionSlider::NoTicks ? 10 : 3; + // QTBUG-93423: We currently need to skip drawing a focus ring around the handle, since + // the handle drawn by the UIKit is not centered inside the rect we get from calling + // [cell knobRectFlipped:slider.isFlipped]. So we choose to draw the focus as + // a rect instead until we have a better solution available. + ret = 0; break; case PM_DialFocusFrameRadius: case PM_SpinBoxFocusFrameRadius: -- cgit v1.2.3