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

Unified Diff: ui/base/cocoa/controls/hover_image_menu_button_cell.mm

Issue 15955003: Menu for the OSX app launcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactor HoverImageMenuButton into /ui/base/cocoa/controls Created 7 years, 7 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
Index: ui/base/cocoa/controls/hover_image_menu_button_cell.mm
diff --git a/ui/base/cocoa/controls/hover_image_menu_button_cell.mm b/ui/base/cocoa/controls/hover_image_menu_button_cell.mm
new file mode 100644
index 0000000000000000000000000000000000000000..753be7c3b7ef7793278ec846386f2db7b2d198d2
--- /dev/null
+++ b/ui/base/cocoa/controls/hover_image_menu_button_cell.mm
@@ -0,0 +1,49 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ui/base/cocoa/controls/hover_image_menu_button_cell.h"
+
+#include "base/memory/scoped_nsobject.h"
+
+@implementation HoverImageMenuButtonCell
+
+@synthesize hovered = hovered_;
+
+- (void)setHoverImage:(NSImage*)newImage {
+ hoverImage_.reset([newImage retain]);
+ [[self controlView] setNeedsDisplay:YES];
+}
+
+- (NSImage*)hoverImage {
+ return hoverImage_;
+}
+
+- (NSImage*)imageToDraw {
+ if ([self isHighlighted] && [self alternateImage])
+ return [self alternateImage];
+
+ if ([self isHovered] && [self hoverImage])
+ return [self hoverImage];
+
+ return [self image];
sail 2013/05/31 19:07:03 How does this work? Shouldn't this be [buttonMenuI
tapted 2013/06/03 12:49:18 It does work - there's even tests ;). This felt mo
+}
+
+- (void)setImage:(NSImage*)defaultImage {
+ [self setUsesItemFromMenu:NO];
sail 2013/05/31 19:07:03 Since the button class explicitly states that the
tapted 2013/06/03 12:49:18 Done.
+ scoped_nsobject<NSMenuItem> buttonItem([[NSMenuItem alloc] init]);
sail 2013/05/31 19:07:03 how about buttonMenuItem?
tapted 2013/06/03 12:49:18 Done.
+ [buttonItem setImage:defaultImage];
+ [self setMenuItem:buttonItem];
+}
+
+- (void)drawWithFrame:(NSRect)cellFrame
+ inView:(NSView*)controlView {
+ [[self imageToDraw] drawInRect:cellFrame
+ fromRect:NSZeroRect
+ operation:NSCompositeSourceOver
+ fraction:1.0
+ respectFlipped:YES
+ hints:nil];
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698