summaryrefslogtreecommitdiffstats
path: root/src/plugins/styles
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2020-10-22 15:18:29 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-10-28 04:55:07 +0000
commit1bb225211c91f3c90fc2f84e269c398a8fdba2c7 (patch)
tree914e3a32dfca3d9ad928fc7a9dfbaca6081b5f6a /src/plugins/styles
parente6993df95eb12597ea2241559f49927d03db7a34 (diff)
QMacStyle - fix tab rendering
In BigSur NSPopupButton, it would appear, is slightly different. But different enough so that a fragment of a disclose 'arrow' button became visible within the clipping region, making it appear as some blue strange thing in between inactive (non-selected) tabs. Task-number: QTBUG-86513 Change-Id: Ib03af48069056b5ecbb8b4afebd851005583293a Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit 40fb97e97f550b8afd13ecc3a038d9d0c2d82bbb) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/plugins/styles')
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac.mm18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm
index d1febd81d4..6b74205fda 100644
--- a/src/plugins/styles/mac/qmacstyle_mac.mm
+++ b/src/plugins/styles/mac/qmacstyle_mac.mm
@@ -3870,6 +3870,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
const auto cs = d->effectiveAquaSizeConstrain(opt, w);
// Extra hacks to get the proper pressed appreance when not selected or selected and inactive
const bool needsInactiveHack = (!isActive && isSelected);
+ const bool isBigSurOrAbove = QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSBigSur;
const auto ct = !needsInactiveHack && (isSelected || tp == QStyleOptionTab::OnlyOneTab) ?
QMacStylePrivate::Button_PushButton :
QMacStylePrivate::Button_PopupButton;
@@ -3878,6 +3879,12 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
auto *pb = static_cast<NSButton *>(d->cocoaControl(cw));
auto vOffset = isPopupButton ? 1 : 2;
+ if (isBigSurOrAbove) {
+ // Make it 1, otherwise, offset is very visible compared
+ // to selected tab (which is not a popup button).
+ vOffset = 1;
+ }
+
if (tabDirection == QMacStylePrivate::East)
vOffset -= 1;
const auto outerAdjust = isPopupButton ? 1 : 4;
@@ -3951,7 +3958,10 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
NSPopUpArrowPosition oldPosition = NSPopUpArrowAtCenter;
NSPopUpButtonCell *pbCell = nil;
auto rAdjusted = r;
- if (isPopupButton && tp == QStyleOptionTab::OnlyOneTab) {
+ if (isPopupButton && (tp == QStyleOptionTab::OnlyOneTab || isBigSurOrAbove)) {
+ // Note: starting from macOS BigSur NSPopupButton has this
+ // arrow 'button' in a different place and it became
+ // quite visible 'in between' inactive tabs.
pbCell = static_cast<NSPopUpButtonCell *>(pb.cell);
oldPosition = pbCell.arrowPosition;
pbCell.arrowPosition = NSPopUpNoArrow;
@@ -3959,6 +3969,12 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
// NSPopUpButton in this state is smaller.
rAdjusted.origin.x -= 3;
rAdjusted.size.width += 6;
+ if (isBigSurOrAbove) {
+ rAdjusted.origin.y -= 1;
+ rAdjusted.size.height += 1;
+ if (tp == QStyleOptionTab::End)
+ rAdjusted.origin.x -= 2;
+ }
}
}