Fixed: broken corners on primary CPBox in Chrome.

In Chrome, a primary CPBox (showing the new recessed rounded corner look) had distorted and jagged edges in Chrome due to the clipping mask.

This fix places the clipping mask on integer coordinates which seems to resolve the problem.
This commit is contained in:
Alexander Ljungberg committed 2013-02-04 15:40:01 +00:00
1 parent d049d067ab
commit 3d9b69a860
3 files changed
+17 -14

No files matched your search

+13 -12
View File
@@ -504,22 +504,26 @@ CPBelowBottom = 6;
shadowSize = [self valueForThemeAttribute:@"inner-shadow-size"],
shadowColor = [self valueForThemeAttribute:@"inner-shadow-color"];
var baseRect = aRect;
aRect = CGRectInset(aRect, borderWidth / 2.0, borderWidth / 2.0);
// clip the canvas to the actual content view in order to only display inner shadow
CGContextBeginPath(context);
CGContextAddPath(context, CGPathWithRoundedRectangleInRect(aRect, cornerRadius, cornerRadius, YES, YES, YES, YES));
CGContextClip(context);
CGContextSaveGState(context);
CGContextSetFillColor(context, [self fillColor]);
CGContextSetStrokeColor(context, [self borderColor]);
CGContextSetShadowWithColor(context, shadowOffset, shadowSize, shadowColor);
CGContextSetLineWidth(context, borderWidth);
CGContextSetFillColor(context, [self fillColor]);
CGContextFillRoundedRectangleInRect(context, aRect, cornerRadius, YES, YES, YES, YES);
CGContextStrokeRoundedRectangleInRect(context, aRect, cornerRadius, YES, YES, YES, YES);
}
CGContextBeginPath(context);
// Note we can't use the 0.5 inset rectangle when setting up clipping. The clipping has to be
// on integer coordinates for this to look right in Chrome.
CGContextAddPath(context, CGPathWithRoundedRectangleInRect(baseRect, cornerRadius, cornerRadius, YES, YES, YES, YES));
CGContextClip(context);
CGContextSetShadowWithColor(context, shadowOffset, shadowSize, shadowColor);
CGContextStrokeRoundedRectangleInRect(context, aRect, cornerRadius, YES, YES, YES, YES);
CGContextRestoreGState(context);
}
- (void)_drawNoBorderInRect:(CGRect)aRect
{
@@ -529,9 +533,6 @@ CPBelowBottom = 6;
CGContextFillRect(context, aRect);
}
@end
var CPBoxTypeKey = @"CPBoxTypeKey",
+2 -2
View File
@@ -18,12 +18,12 @@
@outlet CPScrollView mainScrollView;
}
- (void)awakeFromCib
{
[self makeRedViews];
[[theWindow contentView] setBackgroundColor:[[CPColor greenColor] colorWithAlphaComponent:0.25]];
[documentView setBackgroundColor:[CPColor whiteColor]];
[mainScrollView setDocumentView:documentView];
[theWindow setFullPlatformWindow:YES];
+2
View File
@@ -4,6 +4,8 @@
<dict>
<key>Main cib file base name</key>
<string>MainMenu.cib</string>
<key>CPDefaultTheme</key>
<string>Aristo2</string>
<key>CPBundleName</key>
<string>CPBox</string>
</dict>