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

Side by Side Diff: ui/views/controls/menu/submenu_view.h

Issue 167643003: Support prefix typing in Combobox while menu is open (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: retry upload Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/menu/menu_runner.cc ('k') | ui/views/controls/menu/submenu_view.cc » ('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 (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_SUBMENU_VIEW_H_ 5 #ifndef UI_VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_
6 #define UI_VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_ 6 #define UI_VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "ui/views/animation/scroll_animator.h" 11 #include "ui/views/animation/scroll_animator.h"
12 #include "ui/views/controls/menu/menu_delegate.h" 12 #include "ui/views/controls/menu/menu_delegate.h"
13 #include "ui/views/controls/prefix_delegate.h"
14 #include "ui/views/controls/prefix_selector.h"
13 #include "ui/views/view.h" 15 #include "ui/views/view.h"
14 16
15 namespace views { 17 namespace views {
16 18
17 class MenuHost; 19 class MenuHost;
18 class MenuItemView; 20 class MenuItemView;
19 class MenuScrollViewContainer; 21 class MenuScrollViewContainer;
20 22
21 // SubmenuView is the parent of all menu items. 23 // SubmenuView is the parent of all menu items.
22 // 24 //
23 // SubmenuView has the following responsibilities: 25 // SubmenuView has the following responsibilities:
24 // . It positions and sizes all child views (any type of View may be added, 26 // . It positions and sizes all child views (any type of View may be added,
25 // not just MenuItemViews). 27 // not just MenuItemViews).
26 // . Forwards the appropriate events to the MenuController. This allows the 28 // . Forwards the appropriate events to the MenuController. This allows the
27 // MenuController to update the selection as the user moves the mouse around. 29 // MenuController to update the selection as the user moves the mouse around.
28 // . Renders the drop indicator during a drop operation. 30 // . Renders the drop indicator during a drop operation.
29 // . Shows and hides the window (a NativeWidgetWin) when the menu is shown on 31 // . Shows and hides the window (a NativeWidgetWin) when the menu is shown on
30 // screen. 32 // screen.
31 // 33 //
32 // SubmenuView is itself contained in a MenuScrollViewContainer. 34 // SubmenuView is itself contained in a MenuScrollViewContainer.
33 // MenuScrollViewContainer handles showing as much of the SubmenuView as the 35 // MenuScrollViewContainer handles showing as much of the SubmenuView as the
34 // screen allows. If the SubmenuView is taller than the screen, scroll buttons 36 // screen allows. If the SubmenuView is taller than the screen, scroll buttons
35 // are provided that allow the user to see all the menu items. 37 // are provided that allow the user to see all the menu items.
36 class VIEWS_EXPORT SubmenuView : public View, 38 class VIEWS_EXPORT SubmenuView : public PrefixDelegate,
37 public ScrollDelegate { 39 public ScrollDelegate {
38 public: 40 public:
39 // The submenu's class name. 41 // The submenu's class name.
40 static const char kViewClassName[]; 42 static const char kViewClassName[];
41 43
42 // Creates a SubmenuView for the specified menu item. 44 // Creates a SubmenuView for the specified menu item.
43 explicit SubmenuView(MenuItemView* parent); 45 explicit SubmenuView(MenuItemView* parent);
44 virtual ~SubmenuView(); 46 virtual ~SubmenuView();
45 47
46 // Returns the number of child views that are MenuItemViews. 48 // Returns the number of child views that are MenuItemViews.
47 // MenuItemViews are identified by ID. 49 // MenuItemViews are identified by ID.
48 int GetMenuItemCount(); 50 int GetMenuItemCount();
49 51
50 // Returns the MenuItemView at the specified index. 52 // Returns the MenuItemView at the specified index.
51 MenuItemView* GetMenuItemAt(int index); 53 MenuItemView* GetMenuItemAt(int index);
52 54
53 // Positions and sizes the child views. This tiles the views vertically, 55 // Positions and sizes the child views. This tiles the views vertically,
54 // giving each child the available width. 56 // giving each child the available width.
55 virtual void Layout() OVERRIDE; 57 virtual void Layout() OVERRIDE;
56 virtual gfx::Size GetPreferredSize() OVERRIDE; 58 virtual gfx::Size GetPreferredSize() OVERRIDE;
57 59
58 // Override from View. 60 // Override from View.
59 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; 61 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
62 virtual ui::TextInputClient* GetTextInputClient() OVERRIDE;
60 63
61 // Painting. 64 // Painting.
62 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; 65 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE;
63 66
64 // Drag and drop methods. These are forwarded to the MenuController. 67 // Drag and drop methods. These are forwarded to the MenuController.
65 virtual bool GetDropFormats( 68 virtual bool GetDropFormats(
66 int* formats, 69 int* formats,
67 std::set<OSExchangeData::CustomFormat>* custom_formats) OVERRIDE; 70 std::set<OSExchangeData::CustomFormat>* custom_formats) OVERRIDE;
68 virtual bool AreDropTypesRequired() OVERRIDE; 71 virtual bool AreDropTypesRequired() OVERRIDE;
69 virtual bool CanDrop(const OSExchangeData& data) OVERRIDE; 72 virtual bool CanDrop(const OSExchangeData& data) OVERRIDE;
70 virtual void OnDragEntered(const ui::DropTargetEvent& event) OVERRIDE; 73 virtual void OnDragEntered(const ui::DropTargetEvent& event) OVERRIDE;
71 virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE; 74 virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE;
72 virtual void OnDragExited() OVERRIDE; 75 virtual void OnDragExited() OVERRIDE;
73 virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE; 76 virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE;
74 77
75 // Scrolls on menu item boundaries. 78 // Scrolls on menu item boundaries.
76 virtual bool OnMouseWheel(const ui::MouseWheelEvent& e) OVERRIDE; 79 virtual bool OnMouseWheel(const ui::MouseWheelEvent& e) OVERRIDE;
77 80
78 // Overridden from ui::EventHandler. 81 // Overridden from ui::EventHandler.
79 // Scrolls on menu item boundaries. 82 // Scrolls on menu item boundaries.
80 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; 83 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
81 84
85 // Overridden from PrefixDelegate.
86 virtual int GetRowCount() OVERRIDE;
87 virtual int GetSelectedRow() OVERRIDE;
88 virtual void SetSelectedRow(int row) OVERRIDE;
89 virtual base::string16 GetTextForRow(int row) OVERRIDE;
90
82 // Returns true if the menu is showing. 91 // Returns true if the menu is showing.
83 bool IsShowing(); 92 bool IsShowing();
84 93
85 // Shows the menu at the specified location. Coordinates are in screen 94 // Shows the menu at the specified location. Coordinates are in screen
86 // coordinates. max_width gives the max width the view should be. 95 // coordinates. max_width gives the max width the view should be.
87 void ShowAt(Widget* parent, const gfx::Rect& bounds, bool do_capture); 96 void ShowAt(Widget* parent, const gfx::Rect& bounds, bool do_capture);
88 97
89 // Resets the bounds of the submenu to |bounds|. 98 // Resets the bounds of the submenu to |bounds|.
90 void Reposition(const gfx::Rect& bounds); 99 void Reposition(const gfx::Rect& bounds);
91 100
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 210
202 // The submenu's scroll animator 211 // The submenu's scroll animator
203 scoped_ptr<ScrollAnimator> scroll_animator_; 212 scoped_ptr<ScrollAnimator> scroll_animator_;
204 213
205 // Difference between current position and cumulative deltas passed to 214 // Difference between current position and cumulative deltas passed to
206 // OnScroll. 215 // OnScroll.
207 // TODO(tdresser): This should be removed when raw pixel scrolling for views 216 // TODO(tdresser): This should be removed when raw pixel scrolling for views
208 // is enabled. See crbug.com/329354. 217 // is enabled. See crbug.com/329354.
209 float roundoff_error_; 218 float roundoff_error_;
210 219
220 PrefixSelector prefix_selector_;
221
211 DISALLOW_COPY_AND_ASSIGN(SubmenuView); 222 DISALLOW_COPY_AND_ASSIGN(SubmenuView);
212 }; 223 };
213 224
214 } // namespace views 225 } // namespace views
215 226
216 #endif // UI_VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_ 227 #endif // UI_VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_runner.cc ('k') | ui/views/controls/menu/submenu_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698