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/context_menu_controller.h" | 9 #include "ui/views/context_menu_controller.h" |
10 #include "ui/views/controls/button/image_button.h" | 10 #include "ui/views/controls/button/image_button.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; | 47 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
48 virtual const char* GetClassName() const OVERRIDE; | 48 virtual const char* GetClassName() const OVERRIDE; |
49 // Showing the drop down results in a MouseCaptureLost, we need to ignore it. | 49 // Showing the drop down results in a MouseCaptureLost, we need to ignore it. |
50 virtual void OnMouseCaptureLost() OVERRIDE {} | 50 virtual void OnMouseCaptureLost() OVERRIDE {} |
51 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; | 51 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; |
52 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 52 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
53 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 53 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
54 | 54 |
55 // Overridden from views::ContextMenuController | 55 // Overridden from views::ContextMenuController |
56 virtual void ShowContextMenuForView(View* source, | 56 virtual void ShowContextMenuForView(View* source, |
57 const gfx::Point& point) OVERRIDE; | 57 const gfx::Point& point, |
| 58 ui::MenuSourceType source_type) OVERRIDE; |
58 | 59 |
59 protected: | 60 protected: |
60 // Overridden from CustomButton. Returns true if the button should become | 61 // Overridden from CustomButton. Returns true if the button should become |
61 // pressed when a user holds the mouse down over the button. For this | 62 // pressed when a user holds the mouse down over the button. For this |
62 // implementation, both left and right mouse buttons can trigger a change | 63 // implementation, both left and right mouse buttons can trigger a change |
63 // to the PUSHED state. | 64 // to the PUSHED state. |
64 virtual bool ShouldEnterPushedState(const ui::Event& event) OVERRIDE; | 65 virtual bool ShouldEnterPushedState(const ui::Event& event) OVERRIDE; |
65 | 66 |
66 // Returns if menu should be shown. Override this to change default behavior. | 67 // Returns if menu should be shown. Override this to change default behavior. |
67 virtual bool ShouldShowMenu(); | 68 virtual bool ShouldShowMenu(); |
68 | 69 |
69 // Function to show the dropdown menu. | 70 // Function to show the dropdown menu. |
70 virtual void ShowDropDownMenu(); | 71 virtual void ShowDropDownMenu(ui::MenuSourceType source_type); |
71 | 72 |
72 private: | 73 private: |
73 // The model that populates the attached menu. | 74 // The model that populates the attached menu. |
74 scoped_ptr<ui::MenuModel> model_; | 75 scoped_ptr<ui::MenuModel> model_; |
75 | 76 |
76 // Indicates if menu is currently showing. | 77 // Indicates if menu is currently showing. |
77 bool menu_showing_; | 78 bool menu_showing_; |
78 | 79 |
79 // Y position of mouse when left mouse button is pressed | 80 // Y position of mouse when left mouse button is pressed |
80 int y_position_on_lbuttondown_; | 81 int y_position_on_lbuttondown_; |
81 | 82 |
82 // Menu runner to display drop down menu. | 83 // Menu runner to display drop down menu. |
83 scoped_ptr<MenuRunner> menu_runner_; | 84 scoped_ptr<MenuRunner> menu_runner_; |
84 | 85 |
85 // A factory for tasks that show the dropdown context menu for the button. | 86 // A factory for tasks that show the dropdown context menu for the button. |
86 base::WeakPtrFactory<ButtonDropDown> show_menu_factory_; | 87 base::WeakPtrFactory<ButtonDropDown> show_menu_factory_; |
87 | 88 |
88 DISALLOW_COPY_AND_ASSIGN(ButtonDropDown); | 89 DISALLOW_COPY_AND_ASSIGN(ButtonDropDown); |
89 }; | 90 }; |
90 | 91 |
91 } // namespace views | 92 } // namespace views |
92 | 93 |
93 #endif // UI_VIEWS_CONTROLS_BUTTON_BUTTON_DROPDOWN_H_ | 94 #endif // UI_VIEWS_CONTROLS_BUTTON_BUTTON_DROPDOWN_H_ |
OLD | NEW |