|
| 1 | +Fix rendering in macOS BigSur |
| 2 | + |
| 3 | +See: https://bugreports.qt.io/browse/QTBUG-86513. |
| 4 | + |
| 5 | +Upstream commits (combined in this patch): |
| 6 | + - Qt 6.0: 40fb97e97f550b8afd13ecc3a038d9d0c2d82bbb |
| 7 | + - Qt 6.0: 3857f104cac127f62e64e55a20613f0ac2e6b843 |
| 8 | + - Qt 6.1: abee4cdd5925a8513f51784754fca8fa35031732 |
| 9 | + |
| 10 | +--- old/qtbase/src/plugins/styles/mac/qmacstyle_mac.mm |
| 11 | ++++ new/qtbase/src/plugins/styles/mac/qmacstyle_mac.mm |
| 12 | +@@ -3870,6 +3870,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter |
| 13 | + const auto cs = d->effectiveAquaSizeConstrain(opt, w); |
| 14 | + // Extra hacks to get the proper pressed appreance when not selected or selected and inactive |
| 15 | + const bool needsInactiveHack = (!isActive && isSelected); |
| 16 | ++ const bool isBigSurOrAbove = QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSBigSur; |
| 17 | + const auto ct = !needsInactiveHack && (isSelected || tp == QStyleOptionTab::OnlyOneTab) ? |
| 18 | + QMacStylePrivate::Button_PushButton : |
| 19 | + QMacStylePrivate::Button_PopupButton; |
| 20 | +@@ -3878,6 +3879,12 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter |
| 21 | + auto *pb = static_cast<NSButton *>(d->cocoaControl(cw)); |
| 22 | + |
| 23 | + auto vOffset = isPopupButton ? 1 : 2; |
| 24 | ++ if (isBigSurOrAbove) { |
| 25 | ++ // Make it 1, otherwise, offset is very visible compared |
| 26 | ++ // to selected tab (which is not a popup button). |
| 27 | ++ vOffset = 1; |
| 28 | ++ } |
| 29 | ++ |
| 30 | + if (tabDirection == QMacStylePrivate::East) |
| 31 | + vOffset -= 1; |
| 32 | + const auto outerAdjust = isPopupButton ? 1 : 4; |
| 33 | +@@ -3894,9 +3901,22 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter |
| 34 | + frameRect = frameRect.adjusted(-innerAdjust, 0, outerAdjust, 0); |
| 35 | + else |
| 36 | + frameRect = frameRect.adjusted(-outerAdjust, 0, innerAdjust, 0); |
| 37 | ++ |
| 38 | ++ if (isSelected && isBigSurOrAbove) { |
| 39 | ++ // 1 pixed of 'roundness' is still visible on the right |
| 40 | ++ // (the left is OK, it's rounded). |
| 41 | ++ frameRect = frameRect.adjusted(0, 0, 1, 0); |
| 42 | ++ } |
| 43 | ++ |
| 44 | + break; |
| 45 | + case QStyleOptionTab::Middle: |
| 46 | + frameRect = frameRect.adjusted(-innerAdjust, 0, innerAdjust, 0); |
| 47 | ++ |
| 48 | ++ if (isSelected && isBigSurOrAbove) { |
| 49 | ++ // 1 pixel of 'roundness' is still visible on both |
| 50 | ++ // sides - left and right. |
| 51 | ++ frameRect = frameRect.adjusted(-1, 0, 1, 0); |
| 52 | ++ } |
| 53 | + break; |
| 54 | + case QStyleOptionTab::End: |
| 55 | + // Pressed state hack: tweak adjustments in preparation for flip below |
| 56 | +@@ -3904,6 +3924,11 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter |
| 57 | + frameRect = frameRect.adjusted(-innerAdjust, 0, outerAdjust, 0); |
| 58 | + else |
| 59 | + frameRect = frameRect.adjusted(-outerAdjust, 0, innerAdjust, 0); |
| 60 | ++ |
| 61 | ++ if (isSelected && isBigSurOrAbove) { |
| 62 | ++ // 1 pixel of 'roundness' is still visible on the left. |
| 63 | ++ frameRect = frameRect.adjusted(-1, 0, 0, 0); |
| 64 | ++ } |
| 65 | + break; |
| 66 | + case QStyleOptionTab::OnlyOneTab: |
| 67 | + frameRect = frameRect.adjusted(-outerAdjust, 0, outerAdjust, 0); |
| 68 | +@@ -3951,7 +3976,10 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter |
| 69 | + NSPopUpArrowPosition oldPosition = NSPopUpArrowAtCenter; |
| 70 | + NSPopUpButtonCell *pbCell = nil; |
| 71 | + auto rAdjusted = r; |
| 72 | +- if (isPopupButton && tp == QStyleOptionTab::OnlyOneTab) { |
| 73 | ++ if (isPopupButton && (tp == QStyleOptionTab::OnlyOneTab || isBigSurOrAbove)) { |
| 74 | ++ // Note: starting from macOS BigSur NSPopupButton has this |
| 75 | ++ // arrow 'button' in a different place and it became |
| 76 | ++ // quite visible 'in between' inactive tabs. |
| 77 | + pbCell = static_cast<NSPopUpButtonCell *>(pb.cell); |
| 78 | + oldPosition = pbCell.arrowPosition; |
| 79 | + pbCell.arrowPosition = NSPopUpNoArrow; |
| 80 | +@@ -3959,6 +3987,10 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter |
| 81 | + // NSPopUpButton in this state is smaller. |
| 82 | + rAdjusted.origin.x -= 3; |
| 83 | + rAdjusted.size.width += 6; |
| 84 | ++ if (isBigSurOrAbove) { |
| 85 | ++ if (tp == QStyleOptionTab::End) |
| 86 | ++ rAdjusted.origin.x -= 2; |
| 87 | ++ } |
| 88 | + } |
| 89 | + } |
| 90 | + |
0 commit comments