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