QMacStyle: Fix focus frame rendering in Yosemite

Using the HITheme API would result in the frame's right edge
to be missing.

Instead, we use the recommended technique to draw the focus 
ring around a custom NSCell. (See 
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ControlCell/Articles/ManipulateCellControl.html)

Change-Id: I12d4834d353b5cbd5893bf070b14ad0d8bb75634
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
Gabriel de Dietrich 2014-06-30 16:29:32 +02:00 committed by Morten Johan Sørvig
parent 90053954b8
commit 769af66893

View File

@ -4044,11 +4044,20 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
}
break;
case CE_FocusFrame: {
int xOff = proxy()->pixelMetric(PM_FocusFrameHMargin, opt, w) + 1;
int yOff = proxy()->pixelMetric(PM_FocusFrameVMargin, opt, w) + 1;
HIRect hirect = CGRectMake(xOff+opt->rect.x(), yOff+opt->rect.y(), opt->rect.width() - 2 * xOff,
int xOff = proxy()->pixelMetric(PM_FocusFrameHMargin, opt, w);
int yOff = proxy()->pixelMetric(PM_FocusFrameVMargin, opt, w);
NSRect rect = NSMakeRect(xOff+opt->rect.x(), yOff+opt->rect.y(), opt->rect.width() - 2 * xOff,
opt->rect.height() - 2 * yOff);
HIThemeDrawFocusRect(&hirect, true, QMacCGContext(p), kHIThemeOrientationNormal);
CGContextSaveGState(cg);
[NSGraphicsContext setCurrentContext:[NSGraphicsContext
graphicsContextWithGraphicsPort:(CGContextRef)cg flipped:NO]];
[NSGraphicsContext saveGraphicsState];
NSSetFocusRingStyle(NSFocusRingOnly);
NSBezierPath *focusFramePath = [NSBezierPath bezierPathWithRect:rect];
[focusFramePath setClip]; // Clear clip path to avoid artifacts when rendering the cursor at zero pos
[focusFramePath fill];
[NSGraphicsContext restoreGraphicsState];
CGContextRestoreGState(cg);
break; }
case CE_MenuItem:
case CE_MenuEmptyArea: