| OLD | NEW |
| 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_MENU_ITEM_VIEW_H_ | 5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
| 6 #define UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ | 6 #define UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 namespace views { | 32 namespace views { |
| 33 | 33 |
| 34 namespace internal { | 34 namespace internal { |
| 35 class MenuRunnerImpl; | 35 class MenuRunnerImpl; |
| 36 } | 36 } |
| 37 | 37 |
| 38 namespace test { | 38 namespace test { |
| 39 class TestMenuItemViewShown; | 39 class TestMenuItemViewShown; |
| 40 } | 40 } |
| 41 | 41 |
| 42 class CustomButton; |
| 42 class MenuController; | 43 class MenuController; |
| 43 class MenuDelegate; | 44 class MenuDelegate; |
| 44 class SubmenuView; | 45 class SubmenuView; |
| 45 | 46 |
| 46 // MenuItemView -------------------------------------------------------------- | 47 // MenuItemView -------------------------------------------------------------- |
| 47 | 48 |
| 48 // MenuItemView represents a single menu item with a label and optional icon. | 49 // MenuItemView represents a single menu item with a label and optional icon. |
| 49 // Each MenuItemView may also contain a submenu, which in turn may contain | 50 // Each MenuItemView may also contain a submenu, which in turn may contain |
| 50 // any number of child MenuItemViews. | 51 // any number of child MenuItemViews. |
| 51 // | 52 // |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 // Returns the descendant with the specified command. | 306 // Returns the descendant with the specified command. |
| 306 MenuItemView* GetMenuItemByID(int id); | 307 MenuItemView* GetMenuItemByID(int id); |
| 307 | 308 |
| 308 // Invoke if you remove/add children to the menu while it's showing. This | 309 // Invoke if you remove/add children to the menu while it's showing. This |
| 309 // recalculates the bounds. | 310 // recalculates the bounds. |
| 310 void ChildrenChanged(); | 311 void ChildrenChanged(); |
| 311 | 312 |
| 312 // Sizes any child views. | 313 // Sizes any child views. |
| 313 void Layout() override; | 314 void Layout() override; |
| 314 | 315 |
| 316 CustomButton* hot_button() const { return hot_button_; } |
| 317 |
| 318 // Updates the current |hot_button_| and its hot tracked state. |
| 319 void SetHotTrackedButton(CustomButton* hot_button); |
| 320 |
| 315 // Returns true if the menu has mnemonics. This only useful on the root menu | 321 // Returns true if the menu has mnemonics. This only useful on the root menu |
| 316 // item. | 322 // item. |
| 317 bool has_mnemonics() const { return has_mnemonics_; } | 323 bool has_mnemonics() const { return has_mnemonics_; } |
| 318 | 324 |
| 319 // Set top and bottom margins in pixels. If no margin is set or a | 325 // Set top and bottom margins in pixels. If no margin is set or a |
| 320 // negative margin is specified then MenuConfig values are used. | 326 // negative margin is specified then MenuConfig values are used. |
| 321 void SetMargins(int top_margin, int bottom_margin); | 327 void SetMargins(int top_margin, int bottom_margin); |
| 322 | 328 |
| 323 // Suppress the right margin if this is set to false. | 329 // Suppress the right margin if this is set to false. |
| 324 void set_use_right_margin(bool use_right_margin) { | 330 void set_use_right_margin(bool use_right_margin) { |
| 325 use_right_margin_ = use_right_margin; | 331 use_right_margin_ = use_right_margin; |
| 326 } | 332 } |
| 327 | 333 |
| 328 protected: | 334 protected: |
| 329 // Creates a MenuItemView. This is used by the various AddXXX methods. | 335 // Creates a MenuItemView. This is used by the various AddXXX methods. |
| 330 MenuItemView(MenuItemView* parent, int command, Type type); | 336 MenuItemView(MenuItemView* parent, int command, Type type); |
| 331 | 337 |
| 332 // MenuRunner owns MenuItemView and should be the only one deleting it. | 338 // MenuRunner owns MenuItemView and should be the only one deleting it. |
| 333 ~MenuItemView() override; | 339 ~MenuItemView() override; |
| 334 | 340 |
| 335 void ChildPreferredSizeChanged(View* child) override; | 341 void ChildPreferredSizeChanged(View* child) override; |
| 336 | 342 |
| 343 // View: |
| 337 const char* GetClassName() const override; | 344 const char* GetClassName() const override; |
| 345 void ViewHierarchyChanged( |
| 346 const ViewHierarchyChangedDetails& details) override; |
| 338 | 347 |
| 339 // Returns the preferred size (and padding) of any children. | 348 // Returns the preferred size (and padding) of any children. |
| 340 virtual gfx::Size GetChildPreferredSize() const; | 349 virtual gfx::Size GetChildPreferredSize() const; |
| 341 | 350 |
| 342 // Returns the various margins. | 351 // Returns the various margins. |
| 343 int GetTopMargin() const; | 352 int GetTopMargin() const; |
| 344 int GetBottomMargin() const; | 353 int GetBottomMargin() const; |
| 345 | 354 |
| 346 private: | 355 private: |
| 347 friend class internal::MenuRunnerImpl; // For access to ~MenuItemView. | 356 friend class internal::MenuRunnerImpl; // For access to ~MenuItemView. |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 // |menu_position_| is the requested position with respect to the bounds. | 522 // |menu_position_| is the requested position with respect to the bounds. |
| 514 // |actual_menu_position_| is used by the controller to cache the | 523 // |actual_menu_position_| is used by the controller to cache the |
| 515 // position of the menu being shown. | 524 // position of the menu being shown. |
| 516 MenuPosition requested_menu_position_; | 525 MenuPosition requested_menu_position_; |
| 517 MenuPosition actual_menu_position_; | 526 MenuPosition actual_menu_position_; |
| 518 | 527 |
| 519 // If set to false, the right margin will be removed for menu lines | 528 // If set to false, the right margin will be removed for menu lines |
| 520 // containing other elements. | 529 // containing other elements. |
| 521 bool use_right_margin_; | 530 bool use_right_margin_; |
| 522 | 531 |
| 532 // Current hot tracked child button if any. |
| 533 CustomButton* hot_button_; |
| 534 |
| 523 DISALLOW_COPY_AND_ASSIGN(MenuItemView); | 535 DISALLOW_COPY_AND_ASSIGN(MenuItemView); |
| 524 }; | 536 }; |
| 525 | 537 |
| 526 } // namespace views | 538 } // namespace views |
| 527 | 539 |
| 528 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ | 540 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
| OLD | NEW |