| 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/accessibility/ax_view_state.h" | 7 #include "ui/accessibility/ax_view_state.h" |
| 8 #include "ui/events/event.h" | 8 #include "ui/events/event.h" |
| 9 #include "ui/events/event_utils.h" | 9 #include "ui/events/event_utils.h" |
| 10 #include "ui/events/keycodes/keyboard_codes.h" | 10 #include "ui/events/keycodes/keyboard_codes.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 hover_animation_.Reset(1); | 87 hover_animation_.Reset(1); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 state_ = state; | 91 state_ = state; |
| 92 StateChanged(); | 92 StateChanged(); |
| 93 SchedulePaint(); | 93 SchedulePaint(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void CustomButton::StartThrobbing(int cycles_til_stop) { | 96 void CustomButton::StartThrobbing(int cycles_til_stop) { |
| 97 if (!animate_on_state_change_) |
| 98 return; |
| 97 is_throbbing_ = true; | 99 is_throbbing_ = true; |
| 98 hover_animation_.StartThrobbing(cycles_til_stop); | 100 hover_animation_.StartThrobbing(cycles_til_stop); |
| 99 } | 101 } |
| 100 | 102 |
| 101 void CustomButton::StopThrobbing() { | 103 void CustomButton::StopThrobbing() { |
| 102 if (hover_animation_.is_animating()) { | 104 if (hover_animation_.is_animating()) { |
| 103 hover_animation_.Stop(); | 105 hover_animation_.Stop(); |
| 104 SchedulePaint(); | 106 SchedulePaint(); |
| 105 } | 107 } |
| 106 } | 108 } |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 return true; | 398 return true; |
| 397 } | 399 } |
| 398 | 400 |
| 399 //////////////////////////////////////////////////////////////////////////////// | 401 //////////////////////////////////////////////////////////////////////////////// |
| 400 // CustomButton, protected: | 402 // CustomButton, protected: |
| 401 | 403 |
| 402 CustomButton::CustomButton(ButtonListener* listener) | 404 CustomButton::CustomButton(ButtonListener* listener) |
| 403 : Button(listener), | 405 : Button(listener), |
| 404 state_(STATE_NORMAL), | 406 state_(STATE_NORMAL), |
| 405 hover_animation_(this), | 407 hover_animation_(this), |
| 406 animate_on_state_change_(true), | |
| 407 is_throbbing_(false), | 408 is_throbbing_(false), |
| 408 triggerable_event_flags_(ui::EF_LEFT_MOUSE_BUTTON), | 409 triggerable_event_flags_(ui::EF_LEFT_MOUSE_BUTTON), |
| 409 request_focus_on_press_(false), | 410 request_focus_on_press_(false), |
| 410 notify_action_(NOTIFY_ON_RELEASE), | 411 notify_action_(NOTIFY_ON_RELEASE), |
| 411 has_ink_drop_action_on_click_(false), | 412 has_ink_drop_action_on_click_(false), |
| 412 hide_ink_drop_when_showing_context_menu_(true), | 413 hide_ink_drop_when_showing_context_menu_(true), |
| 413 ink_drop_base_color_(gfx::kPlaceholderColor) { | 414 ink_drop_base_color_(gfx::kPlaceholderColor) { |
| 414 hover_animation_.SetSlideDuration(kHoverFadeDurationMs); | 415 hover_animation_.SetSlideDuration(kHoverFadeDurationMs); |
| 415 } | 416 } |
| 416 | 417 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 views::InkDropState::ACTION_PENDING || | 474 views::InkDropState::ACTION_PENDING || |
| 474 ink_drop()->GetTargetInkDropState() == | 475 ink_drop()->GetTargetInkDropState() == |
| 475 views::InkDropState::ALTERNATE_ACTION_PENDING) { | 476 views::InkDropState::ALTERNATE_ACTION_PENDING) { |
| 476 AnimateInkDrop(views::InkDropState::HIDDEN, | 477 AnimateInkDrop(views::InkDropState::HIDDEN, |
| 477 ui::LocatedEvent::FromIfValid(&event)); | 478 ui::LocatedEvent::FromIfValid(&event)); |
| 478 } | 479 } |
| 479 Button::OnClickCanceled(event); | 480 Button::OnClickCanceled(event); |
| 480 } | 481 } |
| 481 | 482 |
| 482 } // namespace views | 483 } // namespace views |
| OLD | NEW |