| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 // Accelerator is not sent because of no hot tracked views. | 213 // Accelerator is not sent because of no hot tracked views. |
| 214 ACCELERATOR_NOT_PROCESSED, | 214 ACCELERATOR_NOT_PROCESSED, |
| 215 | 215 |
| 216 // Accelerator is sent to the hot tracked views. | 216 // Accelerator is sent to the hot tracked views. |
| 217 ACCELERATOR_PROCESSED, | 217 ACCELERATOR_PROCESSED, |
| 218 | 218 |
| 219 // Same as above and the accelerator causes the exit of the menu. | 219 // Same as above and the accelerator causes the exit of the menu. |
| 220 ACCELERATOR_PROCESSED_EXIT | 220 ACCELERATOR_PROCESSED_EXIT |
| 221 }; | 221 }; |
| 222 | 222 |
| 223 // Direction for IncrementSelection and FindInitialSelectableMenuItem. |
| 224 enum SelectionIncrementDirectionType { |
| 225 // Navigate the menu up. |
| 226 INCREMENT_SELECTION_UP, |
| 227 |
| 228 // Navigate the menu down. |
| 229 INCREMENT_SELECTION_DOWN, |
| 230 }; |
| 231 |
| 223 // Tracks selection information. | 232 // Tracks selection information. |
| 224 struct State { | 233 struct State { |
| 225 State(); | 234 State(); |
| 226 ~State(); | 235 ~State(); |
| 227 | 236 |
| 228 // The selected menu item. | 237 // The selected menu item. |
| 229 MenuItemView* item; | 238 MenuItemView* item; |
| 230 | 239 |
| 231 // If item has a submenu this indicates if the submenu is showing. | 240 // If item has a submenu this indicates if the submenu is showing. |
| 232 bool submenu_open; | 241 bool submenu_open; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 | 434 |
| 426 // Calculates the bubble bounds of the menu to show. is_leading is set to | 435 // Calculates the bubble bounds of the menu to show. is_leading is set to |
| 427 // match the direction the menu opened in. | 436 // match the direction the menu opened in. |
| 428 gfx::Rect CalculateBubbleMenuBounds(MenuItemView* item, | 437 gfx::Rect CalculateBubbleMenuBounds(MenuItemView* item, |
| 429 bool prefer_leading, | 438 bool prefer_leading, |
| 430 bool* is_leading); | 439 bool* is_leading); |
| 431 | 440 |
| 432 // Returns the depth of the menu. | 441 // Returns the depth of the menu. |
| 433 static int MenuDepth(MenuItemView* item); | 442 static int MenuDepth(MenuItemView* item); |
| 434 | 443 |
| 435 // Selects the next/previous menu item. | 444 // Selects the next or previous (depending on |direction|) menu item. |
| 436 void IncrementSelection(int delta); | 445 void IncrementSelection(SelectionIncrementDirectionType direction); |
| 437 | 446 |
| 438 // Returns the first selectable child menu item of |parent|. If there are no | 447 // Returns the first (|direction| == NAVIGATE_SELECTION_DOWN) or the last |
| 439 // selectable menu items NULL is returned. | 448 // (|direction| == INCREMENT_SELECTION_UP) selectable child menu item of |
| 440 MenuItemView* FindFirstSelectableMenuItem(MenuItemView* parent); | 449 // |parent|. If there are no selectable items returns NULL. |
| 450 MenuItemView* FindInitialSelectableMenuItem( |
| 451 MenuItemView* parent, |
| 452 SelectionIncrementDirectionType direction); |
| 441 | 453 |
| 442 // Returns the next selectable child menu item of |parent| starting at |index| | 454 // Returns the next or previous selectable child menu item of |parent| |
| 443 // and incrementing index by |delta|. If there are no more selectable menu | 455 // starting at |index| and incrementing or decrementing index by 1 depending |
| 444 // items NULL is returned. | 456 // on |direction|. If there are no more selectable items NULL is returned. |
| 445 MenuItemView* FindNextSelectableMenuItem(MenuItemView* parent, | 457 MenuItemView* FindNextSelectableMenuItem( |
| 446 int index, | 458 MenuItemView* parent, |
| 447 int delta); | 459 int index, |
| 460 SelectionIncrementDirectionType direction); |
| 448 | 461 |
| 449 // If the selected item has a submenu and it isn't currently open, the | 462 // If the selected item has a submenu and it isn't currently open, the |
| 450 // the selection is changed such that the menu opens immediately. | 463 // the selection is changed such that the menu opens immediately. |
| 451 void OpenSubmenuChangeSelectionIfCan(); | 464 void OpenSubmenuChangeSelectionIfCan(); |
| 452 | 465 |
| 453 // If possible, closes the submenu. | 466 // If possible, closes the submenu. |
| 454 void CloseSubmenu(); | 467 void CloseSubmenu(); |
| 455 | 468 |
| 456 // Returns details about which menu items match the mnemonic |key|. | 469 // Returns details about which menu items match the mnemonic |key|. |
| 457 // |match_function| is used to determine which menus match. | 470 // |match_function| is used to determine which menus match. |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 bool item_selected_by_touch_; | 653 bool item_selected_by_touch_; |
| 641 | 654 |
| 642 scoped_ptr<MenuMessageLoop> message_loop_; | 655 scoped_ptr<MenuMessageLoop> message_loop_; |
| 643 | 656 |
| 644 DISALLOW_COPY_AND_ASSIGN(MenuController); | 657 DISALLOW_COPY_AND_ASSIGN(MenuController); |
| 645 }; | 658 }; |
| 646 | 659 |
| 647 } // namespace views | 660 } // namespace views |
| 648 | 661 |
| 649 #endif // UI_VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ | 662 #endif // UI_VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ |
| OLD | NEW |