Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Unified Diff: ui/views/animation/flood_fill_ink_drop_animation.cc

Issue 1832963002: MD - add ripples to DL shelf items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: worth reviewing Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..2de0c90eb4d4ebe27d0f0e43e5b6fad2543eadd0 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;
Evan Stade 2016/03/31 03:41:27 this was the source of the problematic sizing (it
bruthig 2016/03/31 19:39:03 Acknowledged.
// All the sub animations that are used to animate each of the InkDropStates.
// These are used to get time durations with
@@ -100,25 +100,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,
Evan Stade 2016/03/31 03:41:27 This calculation is a bit overkill for any centerp
bruthig 2016/03/31 19:39:03 Yes this is definitely overkill for ripples that a
Evan Stade 2016/03/31 21:07:38 With this change, the speed is not constant WRT th
bruthig 2016/03/31 22:46:19 I need to digest this a bit more.
- 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,15 +161,10 @@ void FloodFillInkDropAnimation::AnimateStateChange(
case InkDropState::HIDDEN:
if (!IsVisible()) {
SetStateToHidden();
- break;
} else {
AnimateToOpacity(kHiddenOpacity, GetAnimationDuration(HIDDEN_FADE_OUT),
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET,
gfx::Tween::EASE_IN_OUT, animation_observer);
- const gfx::Transform transform = CalculateTransform(kMinRadius);
- AnimateToTransform(transform, GetAnimationDuration(HIDDEN_TRANSFORM),
Evan Stade 2016/03/31 03:41:27 I got rid of this because it looked weird on the s
bruthig 2016/03/31 19:39:03 This was a very intentional choice and I feel like
Evan Stade 2016/03/31 21:07:38 IIUC, you're saying that there's no visual distinc
bruthig 2016/03/31 22:46:19 Correct. You can try this out on the "Home" butto
Evan Stade 2016/04/01 19:03:13 ah ok. So if I change DownloadItemViewMd's sequenc
- ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET,
- gfx::Tween::EASE_IN_OUT, animation_observer);
}
break;
case InkDropState::ACTION_PENDING: {
@@ -204,9 +180,7 @@ 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);
@@ -231,9 +205,8 @@ void FloodFillInkDropAnimation::AnimateStateChange(
GetAnimationDuration(SLOW_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(SLOW_ACTION_PENDING),
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET,
gfx::Tween::EASE_IN_OUT, animation_observer);
break;
@@ -265,8 +238,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);
}
@@ -338,7 +310,7 @@ gfx::Transform FloodFillInkDropAnimation::CalculateTransform(
gfx::Transform FloodFillInkDropAnimation::GetActivatedTargetTransform() const {
return CalculateTransform(
- CalculateLargestDistanceToCorners(size_, center_point_));
+ gfx::Vector2dF(size_.width(), size_.height()).Length());
}
} // namespace views

Powered by Google App Engine
This is Rietveld 408576698