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

Side by Side Diff: chrome/browser/ui/cocoa/menu_button.mm

Issue 2859903003: [Mac] App Menu Animated Icon (Closed)
Patch Set: Switch to CanvasSkiaPaint Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/menu_button.h" 5 #import "chrome/browser/ui/cocoa/menu_button.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "chrome/browser/ui/cocoa/clickhold_button_cell.h" 8 #import "chrome/browser/ui/cocoa/clickhold_button_cell.h"
9 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 9 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
10 #include "ui/base/material_design/material_design_controller.h" 10 #include "ui/base/material_design/material_design_controller.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 - (void)setOpenMenuOnRightClick:(BOOL)enabled { 88 - (void)setOpenMenuOnRightClick:(BOOL)enabled {
89 openMenuOnRightClick_ = enabled; 89 openMenuOnRightClick_ = enabled;
90 [self configureCell]; 90 [self configureCell];
91 } 91 }
92 92
93 - (NSRect)menuRect { 93 - (NSRect)menuRect {
94 return [self bounds]; 94 return [self bounds];
95 } 95 }
96 96
97 - (void)willShowMenu {
98 // Subclasses should implement this, but it's not necessary.
99 }
100
97 @end // @implementation MenuButton 101 @end // @implementation MenuButton
98 102
99 @implementation MenuButton (Private) 103 @implementation MenuButton (Private)
100 104
101 // Synchronize the state of this class with its ClickHoldButtonCell. 105 // Synchronize the state of this class with its ClickHoldButtonCell.
102 - (void)configureCell { 106 - (void)configureCell {
103 ClickHoldButtonCell* cell = [self cell]; 107 ClickHoldButtonCell* cell = [self cell];
104 DCHECK([cell isKindOfClass:[ClickHoldButtonCell class]]); 108 DCHECK([cell isKindOfClass:[ClickHoldButtonCell class]]);
105 109
106 if (![self attachedMenu]) { 110 if (![self attachedMenu]) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // the menu correctly even when we're at the edge of the screen (including 176 // the menu correctly even when we're at the edge of the screen (including
173 // "dragging upwards" when the button is close to the bottom of the screen). 177 // "dragging upwards" when the button is close to the bottom of the screen).
174 // A |scoped_nsobject| local variable cannot be used here because 178 // A |scoped_nsobject| local variable cannot be used here because
175 // Accessibility on 10.5 grabs the NSPopUpButtonCell without retaining it, and 179 // Accessibility on 10.5 grabs the NSPopUpButtonCell without retaining it, and
176 // uses it later. (This is fixed in 10.6.) 180 // uses it later. (This is fixed in 10.6.)
177 if (!popUpCell_.get()) { 181 if (!popUpCell_.get()) {
178 popUpCell_.reset([[NSPopUpButtonCell alloc] initTextCell:@"" 182 popUpCell_.reset([[NSPopUpButtonCell alloc] initTextCell:@""
179 pullsDown:YES]); 183 pullsDown:YES]);
180 } 184 }
181 DCHECK(popUpCell_.get()); 185 DCHECK(popUpCell_.get());
186 [self willShowMenu];
182 [popUpCell_ setMenu:[self attachedMenu]]; 187 [popUpCell_ setMenu:[self attachedMenu]];
183 [popUpCell_ selectItem:nil]; 188 [popUpCell_ selectItem:nil];
184 [popUpCell_ attachPopUpWithFrame:frame inView:self]; 189 [popUpCell_ attachPopUpWithFrame:frame inView:self];
185 [popUpCell_ performClickWithFrame:frame inView:self]; 190 [popUpCell_ performClickWithFrame:frame inView:self];
186 191
187 // Once the menu is dismissed send a mouseExited event if necessary. If the 192 // Once the menu is dismissed send a mouseExited event if necessary. If the
188 // menu action caused the super view to resize then we won't automatically 193 // menu action caused the super view to resize then we won't automatically
189 // get a mouseExited event so we need to do this manually. 194 // get a mouseExited event so we need to do this manually.
190 // See http://crbug.com/82456 195 // See http://crbug.com/82456
191 if (![self cr_isMouseInView]) { 196 if (![self cr_isMouseInView]) {
(...skipping 11 matching lines...) Expand all
203 } 208 }
204 209
205 // Called when the button is clicked and dragged/held. 210 // Called when the button is clicked and dragged/held.
206 - (void)dragShowMenu:(id)sender { 211 - (void)dragShowMenu:(id)sender {
207 // We shouldn't get here unless the menu is enabled. 212 // We shouldn't get here unless the menu is enabled.
208 DCHECK([self attachedMenu]); 213 DCHECK([self attachedMenu]);
209 [self showMenu:YES]; 214 [self showMenu:YES];
210 } 215 }
211 216
212 @end // @implementation MenuButton (Private) 217 @end // @implementation MenuButton (Private)
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/menu_button.h ('k') | chrome/browser/ui/cocoa/toolbar/app_toolbar_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698