From f8774c69b2b43bc6fbb8e0f229ed2635d4e78e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 18 Jul 2018 22:38:46 +0200 Subject: QMacStyle: Normalize how we call drawNSViewInRect Change-Id: I351635c7cc0bb8c852626dc3c0a3caf33b25a761 Reviewed-by: Gabriel de Dietrich --- src/plugins/styles/mac/qmacstyle_mac.mm | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 60fe547807..204b8433aa 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -3098,8 +3098,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai tf.bezeled = YES; static_cast(tf.cell).bezelStyle = isRounded ? NSTextFieldRoundedBezel : NSTextFieldSquareBezel; tf.frame = opt->rect.toCGRect(); - d->drawNSViewInRect(tf, opt->rect, p, ^(CGContextRef ctx, const CGRect &rect) { - Q_UNUSED(ctx); + d->drawNSViewInRect(tf, opt->rect, p, ^(CGContextRef, const CGRect &rect) { [tf.cell drawWithFrame:rect inView:tf]; }); } else { @@ -3430,7 +3429,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter pb.enabled = isEnabled; [pb highlight:isPressed]; pb.state = isHighlighted && !isPressed ? NSOnState : NSOffState; - d->drawNSViewInRect(pb, frameRect, p, ^(CGContextRef __unused ctx, const CGRect &r) { + d->drawNSViewInRect(pb, frameRect, p, ^(CGContextRef, const CGRect &r) { [pb.cell drawBezelWithFrame:r inView:pb.superview]; }); [pb highlight:NO]; @@ -4172,7 +4171,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter const auto cw = QMacStylePrivate::CocoaControl(ct, QStyleHelper::SizeLarge); auto *sv = static_cast(d->cocoaControl(cw)); sv.frame = opt->rect.toCGRect(); - d->drawNSViewInRect(sv, opt->rect, p, ^(CGContextRef __unused ctx, const CGRect &rect) { + d->drawNSViewInRect(sv, opt->rect, p, ^(CGContextRef, const CGRect &rect) { [sv drawDividerInRect:rect]; }); } else { @@ -5179,7 +5178,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex } pb.frame = frameRect.toCGRect(); [pb highlight:isPressed]; - d->drawNSViewInRect(pb, frameRect, p, ^(CGContextRef __unused ctx, const CGRect &r) { + d->drawNSViewInRect(pb, frameRect, p, ^(CGContextRef, const CGRect &r) { [pb.cell drawBezelWithFrame:r inView:pb.superview]; }); } else if (cw.type == QMacStylePrivate::ComboBox) { @@ -5195,7 +5194,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex // TODO Render to pixmap and darken the button manually } - d->drawNSViewInRect(cb, frameRect, p, ^(CGContextRef __unused ctx, const CGRect &r) { + d->drawNSViewInRect(cb, frameRect, p, ^(CGContextRef, const CGRect &r) { // FIXME This is usually drawn in the control's superview, but we wouldn't get inactive look in this case [cb.cell drawWithFrame:r inView:cb]; }); @@ -5267,13 +5266,10 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex Q_UNUSED(isHovered); // FIXME No public API for this const auto buttonRect = proxy()->subControlRect(CC_TitleBar, titlebar, sc, widget); - const auto drawBlock = ^ (CGContextRef ctx, const CGRect &rect) { - Q_UNUSED(ctx); - Q_UNUSED(rect); + d->drawNSViewInRect(wb, buttonRect, p, ^(CGContextRef, const CGRect &rect) { auto *wbCell = static_cast(wb.cell); [wbCell drawWithFrame:rect inView:wb]; - }; - d->drawNSViewInRect(wb, buttonRect, p, drawBlock); + }); } } @@ -5382,8 +5378,8 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex pb.enabled = isEnabled; [pb highlight:isPressed]; pb.state = isHighlighted && !isPressed ? NSOnState : NSOffState; - const auto buttonRect = proxy()->subControlRect(cc, tb, SC_ToolButton, widget); - d->drawNSViewInRect(pb, buttonRect, p, ^(CGContextRef __unused ctx, const CGRect &rect) { + const auto buttonRect = proxy()->subControlRect(cc, tb, SC_ToolButton, widget); + d->drawNSViewInRect(pb, buttonRect, p, ^(CGContextRef, const CGRect &rect) { [pb.cell drawBezelWithFrame:rect inView:pb]; }); } -- cgit v1.2.3