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/custom_button.h" | 5 #include "ui/views/controls/button/custom_button.h" |
6 | 6 |
7 #include "ui/base/accessibility/accessible_view_state.h" | 7 #include "ui/base/accessibility/accessible_view_state.h" |
8 #include "ui/base/animation/throb_animation.h" | 8 #include "ui/base/animation/throb_animation.h" |
9 #include "ui/base/keycodes/keyboard_codes.h" | 9 #include "ui/base/keycodes/keyboard_codes.h" |
10 #include "ui/gfx/screen.h" | 10 #include "ui/gfx/screen.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 if ((state_ == BS_DISABLED) || (event.key_code() != ui::VKEY_SPACE)) | 188 if ((state_ == BS_DISABLED) || (event.key_code() != ui::VKEY_SPACE)) |
189 return false; | 189 return false; |
190 | 190 |
191 SetState(BS_NORMAL); | 191 SetState(BS_NORMAL); |
192 NotifyClick(event); | 192 NotifyClick(event); |
193 return true; | 193 return true; |
194 } | 194 } |
195 | 195 |
196 ui::GestureStatus CustomButton::OnGestureEvent(const GestureEvent& event) { | 196 ui::GestureStatus CustomButton::OnGestureEvent(const GestureEvent& event) { |
197 if (state_ == BS_DISABLED) | 197 if (state_ == BS_DISABLED) |
198 return ui::GESTURE_STATUS_UNKNOWN; | 198 return Button::OnGestureEvent(event); |
199 | 199 |
200 if (event.type() == ui::ET_GESTURE_TAP) { | 200 if (event.type() == ui::ET_GESTURE_TAP) { |
201 // Set the button state to hot and start the animation fully faded in. The | 201 // Set the button state to hot and start the animation fully faded in. The |
202 // TAP_UP event issued immediately after will set the state to BS_NORMAL | 202 // TAP_UP event issued immediately after will set the state to BS_NORMAL |
203 // beginning the fade out animation. See http://crbug.com/131184. | 203 // beginning the fade out animation. See http://crbug.com/131184. |
204 SetState(BS_HOT); | 204 SetState(BS_HOT); |
205 hover_animation_->Reset(1.0); | 205 hover_animation_->Reset(1.0); |
206 NotifyClick(event); | 206 NotifyClick(event); |
207 return ui::GESTURE_STATUS_CONSUMED; | 207 return ui::GESTURE_STATUS_CONSUMED; |
208 } else if (event.type() == ui::ET_GESTURE_TAP_DOWN) { | 208 } else if (event.type() == ui::ET_GESTURE_TAP_DOWN) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 if (!is_add && state_ != BS_DISABLED) | 298 if (!is_add && state_ != BS_DISABLED) |
299 SetState(BS_NORMAL); | 299 SetState(BS_NORMAL); |
300 } | 300 } |
301 | 301 |
302 void CustomButton::OnBlur() { | 302 void CustomButton::OnBlur() { |
303 if (IsHotTracked()) | 303 if (IsHotTracked()) |
304 SetState(BS_NORMAL); | 304 SetState(BS_NORMAL); |
305 } | 305 } |
306 | 306 |
307 } // namespace views | 307 } // namespace views |
OLD | NEW |