diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-07 19:47:36 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-07 19:47:36 +0000 |
commit | 1af62a43877f9ea42296fc3e3060f0d31d31dae6 (patch) | |
tree | 99d2c1426a58314b059b889d07717a29609457d4 /chrome | |
parent | 41861fd5c74937b13996493742e578fcd77aec28 (diff) | |
download | chromium_src-1af62a43877f9ea42296fc3e3060f0d31d31dae6.zip chromium_src-1af62a43877f9ea42296fc3e3060f0d31d31dae6.tar.gz chromium_src-1af62a43877f9ea42296fc3e3060f0d31d31dae6.tar.bz2 |
[Mac] Clean up some drawing artifacts with the new unspoofable infobars.
BUG=none
TEST=visual
Review URL: http://codereview.chromium.org/6312191
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74017 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/ui/cocoa/infobars/infobar_gradient_view.mm | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/chrome/browser/ui/cocoa/infobars/infobar_gradient_view.mm b/chrome/browser/ui/cocoa/infobars/infobar_gradient_view.mm index 6e124cc..0e7fb74 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_gradient_view.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_gradient_view.mm @@ -17,6 +17,10 @@ const double kBackgroundColorBottom[3] = {250.0 / 255.0, 230.0 / 255.0, 145.0 / 255.0}; } +@interface InfoBarGradientView (Private) +- (void)strokePath:(NSBezierPath*)path; +@end + @implementation InfoBarGradientView - (id)initWithFrame:(NSRect)frameRect { @@ -59,6 +63,7 @@ const double kBackgroundColorBottom[3] = const CGFloat curveDistance = 13.0; const CGFloat iconWidth = 29.0; const CGFloat tipPadding = 4.0; + const CGFloat pathJoinShift = 3.0; // Draw the tab bulge that acts as the anti-spoofing countermeasure. NSBezierPath* bulgePath = [NSBezierPath bezierPath]; @@ -93,30 +98,29 @@ const double kBackgroundColorBottom[3] = [infoBarPath lineToPoint:startPoint]; [infoBarPath closePath]; + // Stroke the bulge. + [bulgePath setLineCapStyle:NSSquareLineCapStyle]; + [self strokePath:bulgePath]; + // Draw the gradient. [[self gradient] drawInBezierPath:infoBarPath angle:270]; // Stroke the bottom. NSColor* strokeColor = [self strokeColor]; if (strokeColor) { - [[self strokeColor] set]; + [strokeColor set]; NSRect borderRect, contentRect; NSDivideRect(bounds, &borderRect, &contentRect, 1, NSMinYEdge); NSRectFillUsingOperation(borderRect, NSCompositeSourceOver); } - // Stroke the bulge. - [[self strokeColor] setStroke]; - [bulgePath setLineCapStyle:NSSquareLineCapStyle]; - [bulgePath stroke]; - // Stroke the horizontal line to ensure it has enough definition. - --topStrokeStart.x; - ++topStrokeEnd.x; + topStrokeStart.x -= pathJoinShift; + topStrokeEnd.x += pathJoinShift; NSBezierPath* topStroke = [NSBezierPath bezierPath]; [topStroke moveToPoint:topStrokeStart]; [topStroke lineToPoint:topStrokeEnd]; - [topStroke stroke]; + [self strokePath:topStroke]; } - (BOOL)mouseDownCanMoveWindow { @@ -136,4 +140,20 @@ const double kBackgroundColorBottom[3] = return [super accessibilityAttributeValue:attribute]; } +// Private ///////////////////////////////////////////////////////////////////// + +// Stroking paths with just |-strokeColor| will blend with the color underneath +// it and will make it appear lighter than it should. Stroke with black first to +// have the stroke color come out right. +- (void)strokePath:(NSBezierPath*)path { + [[NSGraphicsContext currentContext] saveGraphicsState]; + + [[NSColor blackColor] set]; + [path stroke]; + [[self strokeColor] set]; + [path stroke]; + + [[NSGraphicsContext currentContext] restoreGraphicsState]; +} + @end |