QMacStyle: Remove HITheme calls for QSizeGrip

That's no longer a thing on macOS. We still keep it around for
QMdiSubWindow, but we should support 4-edge resizing there as
do native windows.

In practice, because of WA_MacOpaqueSizeGrip, we were already
rendering the size grip manually instead of relying on HITheme.

Change-Id: If613a14f03dc650b457688f3f2f57631b5fb30a3
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
This commit is contained in:
Gabriel de Dietrich 2017-08-30 11:53:59 +07:00
parent d47a467ca6
commit b8947e9194

View File

@ -928,24 +928,15 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
break; break;
} }
case QStyle::CT_SizeGrip: case QStyle::CT_SizeGrip:
// Not HIG kosher: mimic what we were doing earlier until we support 4-edge resizing in MDI subwindows
if (sz == QStyleHelper::SizeLarge || sz == QStyleHelper::SizeSmall) { if (sz == QStyleHelper::SizeLarge || sz == QStyleHelper::SizeSmall) {
CGRect r; int s = sz == QStyleHelper::SizeSmall ? 16 : 22; // large: pixel measured from HITheme, small: from my hat
CGPoint p = { 0, 0 }; int width = 0;
HIThemeGrowBoxDrawInfo gbi;
gbi.version = 0;
gbi.state = kThemeStateActive;
gbi.kind = kHIThemeGrowBoxKindNormal;
gbi.direction = QApplication::isRightToLeft() ? kThemeGrowLeft | kThemeGrowDown
: kThemeGrowRight | kThemeGrowDown;
gbi.size = sz == QStyleHelper::SizeSmall ? kHIThemeGrowBoxSizeSmall : kHIThemeGrowBoxSizeNormal;
if (HIThemeGetGrowBoxBounds(&p, &gbi, &r) == noErr) {
int width = 0;
#if QT_CONFIG(mdiarea) #if QT_CONFIG(mdiarea)
if (widg && qobject_cast<QMdiSubWindow *>(widg->parentWidget())) if (widg && qobject_cast<QMdiSubWindow *>(widg->parentWidget()))
width = r.size.width; width = s;
#endif #endif
ret = QSize(width, r.size.height); ret = QSize(width, s);
}
} }
break; break;
case QStyle::CT_ComboBox: case QStyle::CT_ComboBox:
@ -4510,39 +4501,35 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
} }
break; break;
case CE_SizeGrip: { case CE_SizeGrip: {
if (w && w->testAttribute(Qt::WA_MacOpaqueSizeGrip)) { // This is not HIG kosher: Fall back to the old stuff until we decide what to do.
HIThemeGrowBoxDrawInfo gdi; #ifndef QT_NO_MDIAREA
gdi.version = qt_mac_hitheme_version; if (!w || !qobject_cast<QMdiSubWindow *>(w->parentWidget()))
gdi.state = tds; #endif
gdi.kind = kHIThemeGrowBoxKindNormal; break;
gdi.direction = kThemeGrowRight | kThemeGrowDown;
gdi.size = kHIThemeGrowBoxSizeNormal; if (w->testAttribute(Qt::WA_MacOpaqueSizeGrip))
CGPoint pt = CGPointMake(opt->rect.x(), opt->rect.y()); p->fillRect(opt->rect, opt->palette.window());
HIThemeDrawGrowBox(&pt, &gdi, cg, kHIThemeOrientationNormal);
} else { QPen lineColor = QColor(82, 82, 82, 192);
// It isn't possible to draw a transparent size grip with the lineColor.setWidth(1);
// native API, so we do it ourselves here. p->save();
QPen lineColor = QColor(82, 82, 82, 192); p->setRenderHint(QPainter::Antialiasing);
lineColor.setWidth(1); p->setPen(lineColor);
p->save(); const Qt::LayoutDirection layoutDirection = w ? w->layoutDirection() : qApp->layoutDirection();
p->setRenderHint(QPainter::Antialiasing); const int NumLines = 3;
p->setPen(lineColor); for (int l = 0; l < NumLines; ++l) {
const Qt::LayoutDirection layoutDirection = w ? w->layoutDirection() : qApp->layoutDirection(); const int offset = (l * 4 + 3);
const int NumLines = 3; QPoint start, end;
for (int l = 0; l < NumLines; ++l) { if (layoutDirection == Qt::LeftToRight) {
const int offset = (l * 4 + 3); start = QPoint(opt->rect.width() - offset, opt->rect.height() - 1);
QPoint start, end; end = QPoint(opt->rect.width() - 1, opt->rect.height() - offset);
if (layoutDirection == Qt::LeftToRight) { } else {
start = QPoint(opt->rect.width() - offset, opt->rect.height() - 1); start = QPoint(offset, opt->rect.height() - 1);
end = QPoint(opt->rect.width() - 1, opt->rect.height() - offset); end = QPoint(1, opt->rect.height() - offset);
} else {
start = QPoint(offset, opt->rect.height() - 1);
end = QPoint(1, opt->rect.height() - offset);
}
p->drawLine(start, end);
} }
p->restore(); p->drawLine(start, end);
} }
p->restore();
break; break;
} }
case CE_Splitter: case CE_Splitter: