Chromium Code Reviews| Index: ui/views/animation/flood_fill_ink_drop_animation.cc |
| diff --git a/ui/views/animation/flood_fill_ink_drop_animation.cc b/ui/views/animation/flood_fill_ink_drop_animation.cc |
| index 77e091e4e495e6e81961bff87257feeec3d10679..7f0b855fa6249280ae4b03383ce5eaf95bfd15cc 100644 |
| --- a/ui/views/animation/flood_fill_ink_drop_animation.cc |
| +++ b/ui/views/animation/flood_fill_ink_drop_animation.cc |
| @@ -18,7 +18,7 @@ namespace { |
| // The minimum radius to use when scaling the painted layers. Smaller values |
| // were causing visual anomalies. |
| -const float kMinRadius = 0.01f; |
| +const float kMinRadius = 1.f; |
| // All the sub animations that are used to animate each of the InkDropStates. |
| // These are used to get time durations with |
| @@ -45,21 +45,23 @@ enum InkDropSubAnimations { |
| // bounds. |
| ACTION_PENDING_TRANSFORM, |
| - // QUICK_ACTION sub animations. |
| + // ACTION_TRIGGERED sub animations. |
| - // The QUICK_ACTION sub animation that is fading out to a hidden opacity. |
| - QUICK_ACTION_FADE_OUT, |
| + // The ACTION_TRIGGERED sub animation that is fading out to a hidden opacity. |
| + ACTION_TRIGGERED_FADE_OUT, |
| - // SLOW_ACTION_PENDING sub animations. |
| + // ALTERNATE_ACTION_PENDING sub animations. |
| - // The SLOW_ACTION_PENDING animation has only one sub animation which animates |
| + // The ALTERNATE_ACTION_PENDING animation has only one sub animation which |
| + // animates |
| // the circleto fill the bounds at visible opacity. |
| - SLOW_ACTION_PENDING, |
| + ALTERNATE_ACTION_PENDING, |
| - // SLOW_ACTION sub animations. |
| + // ALTERNATE_ACTION_TRIGGERED sub animations. |
| - // The SLOW_ACTION sub animation that is fading out to a hidden opacity. |
| - SLOW_ACTION_FADE_OUT, |
| + // The ALTERNATE_ACTION_TRIGGERED sub animation that is fading out to a hidden |
| + // opacity. |
| + ALTERNATE_ACTION_TRIGGERED_FADE_OUT, |
| // ACTIVATED sub animations. |
| @@ -83,9 +85,9 @@ int kAnimationDurationInMs[] = { |
| 300, // HIDDEN_TRANSFORM |
| 0, // ACTION_PENDING_FADE_IN |
| 240, // ACTION_PENDING_TRANSFORM |
| - 300, // QUICK_ACTION_FADE_OUT |
| - 200, // SLOW_ACTION_PENDING |
| - 300, // SLOW_ACTION_FADE_OUT |
| + 300, // ACTION_TRIGGERED_FADE_OUT |
| + 200, // ALTERNATE_ACTION_PENDING |
| + 300, // ALTERNATE_ACTION_TRIGGERED_FADE_OUT |
| 150, // ACTIVATED_FADE_IN |
| 200, // ACTIVATED_TRANSFORM |
| 300, // DEACTIVATED_FADE_OUT |
| @@ -100,25 +102,6 @@ base::TimeDelta GetAnimationDuration(InkDropSubAnimations state) { |
| kAnimationDurationInMs[state]); |
| } |
| -// Calculates the largest distance from |point| to the corners of a rectangle |
| -// with origin (0, 0) and the given |size|. |
| -float CalculateLargestDistanceToCorners(const gfx::Size& size, |
| - const gfx::Point& point) { |
| - const float top_left_distance = gfx::Vector2dF(point.x(), point.y()).Length(); |
| - const float top_right_distance = |
| - gfx::Vector2dF(size.width() - point.x(), point.y()).Length(); |
| - const float bottom_left_distance = |
| - gfx::Vector2dF(point.x(), size.height() - point.y()).Length(); |
| - const float bottom_right_distance = |
| - gfx::Vector2dF(size.width() - point.x(), size.height() - point.y()) |
| - .Length(); |
| - |
| - float largest_distance = std::max(top_left_distance, top_right_distance); |
| - largest_distance = std::max(largest_distance, bottom_left_distance); |
| - largest_distance = std::max(largest_distance, bottom_right_distance); |
| - return largest_distance; |
| -} |
| - |
| } // namespace |
| namespace views { |
| @@ -180,7 +163,6 @@ void FloodFillInkDropAnimation::AnimateStateChange( |
| case InkDropState::HIDDEN: |
| if (!IsVisible()) { |
| SetStateToHidden(); |
| - break; |
| } else { |
| AnimateToOpacity(kHiddenOpacity, GetAnimationDuration(HIDDEN_FADE_OUT), |
| ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, |
| @@ -204,15 +186,13 @@ void FloodFillInkDropAnimation::AnimateStateChange( |
| ui::LayerAnimator::ENQUEUE_NEW_ANIMATION, |
| gfx::Tween::EASE_IN, animation_observer); |
| - const gfx::Transform transform = CalculateTransform( |
| - CalculateLargestDistanceToCorners(size_, center_point_)); |
| - AnimateToTransform(transform, |
| + AnimateToTransform(GetActivatedTargetTransform(), |
| GetAnimationDuration(ACTION_PENDING_TRANSFORM), |
| ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, |
| gfx::Tween::FAST_OUT_SLOW_IN, animation_observer); |
| break; |
| } |
| - case InkDropState::QUICK_ACTION: { |
| + case InkDropState::ACTION_TRIGGERED: { |
| DCHECK(old_ink_drop_state == InkDropState::HIDDEN || |
| old_ink_drop_state == InkDropState::ACTION_PENDING); |
| if (old_ink_drop_state == InkDropState::HIDDEN) { |
| @@ -220,28 +200,27 @@ void FloodFillInkDropAnimation::AnimateStateChange( |
| animation_observer); |
| } |
| AnimateToOpacity(kHiddenOpacity, |
| - GetAnimationDuration(QUICK_ACTION_FADE_OUT), |
| + GetAnimationDuration(ACTION_TRIGGERED_FADE_OUT), |
| ui::LayerAnimator::ENQUEUE_NEW_ANIMATION, |
| gfx::Tween::EASE_IN_OUT, animation_observer); |
| break; |
| } |
| - case InkDropState::SLOW_ACTION_PENDING: { |
| + case InkDropState::ALTERNATE_ACTION_PENDING: { |
| DCHECK(old_ink_drop_state == InkDropState::ACTION_PENDING); |
| AnimateToOpacity(kVisibleOpacity, |
| - GetAnimationDuration(SLOW_ACTION_PENDING), |
| + GetAnimationDuration(ALTERNATE_ACTION_PENDING), |
| ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, |
| gfx::Tween::EASE_IN, animation_observer); |
| - const gfx::Transform transform = CalculateTransform( |
| - CalculateLargestDistanceToCorners(size_, center_point_)); |
| - AnimateToTransform(transform, GetAnimationDuration(SLOW_ACTION_PENDING), |
| + AnimateToTransform(GetActivatedTargetTransform(), |
| + GetAnimationDuration(ALTERNATE_ACTION_PENDING), |
| ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, |
| gfx::Tween::EASE_IN_OUT, animation_observer); |
| break; |
| } |
| - case InkDropState::SLOW_ACTION: |
| - DCHECK(old_ink_drop_state == InkDropState::SLOW_ACTION_PENDING); |
| - AnimateToOpacity(kHiddenOpacity, |
| - GetAnimationDuration(SLOW_ACTION_FADE_OUT), |
| + case InkDropState::ALTERNATE_ACTION_TRIGGERED: |
| + DCHECK(old_ink_drop_state == InkDropState::ALTERNATE_ACTION_PENDING); |
| + AnimateToOpacity(kHiddenOpacity, GetAnimationDuration( |
| + ALTERNATE_ACTION_TRIGGERED_FADE_OUT), |
| ui::LayerAnimator::ENQUEUE_NEW_ANIMATION, |
| gfx::Tween::EASE_IN_OUT, animation_observer); |
| break; |
| @@ -265,8 +244,7 @@ void FloodFillInkDropAnimation::AnimateStateChange( |
| } |
| void FloodFillInkDropAnimation::SetStateToHidden() { |
| - gfx::Transform transform = CalculateTransform(kMinRadius); |
| - painted_layer_.SetTransform(transform); |
| + painted_layer_.SetTransform(CalculateTransform(kMinRadius)); |
| root_layer_.SetOpacity(InkDropAnimation::kHiddenOpacity); |
| root_layer_.SetVisible(false); |
| } |
| @@ -337,8 +315,10 @@ gfx::Transform FloodFillInkDropAnimation::CalculateTransform( |
| } |
| gfx::Transform FloodFillInkDropAnimation::GetActivatedTargetTransform() const { |
|
bruthig
2016/04/04 17:20:17
nit: It probably makes sense to rename this now th
Evan Stade
2016/04/04 18:09:09
Done.
|
| + // TODO(estade): get rid of this 2, but make the fade out start before the |
| + // active/action transform is done. |
| return CalculateTransform( |
| - CalculateLargestDistanceToCorners(size_, center_point_)); |
| + gfx::Vector2dF(size_.width(), size_.height()).Length() / 2); |
| } |
| } // namespace views |