| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/animation/ink_drop_animation_controller_impl.h" | 5 #include "ui/views/animation/ink_drop_animation_controller_impl.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/timer/timer.h" | 8 #include "base/timer/timer.h" |
| 9 #include "ui/compositor/layer.h" | 9 #include "ui/compositor/layer.h" |
| 10 #include "ui/views/animation/ink_drop_host.h" | 10 #include "ui/views/animation/ink_drop_host.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 const int kHoverFadeOutBeforeAnimationDurationInMs = 300; | 32 const int kHoverFadeOutBeforeAnimationDurationInMs = 300; |
| 33 | 33 |
| 34 // The amount of time in milliseconds that |hover_| should delay after a ripple | 34 // The amount of time in milliseconds that |hover_| should delay after a ripple |
| 35 // animation before fading in. | 35 // animation before fading in. |
| 36 const int kHoverFadeInAfterAnimationDelayInMs = 1000; | 36 const int kHoverFadeInAfterAnimationDelayInMs = 1000; |
| 37 | 37 |
| 38 // Returns true if an ink drop with the given |ink_drop_state| should | 38 // Returns true if an ink drop with the given |ink_drop_state| should |
| 39 // automatically transition to the InkDropState::HIDDEN state. | 39 // automatically transition to the InkDropState::HIDDEN state. |
| 40 bool ShouldAnimateToHidden(InkDropState ink_drop_state) { | 40 bool ShouldAnimateToHidden(InkDropState ink_drop_state) { |
| 41 switch (ink_drop_state) { | 41 switch (ink_drop_state) { |
| 42 case views::InkDropState::QUICK_ACTION: | 42 case views::InkDropState::ACTION_TRIGGERED: |
| 43 case views::InkDropState::SLOW_ACTION: | 43 case views::InkDropState::ALTERNATE_ACTION_TRIGGERED: |
| 44 case views::InkDropState::DEACTIVATED: | 44 case views::InkDropState::DEACTIVATED: |
| 45 return true; | 45 return true; |
| 46 default: | 46 default: |
| 47 return false; | 47 return false; |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 } // namespace | 51 } // namespace |
| 52 | 52 |
| 53 InkDropAnimationControllerImpl::InkDropAnimationControllerImpl( | 53 InkDropAnimationControllerImpl::InkDropAnimationControllerImpl( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 SetHoveredInternal(is_hovered, | 106 SetHoveredInternal(is_hovered, |
| 107 is_hovered ? base::TimeDelta::FromMilliseconds( | 107 is_hovered ? base::TimeDelta::FromMilliseconds( |
| 108 kHoverFadeInFromUserInputDurationInMs) | 108 kHoverFadeInFromUserInputDurationInMs) |
| 109 : base::TimeDelta::FromMilliseconds( | 109 : base::TimeDelta::FromMilliseconds( |
| 110 kHoverFadeOutFromUserInputDurationInMs)); | 110 kHoverFadeOutFromUserInputDurationInMs)); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void InkDropAnimationControllerImpl::CompleteHiddenTargetedAnimations() { | 113 void InkDropAnimationControllerImpl::CompleteHiddenTargetedAnimations() { |
| 114 if (ink_drop_animation_->target_ink_drop_state() == InkDropState::HIDDEN || | 114 if (ink_drop_animation_->target_ink_drop_state() == InkDropState::HIDDEN || |
| 115 ShouldAnimateToHidden(ink_drop_animation_->target_ink_drop_state())) { | 115 ShouldAnimateToHidden(ink_drop_animation_->target_ink_drop_state())) { |
| 116 ink_drop_animation_->HideImmediately(); | 116 CreateInkDropAnimation(); |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 void InkDropAnimationControllerImpl::CreateInkDropAnimation() { | 120 void InkDropAnimationControllerImpl::CreateInkDropAnimation() { |
| 121 DestroyInkDropAnimation(); | 121 DestroyInkDropAnimation(); |
| 122 ink_drop_animation_ = ink_drop_host_->CreateInkDropAnimation(); | 122 ink_drop_animation_ = ink_drop_host_->CreateInkDropAnimation(); |
| 123 ink_drop_animation_->set_observer(this); | 123 ink_drop_animation_->set_observer(this); |
| 124 root_layer_->Add(ink_drop_animation_->GetRootLayer()); | 124 root_layer_->Add(ink_drop_animation_->GetRootLayer()); |
| 125 } | 125 } |
| 126 | 126 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 hover_after_animation_timer_.reset(); | 207 hover_after_animation_timer_.reset(); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void InkDropAnimationControllerImpl::HoverAfterAnimationTimerFired() { | 210 void InkDropAnimationControllerImpl::HoverAfterAnimationTimerFired() { |
| 211 SetHoveredInternal(true, base::TimeDelta::FromMilliseconds( | 211 SetHoveredInternal(true, base::TimeDelta::FromMilliseconds( |
| 212 kHoverFadeInAfterAnimationDurationInMs)); | 212 kHoverFadeInAfterAnimationDurationInMs)); |
| 213 hover_after_animation_timer_.reset(); | 213 hover_after_animation_timer_.reset(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 } // namespace views | 216 } // namespace views |
| OLD | NEW |