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

Unified Diff: ui/views/controls/menu/menu_controller.h

Issue 1230163004: Selects last item in a menu when pressing 'up' initially (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Selects last item in a menu when pressing 'up' initially (nits) Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/views/controls/menu/menu_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/menu/menu_controller.h
diff --git a/ui/views/controls/menu/menu_controller.h b/ui/views/controls/menu/menu_controller.h
index e9354293e922245a2234b553e5aab5baebafe917..e19bcd5b3b4494414f81fb3481e4ba09adcd6d7f 100644
--- a/ui/views/controls/menu/menu_controller.h
+++ b/ui/views/controls/menu/menu_controller.h
@@ -51,6 +51,10 @@ class MenuMessagePumpDispatcher;
class MenuRunnerImpl;
}
+namespace test {
+class MenuControllerTest;
+}
+
// MenuController -------------------------------------------------------------
// MenuController is used internally by the various menu classes to manage
@@ -183,7 +187,7 @@ class VIEWS_EXPORT MenuController : public WidgetObserver {
friend class internal::MenuEventDispatcher;
friend class internal::MenuMessagePumpDispatcher;
friend class internal::MenuRunnerImpl;
- friend class MenuControllerTest;
+ friend class test::MenuControllerTest;
friend class MenuHostRootView;
friend class MenuItemView;
friend class SubmenuView;
@@ -220,6 +224,15 @@ class VIEWS_EXPORT MenuController : public WidgetObserver {
ACCELERATOR_PROCESSED_EXIT
};
+ // Direction for IncrementSelection and FindInitialSelectableMenuItem.
+ enum SelectionIncrementDirectionType {
+ // Navigate the menu up.
+ INCREMENT_SELECTION_UP,
+
+ // Navigate the menu down.
+ INCREMENT_SELECTION_DOWN,
+ };
+
// Tracks selection information.
struct State {
State();
@@ -432,19 +445,23 @@ class VIEWS_EXPORT MenuController : public WidgetObserver {
// Returns the depth of the menu.
static int MenuDepth(MenuItemView* item);
- // Selects the next/previous menu item.
- void IncrementSelection(int delta);
+ // Selects the next or previous (depending on |direction|) menu item.
+ void IncrementSelection(SelectionIncrementDirectionType direction);
- // Returns the first selectable child menu item of |parent|. If there are no
- // selectable menu items NULL is returned.
- MenuItemView* FindFirstSelectableMenuItem(MenuItemView* parent);
+ // Returns the first (|direction| == NAVIGATE_SELECTION_DOWN) or the last
+ // (|direction| == INCREMENT_SELECTION_UP) selectable child menu item of
+ // |parent|. If there are no selectable items returns NULL.
+ MenuItemView* FindInitialSelectableMenuItem(
+ MenuItemView* parent,
+ SelectionIncrementDirectionType direction);
- // Returns the next selectable child menu item of |parent| starting at |index|
- // and incrementing index by |delta|. If there are no more selectable menu
- // items NULL is returned.
- MenuItemView* FindNextSelectableMenuItem(MenuItemView* parent,
- int index,
- int delta);
+ // Returns the next or previous selectable child menu item of |parent|
+ // starting at |index| and incrementing or decrementing index by 1 depending
+ // on |direction|. If there are no more selectable items NULL is returned.
+ MenuItemView* FindNextSelectableMenuItem(
+ MenuItemView* parent,
+ int index,
+ SelectionIncrementDirectionType direction);
// If the selected item has a submenu and it isn't currently open, the
// the selection is changed such that the menu opens immediately.
« no previous file with comments | « no previous file | ui/views/controls/menu/menu_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698