| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 ButtonDropDown::~ButtonDropDown() { | 42 ButtonDropDown::~ButtonDropDown() { |
| 43 } | 43 } |
| 44 | 44 |
| 45 //////////////////////////////////////////////////////////////////////////////// | 45 //////////////////////////////////////////////////////////////////////////////// |
| 46 // | 46 // |
| 47 // ButtonDropDown - Events | 47 // ButtonDropDown - Events |
| 48 // | 48 // |
| 49 //////////////////////////////////////////////////////////////////////////////// | 49 //////////////////////////////////////////////////////////////////////////////// |
| 50 | 50 |
| 51 bool ButtonDropDown::OnMousePressed(const MouseEvent& event) { | 51 bool ButtonDropDown::OnMousePressed(const MouseEvent& event) { |
| 52 if (IsEnabled() && IsTriggerableEvent(event) && HitTest(event.location())) { | 52 if (enabled() && IsTriggerableEvent(event) && HitTest(event.location())) { |
| 53 // Store the y pos of the mouse coordinates so we can use them later to | 53 // Store the y pos of the mouse coordinates so we can use them later to |
| 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(), |
| (...skipping 21 matching lines...) Expand all Loading... |
| 84 | 84 |
| 85 void ButtonDropDown::OnMouseReleased(const MouseEvent& event) { | 85 void ButtonDropDown::OnMouseReleased(const MouseEvent& event) { |
| 86 if (IsTriggerableEvent(event) || | 86 if (IsTriggerableEvent(event) || |
| 87 (event.IsRightMouseButton() && !HitTest(event.location()))) { | 87 (event.IsRightMouseButton() && !HitTest(event.location()))) { |
| 88 ImageButton::OnMouseReleased(event); | 88 ImageButton::OnMouseReleased(event); |
| 89 } | 89 } |
| 90 | 90 |
| 91 if (IsTriggerableEvent(event)) | 91 if (IsTriggerableEvent(event)) |
| 92 show_menu_factory_.InvalidateWeakPtrs(); | 92 show_menu_factory_.InvalidateWeakPtrs(); |
| 93 | 93 |
| 94 if (IsEnabled() && event.IsRightMouseButton() && HitTest(event.location())) { | 94 if (enabled() && event.IsRightMouseButton() && HitTest(event.location())) { |
| 95 show_menu_factory_.InvalidateWeakPtrs(); | 95 show_menu_factory_.InvalidateWeakPtrs(); |
| 96 ShowDropDownMenu(GetWidget()->GetNativeView()); | 96 ShowDropDownMenu(GetWidget()->GetNativeView()); |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 | 99 |
| 100 std::string ButtonDropDown::GetClassName() const { | 100 std::string ButtonDropDown::GetClassName() const { |
| 101 return kViewClassName; | 101 return kViewClassName; |
| 102 } | 102 } |
| 103 | 103 |
| 104 void ButtonDropDown::OnMouseExited(const MouseEvent& event) { | 104 void ButtonDropDown::OnMouseExited(const MouseEvent& event) { |
| (...skipping 80 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 |