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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 // activated by way of space/return keys. Activating a focusable child results | 54 // activated by way of space/return keys. Activating a focusable child results |
55 // in |AcceleratorPressed| being invoked. Note, that as menus try not to steal | 55 // in |AcceleratorPressed| being invoked. Note, that as menus try not to steal |
56 // focus from the hosting window child views do not actually get focus. Instead | 56 // focus from the hosting window child views do not actually get focus. Instead |
57 // |SetHotTracked| is used as the user navigates around. | 57 // |SetHotTracked| is used as the user navigates around. |
58 // | 58 // |
59 // To show the menu use MenuRunner. See MenuRunner for details on how to run | 59 // To show the menu use MenuRunner. See MenuRunner for details on how to run |
60 // (show) the menu as well as for details on the life time of the menu. | 60 // (show) the menu as well as for details on the life time of the menu. |
61 | 61 |
62 class VIEWS_EXPORT MenuItemView : public View { | 62 class VIEWS_EXPORT MenuItemView : public View { |
63 public: | 63 public: |
64 // The LifecycleObserver will receive a notification when the MenuItemView has | |
65 // been deleted. | |
66 class LifecycleObserver { | |
67 public: | |
68 virtual ~LifecycleObserver() {} | |
69 virtual void OnDeleted(MenuItemView* view) = 0; | |
70 }; | |
71 | |
72 void set_lifecycle_observer(LifecycleObserver* lifecycle_observer) { | |
73 lifecycle_observer_ = lifecycle_observer; | |
74 } | |
75 | |
64 friend class MenuController; | 76 friend class MenuController; |
65 | 77 |
66 // The menu item view's class name. | 78 // The menu item view's class name. |
67 static const char kViewClassName[]; | 79 static const char kViewClassName[]; |
68 | 80 |
69 // ID used to identify menu items. | 81 // ID used to identify menu items. |
70 static const int kMenuItemViewID; | 82 static const int kMenuItemViewID; |
71 | 83 |
72 // ID used to identify empty menu items. | 84 // ID used to identify empty menu items. |
73 static const int kEmptyMenuItemViewID; | 85 static const int kEmptyMenuItemViewID; |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
519 // |menu_position_| is the requested position with respect to the bounds. | 531 // |menu_position_| is the requested position with respect to the bounds. |
520 // |actual_menu_position_| is used by the controller to cache the | 532 // |actual_menu_position_| is used by the controller to cache the |
521 // position of the menu being shown. | 533 // position of the menu being shown. |
522 MenuPosition requested_menu_position_; | 534 MenuPosition requested_menu_position_; |
523 MenuPosition actual_menu_position_; | 535 MenuPosition actual_menu_position_; |
524 | 536 |
525 // If set to false, the right margin will be removed for menu lines | 537 // If set to false, the right margin will be removed for menu lines |
526 // containing other elements. | 538 // containing other elements. |
527 bool use_right_margin_; | 539 bool use_right_margin_; |
528 | 540 |
541 LifecycleObserver* lifecycle_observer_; | |
Finnur
2014/02/10 10:41:41
nit: Document.
| |
542 | |
529 DISALLOW_COPY_AND_ASSIGN(MenuItemView); | 543 DISALLOW_COPY_AND_ASSIGN(MenuItemView); |
530 }; | 544 }; |
531 | 545 |
532 } // namespace views | 546 } // namespace views |
533 | 547 |
534 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ | 548 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
OLD | NEW |