OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ | 5 #ifndef VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ |
6 #define VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ | 6 #define VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 const gfx::Rect& bounds, | 70 const gfx::Rect& bounds, |
71 MenuItemView::AnchorPosition position, | 71 MenuItemView::AnchorPosition position, |
72 int* mouse_event_flags); | 72 int* mouse_event_flags); |
73 | 73 |
74 // Whether or not Run blocks. | 74 // Whether or not Run blocks. |
75 bool IsBlockingRun() const { return blocking_run_; } | 75 bool IsBlockingRun() const { return blocking_run_; } |
76 | 76 |
77 // Whether or not drag operation is in progress. | 77 // Whether or not drag operation is in progress. |
78 bool drag_in_progress() const { return drag_in_progress_; } | 78 bool drag_in_progress() const { return drag_in_progress_; } |
79 | 79 |
80 // Sets the selection to menu_item, a value of NULL unselects everything. | |
81 // If open_submenu is true and menu_item has a submenu, the submenu is shown. | |
82 // If update_immediately is true, submenus are opened immediately, otherwise | |
83 // submenus are only opened after a timer fires. | |
84 // | |
85 // Internally this updates pending_state_ immediatley, and if | |
86 // update_immediately is true, CommitPendingSelection is invoked to | |
87 // show/hide submenus and update state_. | |
88 void SetSelection(MenuItemView* menu_item, | |
89 bool open_submenu, | |
90 bool update_immediately); | |
91 | |
92 // Cancels the current Run. See ExitType for a description of what happens | 80 // Cancels the current Run. See ExitType for a description of what happens |
93 // with the various parameters. | 81 // with the various parameters. |
94 void Cancel(ExitType type); | 82 void Cancel(ExitType type); |
95 | 83 |
96 // An alternative to Cancel(EXIT_ALL) that can be used with a OneShotTimer. | 84 // An alternative to Cancel(EXIT_ALL) that can be used with a OneShotTimer. |
97 void CancelAll() { Cancel(EXIT_ALL); } | 85 void CancelAll() { Cancel(EXIT_ALL); } |
98 | 86 |
99 // Various events, forwarded from the submenu. | 87 // Various events, forwarded from the submenu. |
100 // | 88 // |
101 // NOTE: the coordinates of the events are in that of the | 89 // NOTE: the coordinates of the events are in that of the |
(...skipping 16 matching lines...) Expand all Loading... |
118 | 106 |
119 // Invoked from the scroll buttons of the MenuScrollViewContainer. | 107 // Invoked from the scroll buttons of the MenuScrollViewContainer. |
120 void OnDragEnteredScrollButton(SubmenuView* source, bool is_up); | 108 void OnDragEnteredScrollButton(SubmenuView* source, bool is_up); |
121 void OnDragExitedScrollButton(SubmenuView* source); | 109 void OnDragExitedScrollButton(SubmenuView* source); |
122 | 110 |
123 private: | 111 private: |
124 class MenuScrollTask; | 112 class MenuScrollTask; |
125 | 113 |
126 struct SelectByCharDetails; | 114 struct SelectByCharDetails; |
127 | 115 |
| 116 // Values supplied to SetSelection. |
| 117 enum SetSelectionTypes { |
| 118 SELECTION_DEFAULT = 0, |
| 119 |
| 120 // If set submenus are opened immediately, otherwise submenus are only |
| 121 // openned after a timer fires. |
| 122 SELECTION_UPDATE_IMMEDIATELY = 1 << 0, |
| 123 |
| 124 // If set and the menu_item has a submenu, the submenu is shown. |
| 125 SELECTION_OPEN_SUBMENU = 1 << 1, |
| 126 |
| 127 // SetSelection is being invoked as the result exiting or cancelling the |
| 128 // menu. This is used for debugging. |
| 129 SELECTION_EXIT = 1 << 2, |
| 130 }; |
| 131 |
128 // Tracks selection information. | 132 // Tracks selection information. |
129 struct State { | 133 struct State { |
130 State() : item(NULL), submenu_open(false) {} | 134 State() : item(NULL), submenu_open(false) {} |
131 | 135 |
132 // The selected menu item. | 136 // The selected menu item. |
133 MenuItemView* item; | 137 MenuItemView* item; |
134 | 138 |
135 // If item has a submenu this indicates if the submenu is showing. | 139 // If item has a submenu this indicates if the submenu is showing. |
136 bool submenu_open; | 140 bool submenu_open; |
137 | 141 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 MenuItemView* menu; | 180 MenuItemView* menu; |
177 | 181 |
178 // If type is MENU_ITEM but the mouse is not over a menu item this is the | 182 // If type is MENU_ITEM but the mouse is not over a menu item this is the |
179 // parent of the menu item the user clicked on. Otherwise this is NULL. | 183 // parent of the menu item the user clicked on. Otherwise this is NULL. |
180 MenuItemView* parent; | 184 MenuItemView* parent; |
181 | 185 |
182 // If type is SCROLL_*, this is the submenu the mouse is over. | 186 // If type is SCROLL_*, this is the submenu the mouse is over. |
183 SubmenuView* submenu; | 187 SubmenuView* submenu; |
184 }; | 188 }; |
185 | 189 |
| 190 // Sets the selection to menu_item a value of NULL unselects |
| 191 // everything. |types| is a bitmask of |SetSelectionTypes|. |
| 192 // |
| 193 // Internally this updates pending_state_ immediatley. state_ is only updated |
| 194 // immediately if SELECTION_UPDATE_IMMEDIATELY is set. If |
| 195 // SELECTION_UPDATE_IMMEDIATELY is not set CommitPendingSelection is invoked |
| 196 // to show/hide submenus and update state_. |
| 197 void SetSelection(MenuItemView* menu_item, int types); |
| 198 |
186 // Sets the active MenuController. | 199 // Sets the active MenuController. |
187 static void SetActiveInstance(MenuController* controller); | 200 static void SetActiveInstance(MenuController* controller); |
188 | 201 |
189 #if defined(OS_WIN) | 202 #if defined(OS_WIN) |
190 // Dispatcher method. This returns true if the menu was canceled, or | 203 // Dispatcher method. This returns true if the menu was canceled, or |
191 // if the message is such that the menu should be closed. | 204 // if the message is such that the menu should be closed. |
192 virtual bool Dispatch(const MSG& msg); | 205 virtual bool Dispatch(const MSG& msg); |
193 | 206 |
194 #else | 207 #else |
195 virtual bool Dispatch(GdkEvent* event); | 208 virtual bool Dispatch(GdkEvent* event); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 // If non-null mouse drag events are forwarded to this view. See | 479 // If non-null mouse drag events are forwarded to this view. See |
467 // UpdateActiveMouseView for details. | 480 // UpdateActiveMouseView for details. |
468 View* active_mouse_view_; | 481 View* active_mouse_view_; |
469 | 482 |
470 DISALLOW_COPY_AND_ASSIGN(MenuController); | 483 DISALLOW_COPY_AND_ASSIGN(MenuController); |
471 }; | 484 }; |
472 | 485 |
473 } // namespace views | 486 } // namespace views |
474 | 487 |
475 #endif // VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ | 488 #endif // VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ |
OLD | NEW |