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 #include "ui/views/controls/button/button_dropdown.h" | 5 #include "ui/views/controls/button/button_dropdown.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 | 53 |
54 //////////////////////////////////////////////////////////////////////////////// | 54 //////////////////////////////////////////////////////////////////////////////// |
55 // | 55 // |
56 // ButtonDropDown - Events | 56 // ButtonDropDown - Events |
57 // | 57 // |
58 //////////////////////////////////////////////////////////////////////////////// | 58 //////////////////////////////////////////////////////////////////////////////// |
59 | 59 |
60 bool ButtonDropDown::OnMousePressed(const MouseEvent& event) { | 60 bool ButtonDropDown::OnMousePressed(const MouseEvent& event) { |
61 if (enabled() && ShouldShowMenu() && | 61 if (enabled() && ShouldShowMenu() && |
62 IsTriggerableEvent(event) && HitTest(event.location())) { | 62 IsTriggerableEvent(event) && HitTestPoint(event.location())) { |
63 // Store the y pos of the mouse coordinates so we can use them later to | 63 // Store the y pos of the mouse coordinates so we can use them later to |
64 // determine if the user dragged the mouse down (which should pop up the | 64 // determine if the user dragged the mouse down (which should pop up the |
65 // drag down menu immediately, instead of waiting for the timer) | 65 // drag down menu immediately, instead of waiting for the timer) |
66 y_position_on_lbuttondown_ = event.y(); | 66 y_position_on_lbuttondown_ = event.y(); |
67 | 67 |
68 // Schedule a task that will show the menu. | 68 // Schedule a task that will show the menu. |
69 MessageLoop::current()->PostDelayedTask( | 69 MessageLoop::current()->PostDelayedTask( |
70 FROM_HERE, | 70 FROM_HERE, |
71 base::Bind(&ButtonDropDown::ShowDropDownMenu, | 71 base::Bind(&ButtonDropDown::ShowDropDownMenu, |
72 show_menu_factory_.GetWeakPtr()), | 72 show_menu_factory_.GetWeakPtr()), |
(...skipping 13 matching lines...) Expand all Loading... |
86 show_menu_factory_.InvalidateWeakPtrs(); | 86 show_menu_factory_.InvalidateWeakPtrs(); |
87 ShowDropDownMenu(); | 87 ShowDropDownMenu(); |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 return result; | 91 return result; |
92 } | 92 } |
93 | 93 |
94 void ButtonDropDown::OnMouseReleased(const MouseEvent& event) { | 94 void ButtonDropDown::OnMouseReleased(const MouseEvent& event) { |
95 if (IsTriggerableEvent(event) || | 95 if (IsTriggerableEvent(event) || |
96 (event.IsRightMouseButton() && !HitTest(event.location()))) { | 96 (event.IsRightMouseButton() && !HitTestPoint(event.location()))) { |
97 ImageButton::OnMouseReleased(event); | 97 ImageButton::OnMouseReleased(event); |
98 } | 98 } |
99 | 99 |
100 if (IsTriggerableEvent(event)) | 100 if (IsTriggerableEvent(event)) |
101 show_menu_factory_.InvalidateWeakPtrs(); | 101 show_menu_factory_.InvalidateWeakPtrs(); |
102 | 102 |
103 if (enabled() && event.IsRightMouseButton() && HitTest(event.location())) { | 103 if (enabled() && event.IsRightMouseButton() && |
| 104 HitTestPoint(event.location())) { |
104 show_menu_factory_.InvalidateWeakPtrs(); | 105 show_menu_factory_.InvalidateWeakPtrs(); |
105 ShowDropDownMenu(); | 106 ShowDropDownMenu(); |
106 } | 107 } |
107 } | 108 } |
108 | 109 |
109 std::string ButtonDropDown::GetClassName() const { | 110 std::string ButtonDropDown::GetClassName() const { |
110 return kViewClassName; | 111 return kViewClassName; |
111 } | 112 } |
112 | 113 |
113 void ButtonDropDown::OnMouseExited(const MouseEvent& event) { | 114 void ButtonDropDown::OnMouseExited(const MouseEvent& event) { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 SetState(BS_NORMAL); | 212 SetState(BS_NORMAL); |
212 } | 213 } |
213 | 214 |
214 //////////////////////////////////////////////////////////////////////////////// | 215 //////////////////////////////////////////////////////////////////////////////// |
215 // | 216 // |
216 // ButtonDropDown - Accessibility | 217 // ButtonDropDown - Accessibility |
217 // | 218 // |
218 //////////////////////////////////////////////////////////////////////////////// | 219 //////////////////////////////////////////////////////////////////////////////// |
219 | 220 |
220 } // namespace views | 221 } // namespace views |
OLD | NEW |