OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ | 5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ |
6 #define UI_VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ | 6 #define UI_VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #include <list> | 10 #include <list> |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 static MenuController* GetActiveInstance(); | 79 static MenuController* GetActiveInstance(); |
80 | 80 |
81 // Runs the menu at the specified location. If the menu was configured to | 81 // Runs the menu at the specified location. If the menu was configured to |
82 // block, the selected item is returned. If the menu does not block this | 82 // block, the selected item is returned. If the menu does not block this |
83 // returns NULL immediately. | 83 // returns NULL immediately. |
84 MenuItemView* Run(Widget* parent, | 84 MenuItemView* Run(Widget* parent, |
85 MenuButton* button, | 85 MenuButton* button, |
86 MenuItemView* root, | 86 MenuItemView* root, |
87 const gfx::Rect& bounds, | 87 const gfx::Rect& bounds, |
88 MenuItemView::AnchorPosition position, | 88 MenuItemView::AnchorPosition position, |
| 89 bool context_menu, |
89 int* mouse_event_flags); | 90 int* mouse_event_flags); |
90 | 91 |
91 // Whether or not Run blocks. | 92 // Whether or not Run blocks. |
92 bool IsBlockingRun() const { return blocking_run_; } | 93 bool IsBlockingRun() const { return blocking_run_; } |
93 | 94 |
94 // Whether or not drag operation is in progress. | 95 // Whether or not drag operation is in progress. |
95 bool drag_in_progress() const { return drag_in_progress_; } | 96 bool drag_in_progress() const { return drag_in_progress_; } |
96 | 97 |
97 // Cancels the current Run. See ExitType for a description of what happens | 98 // Cancels the current Run. See ExitType for a description of what happens |
98 // with the various parameters. | 99 // with the various parameters. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 gfx::Rect initial_bounds; | 192 gfx::Rect initial_bounds; |
192 | 193 |
193 // Position of the initial menu. | 194 // Position of the initial menu. |
194 MenuItemView::AnchorPosition anchor; | 195 MenuItemView::AnchorPosition anchor; |
195 | 196 |
196 // The direction child menus have opened in. | 197 // The direction child menus have opened in. |
197 std::list<bool> open_leading; | 198 std::list<bool> open_leading; |
198 | 199 |
199 // Bounds for the monitor we're showing on. | 200 // Bounds for the monitor we're showing on. |
200 gfx::Rect monitor_bounds; | 201 gfx::Rect monitor_bounds; |
| 202 |
| 203 // Is the current menu a context menu. |
| 204 bool context_menu; |
201 }; | 205 }; |
202 | 206 |
203 // Used by GetMenuPart to indicate the menu part at a particular location. | 207 // Used by GetMenuPart to indicate the menu part at a particular location. |
204 struct MenuPart { | 208 struct MenuPart { |
205 // Type of part. | 209 // Type of part. |
206 enum Type { | 210 enum Type { |
207 NONE, | 211 NONE, |
208 MENU_ITEM, | 212 MENU_ITEM, |
209 SCROLL_UP, | 213 SCROLL_UP, |
210 SCROLL_DOWN | 214 SCROLL_DOWN |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 // Creates a MenuController. If |blocking| is true a nested message loop is | 265 // Creates a MenuController. If |blocking| is true a nested message loop is |
262 // started in |Run|. | 266 // started in |Run|. |
263 MenuController(bool blocking, internal::MenuControllerDelegate* delegate); | 267 MenuController(bool blocking, internal::MenuControllerDelegate* delegate); |
264 | 268 |
265 virtual ~MenuController(); | 269 virtual ~MenuController(); |
266 | 270 |
267 // AcceleratorPressed is invoked on the hot tracked view if it exists. | 271 // AcceleratorPressed is invoked on the hot tracked view if it exists. |
268 SendAcceleratorResultType SendAcceleratorToHotTrackedView(); | 272 SendAcceleratorResultType SendAcceleratorToHotTrackedView(); |
269 | 273 |
270 void UpdateInitialLocation(const gfx::Rect& bounds, | 274 void UpdateInitialLocation(const gfx::Rect& bounds, |
271 MenuItemView::AnchorPosition position); | 275 MenuItemView::AnchorPosition position, |
| 276 bool context_menu); |
272 | 277 |
273 // Invoked when the user accepts the selected item. This is only used | 278 // Invoked when the user accepts the selected item. This is only used |
274 // when blocking. This schedules the loop to quit. | 279 // when blocking. This schedules the loop to quit. |
275 void Accept(MenuItemView* item, int mouse_event_flags); | 280 void Accept(MenuItemView* item, int mouse_event_flags); |
276 | 281 |
277 bool ShowSiblingMenu(SubmenuView* source, const gfx::Point& mouse_location); | 282 bool ShowSiblingMenu(SubmenuView* source, const gfx::Point& mouse_location); |
278 | 283 |
279 // Shows a context menu for |menu_item| as a result of a located event if | 284 // Shows a context menu for |menu_item| as a result of a located event if |
280 // appropriate. This is invoked on long press and releasing the right mouse | 285 // appropriate. This is invoked on long press and releasing the right mouse |
281 // button. Returns whether a context menu was shown. | 286 // button. Returns whether a context menu was shown. |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 // How deep we are in nested message loops. This should be at most 2 (when | 557 // How deep we are in nested message loops. This should be at most 2 (when |
553 // showing a context menu from a menu). | 558 // showing a context menu from a menu). |
554 int message_loop_depth_; | 559 int message_loop_depth_; |
555 | 560 |
556 DISALLOW_COPY_AND_ASSIGN(MenuController); | 561 DISALLOW_COPY_AND_ASSIGN(MenuController); |
557 }; | 562 }; |
558 | 563 |
559 } // namespace views | 564 } // namespace views |
560 | 565 |
561 #endif // UI_VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ | 566 #endif // UI_VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ |
OLD | NEW |