| Index: chrome/browser/cocoa/gradient_button_cell.mm
|
| ===================================================================
|
| --- chrome/browser/cocoa/gradient_button_cell.mm (revision 21106)
|
| +++ chrome/browser/cocoa/gradient_button_cell.mm (working copy)
|
| @@ -6,6 +6,12 @@
|
| #import "third_party/GTM/AppKit/GTMTheme.h"
|
| #import "base/scoped_nsobject.h"
|
|
|
| +@interface GradientButtonCell (Private)
|
| +- (void)drawUnderlayImageWithFrame:(NSRect)cellFrame
|
| + inView:(NSView*)controlView;
|
| +@end
|
| +
|
| +
|
| @implementation GradientButtonCell
|
|
|
| // For nib instantiations
|
| @@ -28,6 +34,16 @@
|
| shouldTheme_ = shouldTheme;
|
| }
|
|
|
| +- (NSImage*)underlayImage {
|
| + return underlayImage_;
|
| +}
|
| +
|
| +- (void)setUnderlayImage:(NSImage*)image {
|
| + underlayImage_.reset([image retain]);
|
| +
|
| + [[self controlView] setNeedsDisplay:YES];
|
| +}
|
| +
|
| - (NSBackgroundStyle)interiorBackgroundStyle {
|
| return [self isHighlighted] ?
|
| NSBackgroundStyleLowered : NSBackgroundStyleRaised;
|
| @@ -207,6 +223,8 @@
|
| [shadow set];
|
| }
|
|
|
| + [self drawUnderlayImageWithFrame:cellFrame inView:controlView];
|
| +
|
| CGContextBeginTransparencyLayer(context, 0);
|
| NSRect imageRect = NSZeroRect;
|
| imageRect.size = [[self image] size];
|
| @@ -225,6 +243,8 @@
|
| CGContextEndTransparencyLayer(context);
|
| [NSGraphicsContext restoreGraphicsState];
|
| } else {
|
| + [self drawUnderlayImageWithFrame:cellFrame inView:controlView];
|
| +
|
| // NSCell draws these uncentered for some reason, probably because of the
|
| // of control in the xib
|
| [super drawInteriorWithFrame:NSOffsetRect(cellFrame, 0, 1)
|
| @@ -232,4 +252,17 @@
|
| }
|
| }
|
|
|
| +- (void)drawUnderlayImageWithFrame:(NSRect)cellFrame
|
| + inView:(NSView*)controlView {
|
| + if (underlayImage_) {
|
| + NSRect imageRect = NSZeroRect;
|
| + imageRect.size = [underlayImage_ size];
|
| + [underlayImage_ setFlipped:[controlView isFlipped]];
|
| + [underlayImage_ drawInRect:[self imageRectForBounds:cellFrame]
|
| + fromRect:imageRect
|
| + operation:NSCompositeSourceOver
|
| + fraction:[self isEnabled] ? 1.0 : 0.5];
|
| + }
|
| +}
|
| +
|
| @end
|
|
|