Chromium Code Reviews| Index: ui/app_list/cocoa/apps_grid_view_item.mm |
| diff --git a/ui/app_list/cocoa/apps_grid_view_item.mm b/ui/app_list/cocoa/apps_grid_view_item.mm |
| index e09065257b1f1e7df94c847077757df45f404750..44484875a4b703391117aef7f4faf2afbed94b0f 100644 |
| --- a/ui/app_list/cocoa/apps_grid_view_item.mm |
| +++ b/ui/app_list/cocoa/apps_grid_view_item.mm |
| @@ -14,6 +14,7 @@ |
| #include "ui/base/resource/resource_bundle.h" |
| #include "ui/gfx/image/image_skia_util_mac.h" |
| #include "ui/gfx/font.h" |
| +#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| namespace { |
| @@ -90,6 +91,18 @@ void ItemModelObserverBridge::ItemPercentDownloadedChanged() { |
| @end |
| +@interface AppsGridItemButtonCell : NSButtonCell { |
| + @private |
| + BOOL hasShadow_; |
| +} |
| + |
| +@property(assign, nonatomic) BOOL hasShadow; |
| + |
| +@end |
| + |
| +@interface AppsGridItemButton : NSButton; |
| +@end |
| + |
| @implementation AppsGridItemBackgroundView |
| - (NSButton*)button { |
| @@ -149,8 +162,8 @@ void ItemModelObserverBridge::ItemPercentDownloadedChanged() { |
| - (id)initWithSize:(NSSize)tileSize { |
| if ((self = [super init])) { |
| - scoped_nsobject<NSButton> prototypeButton( |
| - [[NSButton alloc] initWithFrame:NSMakeRect( |
| + scoped_nsobject<AppsGridItemButton> prototypeButton( |
| + [[AppsGridItemButton alloc] initWithFrame:NSMakeRect( |
| 0, 0, tileSize.width, tileSize.height - kTileTopPadding)]); |
| // This NSButton style always positions the icon at the very top of the |
| @@ -182,6 +195,7 @@ void ItemModelObserverBridge::ItemPercentDownloadedChanged() { |
| NSButton* button = [self button]; |
| [button setTitle:base::SysUTF8ToNSString(itemModel->title())]; |
| [button setImage:gfx::NSImageFromImageSkia(itemModel->icon())]; |
| + [[button cell] setHasShadow:itemModel->has_shadow()]; |
| observerBridge_.reset(new app_list::ItemModelObserverBridge(self, itemModel)); |
| if (trackingArea_.get()) |
| @@ -225,3 +239,39 @@ void ItemModelObserverBridge::ItemPercentDownloadedChanged() { |
| } |
| @end |
| + |
| +@implementation AppsGridItemButton |
| + |
| ++ (Class)cellClass { |
| + return [AppsGridItemButtonCell class]; |
| +} |
| + |
| +@end |
| + |
| +@implementation AppsGridItemButtonCell |
| + |
| +@synthesize hasShadow = hasShadow_; |
| + |
| +- (void)drawImage:(NSImage*)image |
| + withFrame:(NSRect)frame |
| + inView:(NSView*)controlView { |
| + if (!hasShadow_) { |
| + [super drawImage:image |
| + withFrame:frame |
| + inView:controlView]; |
| + return; |
| + } |
| + |
| + scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); |
| + gfx::ScopedNSGraphicsContextSaveGState context; |
| + [shadow setShadowOffset:NSMakeSize(0, -2)]; |
| + [shadow setShadowBlurRadius:2.0]; |
| + [shadow setShadowColor:[[NSColor blackColor] colorWithAlphaComponent:0.14]]; |
|
tapted
2013/05/17 14:50:39
note: source for these numbers https://code.google
sail
2013/05/17 17:41:33
A more direct way to do this is [NSColor colorWith
tapted
2013/05/17 23:39:30
Done.
|
| + [shadow set]; |
| + |
| + [super drawImage:image |
| + withFrame:frame |
| + inView:controlView]; |
| +} |
| + |
| +@end |