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

Side by Side Diff: ui/base/cocoa/menu_controller.h

Issue 2863883002: Tracing for NSMenu timelines
Patch Set: big CL with more trace points 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
« no previous file with comments | « no previous file | ui/base/cocoa/menu_controller.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef UI_BASE_COCOA_MENU_CONTROLLER_H_ 5 #ifndef UI_BASE_COCOA_MENU_CONTROLLER_H_
6 #define UI_BASE_COCOA_MENU_CONTROLLER_H_ 6 #define UI_BASE_COCOA_MENU_CONTROLLER_H_
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 9
10 #include "base/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
(...skipping 11 matching lines...) Expand all
22 // has the tag and represented object set for each menu item. The object is a 22 // has the tag and represented object set for each menu item. The object is a
23 // NSValue holding a pointer to the model for that level of the menu (to 23 // NSValue holding a pointer to the model for that level of the menu (to
24 // allow for hierarchical menus). The tag is the index into that model for 24 // allow for hierarchical menus). The tag is the index into that model for
25 // that particular item. It is important that the model outlives this object 25 // that particular item. It is important that the model outlives this object
26 // as it only maintains weak references. 26 // as it only maintains weak references.
27 UI_BASE_EXPORT 27 UI_BASE_EXPORT
28 @interface MenuController : NSObject<NSMenuDelegate> { 28 @interface MenuController : NSObject<NSMenuDelegate> {
29 @protected 29 @protected
30 ui::MenuModel* model_; // weak 30 ui::MenuModel* model_; // weak
31 base::scoped_nsobject<NSMenu> menu_; 31 base::scoped_nsobject<NSMenu> menu_;
32 BOOL suppressNextItemSelected_; // Set by -processItemSelectedEarly:.
32 BOOL useWithPopUpButtonCell_; // If YES, 0th item is blank 33 BOOL useWithPopUpButtonCell_; // If YES, 0th item is blank
33 BOOL isMenuOpen_; 34 BOOL isMenuOpen_;
34 } 35 }
35 36
36 @property(nonatomic, assign) ui::MenuModel* model; 37 @property(nonatomic, assign) ui::MenuModel* model;
37 // Note that changing this will have no effect if you use 38 // Note that changing this will have no effect if you use
38 // |-initWithModel:useWithPopUpButtonCell:| or after the first call to |-menu|. 39 // |-initWithModel:useWithPopUpButtonCell:| or after the first call to |-menu|.
39 @property(nonatomic) BOOL useWithPopUpButtonCell; 40 @property(nonatomic) BOOL useWithPopUpButtonCell;
40 41
41 + (base::string16)elideMenuTitle:(const base::string16&)title 42 + (base::string16)elideMenuTitle:(const base::string16&)title
42 toWidth:(int)width; 43 toWidth:(int)width;
43 44
44 // NIB-based initializer. This does not create a menu. Clients can set the 45 // NIB-based initializer. This does not create a menu. Clients can set the
45 // properties of the object and the menu will be created upon the first call to 46 // properties of the object and the menu will be created upon the first call to
46 // |-menu|. Note that the menu will be immutable after creation. 47 // |-menu|. Note that the menu will be immutable after creation.
47 - (id)init; 48 - (id)init;
48 49
49 // Builds a NSMenu from the pre-built model (must not be nil). Changes made 50 // Builds a NSMenu from the pre-built model (must not be nil). Changes made
50 // to the contents of the model after calling this will not be noticed. If 51 // to the contents of the model after calling this will not be noticed. If
51 // the menu will be displayed by a NSPopUpButtonCell, it needs to be of a 52 // the menu will be displayed by a NSPopUpButtonCell, it needs to be of a
52 // slightly different form (0th item is empty). Note this attribute of the menu 53 // slightly different form (0th item is empty). Note this attribute of the menu
53 // cannot be changed after it has been created. 54 // cannot be changed after it has been created.
54 - (id)initWithModel:(ui::MenuModel*)model 55 - (id)initWithModel:(ui::MenuModel*)model
55 useWithPopUpButtonCell:(BOOL)useWithCell; 56 useWithPopUpButtonCell:(BOOL)useWithCell;
56 57
57 // Programmatically close the constructed menu. 58 // Programmatically close the constructed menu.
58 - (void)cancel; 59 - (void)cancel;
59 60
61 // Called when the user chooses a particular menu item. |sender| is the menu
62 // item chosen.
63 - (void)itemSelected:(id)sender;
64
65 // Sent when the menu item is clicked. A subclass can invoke itemSelected: and
66 // return YES to suppress the action processing that occurs 300ms later, after
67 // the native menu animations have completed. Consumers should not assume that
68 // this method will be invoked.
69 - (BOOL)processItemSelectedEarly:(id)sender;
70
60 // Access to the constructed menu if the complex initializer was used. If the 71 // Access to the constructed menu if the complex initializer was used. If the
61 // default initializer was used, then this will create the menu on first call. 72 // default initializer was used, then this will create the menu on first call.
62 - (NSMenu*)menu; 73 - (NSMenu*)menu;
63 74
64 // Whether the menu is currently open. 75 // Whether the menu is currently open.
65 - (BOOL)isMenuOpen; 76 - (BOOL)isMenuOpen;
66 77
67 // NSMenuDelegate methods this class implements. Subclasses should call super 78 // NSMenuDelegate methods this class implements. Subclasses should call super
68 // if extending the behavior. 79 // if extending the behavior.
69 - (void)menuWillOpen:(NSMenu*)menu; 80 - (void)menuWillOpen:(NSMenu*)menu;
(...skipping 12 matching lines...) Expand all
82 atIndex:(NSInteger)index 93 atIndex:(NSInteger)index
83 fromModel:(ui::MenuModel*)model; 94 fromModel:(ui::MenuModel*)model;
84 - (NSMenu*)menuFromModel:(ui::MenuModel*)model; 95 - (NSMenu*)menuFromModel:(ui::MenuModel*)model;
85 // Returns the maximum width for the menu item. Returns -1 to indicate 96 // Returns the maximum width for the menu item. Returns -1 to indicate
86 // that there's no maximum width. 97 // that there's no maximum width.
87 - (int)maxWidthForMenuModel:(ui::MenuModel*)model 98 - (int)maxWidthForMenuModel:(ui::MenuModel*)model
88 modelIndex:(int)modelIndex; 99 modelIndex:(int)modelIndex;
89 @end 100 @end
90 101
91 #endif // UI_BASE_COCOA_MENU_CONTROLLER_H_ 102 #endif // UI_BASE_COCOA_MENU_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | ui/base/cocoa/menu_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698