OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // determine if the user dragged the mouse down (which should pop up the | 54 // determine if the user dragged the mouse down (which should pop up the |
55 // drag down menu immediately, instead of waiting for the timer) | 55 // drag down menu immediately, instead of waiting for the timer) |
56 y_position_on_lbuttondown_ = event.y(); | 56 y_position_on_lbuttondown_ = event.y(); |
57 | 57 |
58 // Schedule a task that will show the menu. | 58 // Schedule a task that will show the menu. |
59 MessageLoop::current()->PostDelayedTask( | 59 MessageLoop::current()->PostDelayedTask( |
60 FROM_HERE, | 60 FROM_HERE, |
61 base::Bind(&ButtonDropDown::ShowDropDownMenu, | 61 base::Bind(&ButtonDropDown::ShowDropDownMenu, |
62 show_menu_factory_.GetWeakPtr(), | 62 show_menu_factory_.GetWeakPtr(), |
63 GetWidget()->GetNativeView()), | 63 GetWidget()->GetNativeView()), |
64 kMenuTimerDelay); | 64 base::TimeDelta::FromMilliseconds(kMenuTimerDelay)); |
65 } | 65 } |
66 return ImageButton::OnMousePressed(event); | 66 return ImageButton::OnMousePressed(event); |
67 } | 67 } |
68 | 68 |
69 bool ButtonDropDown::OnMouseDragged(const MouseEvent& event) { | 69 bool ButtonDropDown::OnMouseDragged(const MouseEvent& event) { |
70 bool result = ImageButton::OnMouseDragged(event); | 70 bool result = ImageButton::OnMouseDragged(event); |
71 | 71 |
72 if (show_menu_factory_.HasWeakPtrs()) { | 72 if (show_menu_factory_.HasWeakPtrs()) { |
73 // If the mouse is dragged to a y position lower than where it was when | 73 // If the mouse is dragged to a y position lower than where it was when |
74 // clicked then we should not wait for the menu to appear but show | 74 // clicked then we should not wait for the menu to appear but show |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 SetState(BS_NORMAL); | 185 SetState(BS_NORMAL); |
186 } | 186 } |
187 | 187 |
188 //////////////////////////////////////////////////////////////////////////////// | 188 //////////////////////////////////////////////////////////////////////////////// |
189 // | 189 // |
190 // ButtonDropDown - Accessibility | 190 // ButtonDropDown - Accessibility |
191 // | 191 // |
192 //////////////////////////////////////////////////////////////////////////////// | 192 //////////////////////////////////////////////////////////////////////////////// |
193 | 193 |
194 } // namespace views | 194 } // namespace views |
OLD | NEW |