Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Side by Side Diff: ui/views/controls/button/button_dropdown.cc

Issue 10832282: Replace views::MouseEvent with ui::MouseEvent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/button/button_dropdown.h ('k') | ui/views/controls/button/custom_button.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 bool ButtonDropDown::IsMenuShowing() const { 50 bool ButtonDropDown::IsMenuShowing() const {
51 return menu_showing_; 51 return menu_showing_;
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 ui::MouseEvent& event) {
61 if (enabled() && ShouldShowMenu() && 61 if (enabled() && ShouldShowMenu() &&
62 IsTriggerableEvent(event) && HitTestPoint(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()),
73 base::TimeDelta::FromMilliseconds(kMenuTimerDelay)); 73 base::TimeDelta::FromMilliseconds(kMenuTimerDelay));
74 } 74 }
75 return ImageButton::OnMousePressed(event); 75 return ImageButton::OnMousePressed(event);
76 } 76 }
77 77
78 bool ButtonDropDown::OnMouseDragged(const MouseEvent& event) { 78 bool ButtonDropDown::OnMouseDragged(const ui::MouseEvent& event) {
79 bool result = ImageButton::OnMouseDragged(event); 79 bool result = ImageButton::OnMouseDragged(event);
80 80
81 if (show_menu_factory_.HasWeakPtrs()) { 81 if (show_menu_factory_.HasWeakPtrs()) {
82 // If the mouse is dragged to a y position lower than where it was when 82 // If the mouse is dragged to a y position lower than where it was when
83 // clicked then we should not wait for the menu to appear but show 83 // clicked then we should not wait for the menu to appear but show
84 // it immediately. 84 // it immediately.
85 if (event.y() > y_position_on_lbuttondown_ + GetHorizontalDragThreshold()) { 85 if (event.y() > y_position_on_lbuttondown_ + GetHorizontalDragThreshold()) {
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 ui::MouseEvent& event) {
95 if (IsTriggerableEvent(event) || 95 if (IsTriggerableEvent(event) ||
96 (event.IsRightMouseButton() && !HitTestPoint(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() && 103 if (enabled() && event.IsRightMouseButton() &&
104 HitTestPoint(event.location())) { 104 HitTestPoint(event.location())) {
105 show_menu_factory_.InvalidateWeakPtrs(); 105 show_menu_factory_.InvalidateWeakPtrs();
106 ShowDropDownMenu(); 106 ShowDropDownMenu();
107 } 107 }
108 } 108 }
109 109
110 std::string ButtonDropDown::GetClassName() const { 110 std::string ButtonDropDown::GetClassName() const {
111 return kViewClassName; 111 return kViewClassName;
112 } 112 }
113 113
114 void ButtonDropDown::OnMouseExited(const MouseEvent& event) { 114 void ButtonDropDown::OnMouseExited(const ui::MouseEvent& event) {
115 // Starting a drag results in a MouseExited, we need to ignore it. 115 // Starting a drag results in a MouseExited, we need to ignore it.
116 // A right click release triggers an exit event. We want to 116 // A right click release triggers an exit event. We want to
117 // remain in a PUSHED state until the drop down menu closes. 117 // remain in a PUSHED state until the drop down menu closes.
118 if (state_ != BS_DISABLED && !InDrag() && state_ != BS_PUSHED) 118 if (state_ != BS_DISABLED && !InDrag() && state_ != BS_PUSHED)
119 SetState(BS_NORMAL); 119 SetState(BS_NORMAL);
120 } 120 }
121 121
122 void ButtonDropDown::ShowContextMenu(const gfx::Point& p, 122 void ButtonDropDown::ShowContextMenu(const gfx::Point& p,
123 bool is_mouse_gesture) { 123 bool is_mouse_gesture) {
124 show_menu_factory_.InvalidateWeakPtrs(); 124 show_menu_factory_.InvalidateWeakPtrs();
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 SetState(BS_NORMAL); 212 SetState(BS_NORMAL);
213 } 213 }
214 214
215 //////////////////////////////////////////////////////////////////////////////// 215 ////////////////////////////////////////////////////////////////////////////////
216 // 216 //
217 // ButtonDropDown - Accessibility 217 // ButtonDropDown - Accessibility
218 // 218 //
219 //////////////////////////////////////////////////////////////////////////////// 219 ////////////////////////////////////////////////////////////////////////////////
220 220
221 } // namespace views 221 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/button_dropdown.h ('k') | ui/views/controls/button/custom_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698