| 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 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 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // Max width of accelerators in child menu items. This doesn't include | 129 // Max width of accelerators in child menu items. This doesn't include |
| 130 // children's children, only direct children. | 130 // children's children, only direct children. |
| 131 int max_accelerator_width() const { return max_accelerator_width_; } | 131 int max_accelerator_width() const { return max_accelerator_width_; } |
| 132 | 132 |
| 133 // Minimum width of menu in pixels (default 0). This becomes the smallest | 133 // Minimum width of menu in pixels (default 0). This becomes the smallest |
| 134 // width returned by GetPreferredSize(). | 134 // width returned by GetPreferredSize(). |
| 135 void set_minimum_preferred_width(int minimum_preferred_width) { | 135 void set_minimum_preferred_width(int minimum_preferred_width) { |
| 136 minimum_preferred_width_ = minimum_preferred_width; | 136 minimum_preferred_width_ = minimum_preferred_width; |
| 137 } | 137 } |
| 138 | 138 |
| 139 // Automatically resize menu if a subview's preferred size changes. |
| 140 bool resize_open_menu() const { return resize_open_menu_; } |
| 141 void set_resize_open_menu(bool resize_open_menu) { |
| 142 resize_open_menu_ = resize_open_menu; |
| 143 } |
| 144 |
| 139 // Padding around the edges of the submenu. | 145 // Padding around the edges of the submenu. |
| 140 static const int kSubmenuBorderSize; | 146 static const int kSubmenuBorderSize; |
| 141 | 147 |
| 142 protected: | 148 protected: |
| 143 // View override. | 149 // View override. |
| 144 virtual std::string GetClassName() const OVERRIDE; | 150 virtual std::string GetClassName() const OVERRIDE; |
| 145 | 151 |
| 146 // View method. Overridden to schedule a paint. We do this so that when | 152 // View method. Overridden to schedule a paint. We do this so that when |
| 147 // scrolling occurs, everything is repainted correctly. | 153 // scrolling occurs, everything is repainted correctly. |
| 148 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; | 154 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; |
| 149 | 155 |
| 156 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; |
| 150 | 157 |
| 151 private: | 158 private: |
| 152 // Paints the drop indicator. This is only invoked if item is non-NULL and | 159 // Paints the drop indicator. This is only invoked if item is non-NULL and |
| 153 // position is not DROP_NONE. | 160 // position is not DROP_NONE. |
| 154 void PaintDropIndicator(gfx::Canvas* canvas, | 161 void PaintDropIndicator(gfx::Canvas* canvas, |
| 155 MenuItemView* item, | 162 MenuItemView* item, |
| 156 MenuDelegate::DropPosition position); | 163 MenuDelegate::DropPosition position); |
| 157 | 164 |
| 158 void SchedulePaintForDropIndicator(MenuItemView* item, | 165 void SchedulePaintForDropIndicator(MenuItemView* item, |
| 159 MenuDelegate::DropPosition position); | 166 MenuDelegate::DropPosition position); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 178 | 185 |
| 179 // Ancestor of the SubmenuView, lazily created. | 186 // Ancestor of the SubmenuView, lazily created. |
| 180 MenuScrollViewContainer* scroll_view_container_; | 187 MenuScrollViewContainer* scroll_view_container_; |
| 181 | 188 |
| 182 // See description above getter. | 189 // See description above getter. |
| 183 int max_accelerator_width_; | 190 int max_accelerator_width_; |
| 184 | 191 |
| 185 // Minimum width returned in GetPreferredSize(). | 192 // Minimum width returned in GetPreferredSize(). |
| 186 int minimum_preferred_width_; | 193 int minimum_preferred_width_; |
| 187 | 194 |
| 195 // Reposition open menu when contained views change size. |
| 196 bool resize_open_menu_; |
| 197 |
| 188 DISALLOW_COPY_AND_ASSIGN(SubmenuView); | 198 DISALLOW_COPY_AND_ASSIGN(SubmenuView); |
| 189 }; | 199 }; |
| 190 | 200 |
| 191 } // namespace views | 201 } // namespace views |
| 192 | 202 |
| 193 #endif // VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_ | 203 #endif // VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_ |
| OLD | NEW |