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: views/controls/menu/submenu_view.h

Issue 8508024: Support touch scroll gestures in menus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Gardening. Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_SUBMENU_VIEW_H_ 5 #ifndef VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_
6 #define VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_ 6 #define VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "views/controls/menu/menu_delegate.h" 11 #include "views/controls/menu/menu_delegate.h"
12 #include "views/view.h" 12 #include "views/view.h"
13 #include "ui/views/animation/scroll_animator.h"
13 14
14 namespace views { 15 namespace views {
15 16
16 class MenuHost; 17 class MenuHost;
17 class MenuItemView; 18 class MenuItemView;
18 class MenuScrollViewContainer; 19 class MenuScrollViewContainer;
19 20
20 // SubmenuView is the parent of all menu items. 21 // SubmenuView is the parent of all menu items.
21 // 22 //
22 // SubmenuView has the following responsibilities: 23 // SubmenuView has the following responsibilities:
23 // . It positions and sizes all child views (any type of View may be added, 24 // . It positions and sizes all child views (any type of View may be added,
24 // not just MenuItemViews). 25 // not just MenuItemViews).
25 // . Forwards the appropriate events to the MenuController. This allows the 26 // . Forwards the appropriate events to the MenuController. This allows the
26 // MenuController to update the selection as the user moves the mouse around. 27 // MenuController to update the selection as the user moves the mouse around.
27 // . Renders the drop indicator during a drop operation. 28 // . Renders the drop indicator during a drop operation.
28 // . Shows and hides the window (a NativeWidgetWin) when the menu is shown on 29 // . Shows and hides the window (a NativeWidgetWin) when the menu is shown on
29 // screen. 30 // screen.
30 // 31 //
31 // SubmenuView is itself contained in a MenuScrollViewContainer. 32 // SubmenuView is itself contained in a MenuScrollViewContainer.
32 // MenuScrollViewContainer handles showing as much of the SubmenuView as the 33 // MenuScrollViewContainer handles showing as much of the SubmenuView as the
33 // screen allows. If the SubmenuView is taller than the screen, scroll buttons 34 // screen allows. If the SubmenuView is taller than the screen, scroll buttons
34 // are provided that allow the user to see all the menu items. 35 // are provided that allow the user to see all the menu items.
35 class VIEWS_EXPORT SubmenuView : public View { 36 class VIEWS_EXPORT SubmenuView : public View,
37 public ScrollDelegate {
36 public: 38 public:
37 // The submenu's class name. 39 // The submenu's class name.
38 static const char kViewClassName[]; 40 static const char kViewClassName[];
39 41
40 // Creates a SubmenuView for the specified menu item. 42 // Creates a SubmenuView for the specified menu item.
41 explicit SubmenuView(MenuItemView* parent); 43 explicit SubmenuView(MenuItemView* parent);
42 virtual ~SubmenuView(); 44 virtual ~SubmenuView();
43 45
44 // Returns the number of child views that are MenuItemViews. 46 // Returns the number of child views that are MenuItemViews.
45 // MenuItemViews are identified by ID. 47 // MenuItemViews are identified by ID.
(...skipping 20 matching lines...) Expand all
66 virtual bool AreDropTypesRequired() OVERRIDE; 68 virtual bool AreDropTypesRequired() OVERRIDE;
67 virtual bool CanDrop(const OSExchangeData& data) OVERRIDE; 69 virtual bool CanDrop(const OSExchangeData& data) OVERRIDE;
68 virtual void OnDragEntered(const DropTargetEvent& event) OVERRIDE; 70 virtual void OnDragEntered(const DropTargetEvent& event) OVERRIDE;
69 virtual int OnDragUpdated(const DropTargetEvent& event) OVERRIDE; 71 virtual int OnDragUpdated(const DropTargetEvent& event) OVERRIDE;
70 virtual void OnDragExited() OVERRIDE; 72 virtual void OnDragExited() OVERRIDE;
71 virtual int OnPerformDrop(const DropTargetEvent& event) OVERRIDE; 73 virtual int OnPerformDrop(const DropTargetEvent& event) OVERRIDE;
72 74
73 // Scrolls on menu item boundaries. 75 // Scrolls on menu item boundaries.
74 virtual bool OnMouseWheel(const MouseWheelEvent& e) OVERRIDE; 76 virtual bool OnMouseWheel(const MouseWheelEvent& e) OVERRIDE;
75 77
78 // Scrolls on menu item boundaries.
79 virtual ui::GestureStatus OnGestureEvent(const GestureEvent& e) OVERRIDE;
80
76 // Returns true if the menu is showing. 81 // Returns true if the menu is showing.
77 bool IsShowing(); 82 bool IsShowing();
78 83
79 // Shows the menu at the specified location. Coordinates are in screen 84 // Shows the menu at the specified location. Coordinates are in screen
80 // coordinates. max_width gives the max width the view should be. 85 // coordinates. max_width gives the max width the view should be.
81 void ShowAt(Widget* parent, 86 void ShowAt(Widget* parent,
82 const gfx::Rect& bounds, 87 const gfx::Rect& bounds,
83 bool do_capture); 88 bool do_capture);
84 89
85 // Resets the bounds of the submenu to |bounds|. 90 // Resets the bounds of the submenu to |bounds|.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 MenuItemView* item, 167 MenuItemView* item,
163 MenuDelegate::DropPosition position); 168 MenuDelegate::DropPosition position);
164 169
165 void SchedulePaintForDropIndicator(MenuItemView* item, 170 void SchedulePaintForDropIndicator(MenuItemView* item,
166 MenuDelegate::DropPosition position); 171 MenuDelegate::DropPosition position);
167 172
168 // Calculates the location of th edrop indicator. 173 // Calculates the location of th edrop indicator.
169 gfx::Rect CalculateDropIndicatorBounds(MenuItemView* item, 174 gfx::Rect CalculateDropIndicatorBounds(MenuItemView* item,
170 MenuDelegate::DropPosition position); 175 MenuDelegate::DropPosition position);
171 176
177 // Implementation of ScrollDelegate
178 virtual void OnScroll(float dx, float dy) OVERRIDE;
179
172 // Parent menu item. 180 // Parent menu item.
173 MenuItemView* parent_menu_item_; 181 MenuItemView* parent_menu_item_;
174 182
175 // Widget subclass used to show the children. This is deleted when we invoke 183 // Widget subclass used to show the children. This is deleted when we invoke
176 // |DestroyMenuHost|, or |MenuHostDestroyed| is invoked back on us. 184 // |DestroyMenuHost|, or |MenuHostDestroyed| is invoked back on us.
177 MenuHost* host_; 185 MenuHost* host_;
178 186
179 // If non-null, indicates a drop is in progress and drop_item is the item 187 // If non-null, indicates a drop is in progress and drop_item is the item
180 // the drop is over. 188 // the drop is over.
181 MenuItemView* drop_item_; 189 MenuItemView* drop_item_;
182 190
183 // Position of the drop. 191 // Position of the drop.
184 MenuDelegate::DropPosition drop_position_; 192 MenuDelegate::DropPosition drop_position_;
185 193
186 // Ancestor of the SubmenuView, lazily created. 194 // Ancestor of the SubmenuView, lazily created.
187 MenuScrollViewContainer* scroll_view_container_; 195 MenuScrollViewContainer* scroll_view_container_;
188 196
189 // See description above getter. 197 // See description above getter.
190 int max_accelerator_width_; 198 int max_accelerator_width_;
191 199
192 // Minimum width returned in GetPreferredSize(). 200 // Minimum width returned in GetPreferredSize().
193 int minimum_preferred_width_; 201 int minimum_preferred_width_;
194 202
195 // Reposition open menu when contained views change size. 203 // Reposition open menu when contained views change size.
196 bool resize_open_menu_; 204 bool resize_open_menu_;
197 205
206 // The submenu's scroll animator
207 scoped_ptr<ScrollAnimator> scroll_animator_;
208
198 DISALLOW_COPY_AND_ASSIGN(SubmenuView); 209 DISALLOW_COPY_AND_ASSIGN(SubmenuView);
199 }; 210 };
200 211
201 } // namespace views 212 } // namespace views
202 213
203 #endif // VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_ 214 #endif // VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698