From 6044cdfe614c15dce3064ef81d65b8a40f7d1437 Mon Sep 17 00:00:00 2001 From: "avi@chromium.org" Date: Wed, 21 Jul 2010 14:19:55 +0000 Subject: Unblackify the upgrade ball. BUG=http://crbug.com/49370 TEST=as in bug Review URL: http://codereview.chromium.org/3047005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53181 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/cocoa/gradient_button_cell.mm | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'chrome/browser/cocoa/gradient_button_cell.mm') diff --git a/chrome/browser/cocoa/gradient_button_cell.mm b/chrome/browser/cocoa/gradient_button_cell.mm index 4c3eaea..5fb8c29 100644 --- a/chrome/browser/cocoa/gradient_button_cell.mm +++ b/chrome/browser/cocoa/gradient_button_cell.mm @@ -128,6 +128,15 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; shouldTheme_ = shouldTheme; } +- (NSImage*)overlayImage { + return overlayImage_.get(); +} + +- (void)setOverlayImage:(NSImage*)image { + overlayImage_.reset([image retain]); + [[self controlView] setNeedsDisplay:YES]; +} + - (NSBackgroundStyle)interiorBackgroundStyle { // Never lower the interior, since that just leads to a weird shadow which can // often interact badly with the theme. @@ -427,8 +436,8 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; NSRectFillUsingOperation(cellFrame, NSCompositeSourceAtop); } } - CGContextEndTransparencyLayer(context); + [NSGraphicsContext restoreGraphicsState]; } else { // NSCell draws these uncentered for some reason, probably because of the @@ -436,6 +445,16 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; [super drawInteriorWithFrame:NSOffsetRect(cellFrame, 0, 1) inView:controlView]; } + + if (overlayImage_) { + NSRect imageRect = NSZeroRect; + imageRect.size = [overlayImage_ size]; + [overlayImage_ drawInRect:[self imageRectForBounds:cellFrame] + fromRect:imageRect + operation:NSCompositeSourceOver + fraction:[self isEnabled] ? 1.0 : 0.5 + neverFlipped:YES]; + } } - (NSBezierPath*)clipPathForFrame:(NSRect)cellFrame -- cgit v1.1