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_BUTTON_BUTTON_DROPDOWN_H_ | 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_BUTTON_DROPDOWN_H_ |
6 #define UI_VIEWS_CONTROLS_BUTTON_BUTTON_DROPDOWN_H_ | 6 #define UI_VIEWS_CONTROLS_BUTTON_BUTTON_DROPDOWN_H_ |
7 | 7 |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "ui/views/controls/button/image_button.h" | 9 #include "ui/views/controls/button/image_button.h" |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... | |
22 // | 22 // |
23 // A button class that when pressed (and held) or pressed (and drag down) will | 23 // A button class that when pressed (and held) or pressed (and drag down) will |
24 // display a menu | 24 // display a menu |
25 // | 25 // |
26 //////////////////////////////////////////////////////////////////////////////// | 26 //////////////////////////////////////////////////////////////////////////////// |
27 class VIEWS_EXPORT ButtonDropDown : public ImageButton { | 27 class VIEWS_EXPORT ButtonDropDown : public ImageButton { |
28 public: | 28 public: |
29 // The button's class name. | 29 // The button's class name. |
30 static const char kViewClassName[]; | 30 static const char kViewClassName[]; |
31 | 31 |
32 // Constructor takes ownership of the |model| and destroys | |
Peter Kasting
2012/08/07 21:32:26
Nit: Allocated with new as opposed to... malloc?
gene
2012/08/07 21:42:37
Done.
| |
33 // object in the destructor. |model| must be allocated with new. | |
32 ButtonDropDown(ButtonListener* listener, ui::MenuModel* model); | 34 ButtonDropDown(ButtonListener* listener, ui::MenuModel* model); |
33 virtual ~ButtonDropDown(); | 35 virtual ~ButtonDropDown(); |
34 | 36 |
35 // If menu is currently pending for long press - stop it. | 37 // If menu is currently pending for long press - stop it. |
36 void ClearPendingMenu(); | 38 void ClearPendingMenu(); |
37 | 39 |
38 // Indicates if menu is currently showing. | 40 // Indicates if menu is currently showing. |
39 bool IsMenuShowing() const; | 41 bool IsMenuShowing() const; |
40 | 42 |
41 // Overridden from views::View | 43 // Overridden from views::View |
(...skipping 18 matching lines...) Expand all Loading... | |
60 virtual bool ShouldEnterPushedState(const Event& event) OVERRIDE; | 62 virtual bool ShouldEnterPushedState(const Event& event) OVERRIDE; |
61 | 63 |
62 // Returns if menu should be shown. Override this to change default behavior. | 64 // Returns if menu should be shown. Override this to change default behavior. |
63 virtual bool ShouldShowMenu(); | 65 virtual bool ShouldShowMenu(); |
64 | 66 |
65 // Function to show the dropdown menu. | 67 // Function to show the dropdown menu. |
66 virtual void ShowDropDownMenu(); | 68 virtual void ShowDropDownMenu(); |
67 | 69 |
68 private: | 70 private: |
69 // The model that populates the attached menu. | 71 // The model that populates the attached menu. |
70 ui::MenuModel* model_; | 72 scoped_ptr<ui::MenuModel> model_; |
71 | 73 |
72 // Indicates if menu is currently showing. | 74 // Indicates if menu is currently showing. |
73 bool menu_showing_; | 75 bool menu_showing_; |
74 | 76 |
75 // Y position of mouse when left mouse button is pressed | 77 // Y position of mouse when left mouse button is pressed |
76 int y_position_on_lbuttondown_; | 78 int y_position_on_lbuttondown_; |
77 | 79 |
78 // Menu runner to display drop down menu. | 80 // Menu runner to display drop down menu. |
79 scoped_ptr<MenuRunner> menu_runner_; | 81 scoped_ptr<MenuRunner> menu_runner_; |
80 | 82 |
81 // A factory for tasks that show the dropdown context menu for the button. | 83 // A factory for tasks that show the dropdown context menu for the button. |
82 base::WeakPtrFactory<ButtonDropDown> show_menu_factory_; | 84 base::WeakPtrFactory<ButtonDropDown> show_menu_factory_; |
83 | 85 |
84 DISALLOW_COPY_AND_ASSIGN(ButtonDropDown); | 86 DISALLOW_COPY_AND_ASSIGN(ButtonDropDown); |
85 }; | 87 }; |
86 | 88 |
87 } // namespace views | 89 } // namespace views |
88 | 90 |
89 #endif // UI_VIEWS_CONTROLS_BUTTON_BUTTON_DROPDOWN_H_ | 91 #endif // UI_VIEWS_CONTROLS_BUTTON_BUTTON_DROPDOWN_H_ |
OLD | NEW |