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/event.h" | 9 #include "ui/base/event.h" |
10 #include "ui/base/keycodes/keyboard_codes.h" | 10 #include "ui/base/keycodes/keyboard_codes.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 SetState(BS_NORMAL); | 197 SetState(BS_NORMAL); |
198 // TODO(beng): remove once NotifyClick takes ui::Event. | 198 // TODO(beng): remove once NotifyClick takes ui::Event. |
199 ui::MouseEvent synthetic_event(ui::ET_MOUSE_RELEASED, | 199 ui::MouseEvent synthetic_event(ui::ET_MOUSE_RELEASED, |
200 gfx::Point(), | 200 gfx::Point(), |
201 gfx::Point(), | 201 gfx::Point(), |
202 ui::EF_LEFT_MOUSE_BUTTON); | 202 ui::EF_LEFT_MOUSE_BUTTON); |
203 NotifyClick(synthetic_event); | 203 NotifyClick(synthetic_event); |
204 return true; | 204 return true; |
205 } | 205 } |
206 | 206 |
207 ui::GestureStatus CustomButton::OnGestureEvent(const GestureEvent& event) { | 207 ui::GestureStatus CustomButton::OnGestureEvent(const ui::GestureEvent& event) { |
208 if (state_ == BS_DISABLED) | 208 if (state_ == BS_DISABLED) |
209 return Button::OnGestureEvent(event); | 209 return Button::OnGestureEvent(event); |
210 | 210 |
211 if (event.type() == ui::ET_GESTURE_TAP && IsTriggerableEvent(event)) { | 211 if (event.type() == ui::ET_GESTURE_TAP && IsTriggerableEvent(event)) { |
212 // Set the button state to hot and start the animation fully faded in. The | 212 // Set the button state to hot and start the animation fully faded in. The |
213 // TAP_UP event issued immediately after will set the state to BS_NORMAL | 213 // TAP_UP event issued immediately after will set the state to BS_NORMAL |
214 // beginning the fade out animation. See http://crbug.com/131184. | 214 // beginning the fade out animation. See http://crbug.com/131184. |
215 SetState(BS_HOT); | 215 SetState(BS_HOT); |
216 hover_animation_->Reset(1.0); | 216 hover_animation_->Reset(1.0); |
217 NotifyClick(event); | 217 NotifyClick(event); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 if (!is_add && state_ != BS_DISABLED) | 320 if (!is_add && state_ != BS_DISABLED) |
321 SetState(BS_NORMAL); | 321 SetState(BS_NORMAL); |
322 } | 322 } |
323 | 323 |
324 void CustomButton::OnBlur() { | 324 void CustomButton::OnBlur() { |
325 if (IsHotTracked()) | 325 if (IsHotTracked()) |
326 SetState(BS_NORMAL); | 326 SetState(BS_NORMAL); |
327 } | 327 } |
328 | 328 |
329 } // namespace views | 329 } // namespace views |
OLD | NEW |