Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(763)

Unified Diff: chrome/browser/cocoa/gradient_button_cell.mm

Issue 155851: Add theme support for the yellow star on the Mac.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/gradient_button_cell.h ('k') | chrome/browser/cocoa/toolbar_controller.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « chrome/browser/cocoa/gradient_button_cell.h ('k') | chrome/browser/cocoa/toolbar_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698