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

Side by Side Diff: ui/views/animation/square_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: fix another TODO Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/square_ink_drop_animation.h" 5 #include "ui/views/animation/square_ink_drop_animation.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/compositor/layer.h" 10 #include "ui/compositor/layer.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 // ACTION_PENDING sub animations. 48 // ACTION_PENDING sub animations.
49 49
50 // The ACTION_PENDING sub animation that fades in to the visible opacity. 50 // The ACTION_PENDING sub animation that fades in to the visible opacity.
51 ACTION_PENDING_FADE_IN, 51 ACTION_PENDING_FADE_IN,
52 52
53 // The ACTION_PENDING sub animation that transforms the shape to a 53 // The ACTION_PENDING sub animation that transforms the shape to a
54 // |large_size_| circle. 54 // |large_size_| circle.
55 ACTION_PENDING_TRANSFORM, 55 ACTION_PENDING_TRANSFORM,
56 56
57 // QUICK_ACTION sub animations. 57 // ACTION_TRIGGERED sub animations.
58 58
59 // The QUICK_ACTION sub animation that is fading out to a hidden opacity. 59 // The ACTION_TRIGGERED sub animation that is fading out to a hidden opacity.
60 QUICK_ACTION_FADE_OUT, 60 ACTION_TRIGGERED_FADE_OUT,
61 61
62 // The QUICK_ACTION sub animation that transforms the shape to a |large_size_| 62 // The ACTION_TRIGGERED sub animation that transforms the shape to a
63 // |large_size_|
63 // circle. 64 // circle.
64 QUICK_ACTION_TRANSFORM, 65 ACTION_TRIGGERED_TRANSFORM,
65 66
66 // SLOW_ACTION_PENDING sub animations. 67 // ALTERNATE_ACTION_PENDING sub animations.
67 68
68 // The SLOW_ACTION_PENDING animation has only one sub animation which animates 69 // The ALTERNATE_ACTION_PENDING animation has only one sub animation which
70 // animates
69 // to a |small_size_| rounded rectangle at visible opacity. 71 // to a |small_size_| rounded rectangle at visible opacity.
70 SLOW_ACTION_PENDING, 72 ALTERNATE_ACTION_PENDING,
71 73
72 // SLOW_ACTION sub animations. 74 // ALTERNATE_ACTION_TRIGGERED sub animations.
73 75
74 // The SLOW_ACTION sub animation that is fading out to a hidden opacity. 76 // The ALTERNATE_ACTION_TRIGGERED sub animation that is fading out to a hidden
75 SLOW_ACTION_FADE_OUT, 77 // opacity.
78 ALTERNATE_ACTION_TRIGGERED_FADE_OUT,
76 79
77 // The SLOW_ACTION sub animation that transforms the shape to a |large_size_| 80 // The ALTERNATE_ACTION_TRIGGERED sub animation that transforms the shape to a
81 // |large_size_|
78 // rounded rectangle. 82 // rounded rectangle.
79 SLOW_ACTION_TRANSFORM, 83 ALTERNATE_ACTION_TRIGGERED_TRANSFORM,
80 84
81 // ACTIVATED sub animations. 85 // ACTIVATED sub animations.
82 86
83 // The ACTIVATED sub animation that transforms the shape to a |large_size_| 87 // The ACTIVATED sub animation that transforms the shape to a |large_size_|
84 // circle. This is used when the ink drop is in a HIDDEN state prior to 88 // circle. This is used when the ink drop is in a HIDDEN state prior to
85 // animating to the ACTIVATED state. 89 // animating to the ACTIVATED state.
86 ACTIVATED_CIRCLE_TRANSFORM, 90 ACTIVATED_CIRCLE_TRANSFORM,
87 91
88 // The ACTIVATED sub animation that transforms the shape to a |small_size_| 92 // The ACTIVATED sub animation that transforms the shape to a |small_size_|
89 // rounded rectangle. 93 // rounded rectangle.
90 ACTIVATED_RECT_TRANSFORM, 94 ACTIVATED_RECT_TRANSFORM,
91 95
92 // DEACTIVATED sub animations. 96 // DEACTIVATED sub animations.
93 97
94 // The DEACTIVATED sub animation that is fading out to a hidden opacity. 98 // The DEACTIVATED sub animation that is fading out to a hidden opacity.
95 DEACTIVATED_FADE_OUT, 99 DEACTIVATED_FADE_OUT,
96 100
97 // The DEACTIVATED sub animation that transforms the shape to a |large_size_| 101 // The DEACTIVATED sub animation that transforms the shape to a |large_size_|
98 // rounded rectangle. 102 // rounded rectangle.
99 DEACTIVATED_TRANSFORM, 103 DEACTIVATED_TRANSFORM,
100 }; 104 };
101 105
102 // The scale factor used to burst the QUICK_ACTION bubble as it fades out. 106 // The scale factor used to burst the ACTION_TRIGGERED bubble as it fades out.
103 const float kQuickActionBurstScale = 1.3f; 107 const float kQuickActionBurstScale = 1.3f;
104 108
105 // Duration constants for InkDropStateSubAnimations. See the 109 // Duration constants for InkDropStateSubAnimations. See the
106 // InkDropStateSubAnimations enum documentation for more info. 110 // InkDropStateSubAnimations enum documentation for more info.
107 int kAnimationDurationInMs[] = { 111 int kAnimationDurationInMs[] = {
108 150, // HIDDEN_FADE_OUT 112 150, // HIDDEN_FADE_OUT
109 200, // HIDDEN_TRANSFORM 113 200, // HIDDEN_TRANSFORM
110 0, // ACTION_PENDING_FADE_IN 114 0, // ACTION_PENDING_FADE_IN
111 160, // ACTION_PENDING_TRANSFORM 115 160, // ACTION_PENDING_TRANSFORM
112 150, // QUICK_ACTION_FADE_OUT 116 150, // ACTION_TRIGGERED_FADE_OUT
113 160, // QUICK_ACTION_TRANSFORM 117 160, // ACTION_TRIGGERED_TRANSFORM
114 200, // SLOW_ACTION_PENDING 118 200, // ALTERNATE_ACTION_PENDING
115 150, // SLOW_ACTION_FADE_OUT 119 150, // ALTERNATE_ACTION_TRIGGERED_FADE_OUT
116 200, // SLOW_ACTION_TRANSFORM 120 200, // ALTERNATE_ACTION_TRIGGERED_TRANSFORM
117 200, // ACTIVATED_CIRCLE_TRANSFORM 121 200, // ACTIVATED_CIRCLE_TRANSFORM
118 160, // ACTIVATED_RECT_TRANSFORM 122 160, // ACTIVATED_RECT_TRANSFORM
119 150, // DEACTIVATED_FADE_OUT 123 150, // DEACTIVATED_FADE_OUT
120 200, // DEACTIVATED_TRANSFORM 124 200, // DEACTIVATED_TRANSFORM
121 }; 125 };
122 126
123 // Returns the InkDropState sub animation duration for the given |state|. 127 // Returns the InkDropState sub animation duration for the given |state|.
124 base::TimeDelta GetAnimationDuration(InkDropSubAnimations state) { 128 base::TimeDelta GetAnimationDuration(InkDropSubAnimations state) {
125 return base::TimeDelta::FromMilliseconds( 129 return base::TimeDelta::FromMilliseconds(
126 (views::InkDropAnimation::UseFastAnimations() 130 (views::InkDropAnimation::UseFastAnimations()
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 AnimateToOpacity(kVisibleOpacity, 271 AnimateToOpacity(kVisibleOpacity,
268 GetAnimationDuration(ACTION_PENDING_TRANSFORM), 272 GetAnimationDuration(ACTION_PENDING_TRANSFORM),
269 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, 273 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET,
270 gfx::Tween::EASE_IN, animation_observer); 274 gfx::Tween::EASE_IN, animation_observer);
271 CalculateCircleTransforms(large_size_, &transforms); 275 CalculateCircleTransforms(large_size_, &transforms);
272 AnimateToTransforms(transforms, 276 AnimateToTransforms(transforms,
273 GetAnimationDuration(ACTION_PENDING_TRANSFORM), 277 GetAnimationDuration(ACTION_PENDING_TRANSFORM),
274 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, 278 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET,
275 gfx::Tween::EASE_IN_OUT, animation_observer); 279 gfx::Tween::EASE_IN_OUT, animation_observer);
276 break; 280 break;
277 case InkDropState::QUICK_ACTION: { 281 case InkDropState::ACTION_TRIGGERED: {
278 DCHECK(old_ink_drop_state == InkDropState::HIDDEN || 282 DCHECK(old_ink_drop_state == InkDropState::HIDDEN ||
279 old_ink_drop_state == InkDropState::ACTION_PENDING); 283 old_ink_drop_state == InkDropState::ACTION_PENDING);
280 if (old_ink_drop_state == InkDropState::HIDDEN) { 284 if (old_ink_drop_state == InkDropState::HIDDEN) {
281 AnimateStateChange(old_ink_drop_state, InkDropState::ACTION_PENDING, 285 AnimateStateChange(old_ink_drop_state, InkDropState::ACTION_PENDING,
282 animation_observer); 286 animation_observer);
283 } 287 }
284 AnimateToOpacity(kHiddenOpacity, 288 AnimateToOpacity(kHiddenOpacity,
285 GetAnimationDuration(QUICK_ACTION_FADE_OUT), 289 GetAnimationDuration(ACTION_TRIGGERED_FADE_OUT),
286 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION, 290 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION,
287 gfx::Tween::EASE_IN_OUT, animation_observer); 291 gfx::Tween::EASE_IN_OUT, animation_observer);
288 gfx::Size s = ScaleToRoundedSize(large_size_, kQuickActionBurstScale); 292 gfx::Size s = ScaleToRoundedSize(large_size_, kQuickActionBurstScale);
289 CalculateCircleTransforms(s, &transforms); 293 CalculateCircleTransforms(s, &transforms);
290 AnimateToTransforms(transforms, 294 AnimateToTransforms(transforms,
291 GetAnimationDuration(QUICK_ACTION_TRANSFORM), 295 GetAnimationDuration(ACTION_TRIGGERED_TRANSFORM),
292 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION, 296 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION,
293 gfx::Tween::EASE_IN_OUT, animation_observer); 297 gfx::Tween::EASE_IN_OUT, animation_observer);
294 break; 298 break;
295 } 299 }
296 case InkDropState::SLOW_ACTION_PENDING: 300 case InkDropState::ALTERNATE_ACTION_PENDING:
297 DCHECK(old_ink_drop_state == InkDropState::ACTION_PENDING); 301 DCHECK(old_ink_drop_state == InkDropState::ACTION_PENDING);
298 AnimateToOpacity(kVisibleOpacity, 302 AnimateToOpacity(kVisibleOpacity,
299 GetAnimationDuration(SLOW_ACTION_PENDING), 303 GetAnimationDuration(ALTERNATE_ACTION_PENDING),
300 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, 304 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET,
301 gfx::Tween::EASE_IN, animation_observer); 305 gfx::Tween::EASE_IN, animation_observer);
302 CalculateRectTransforms(small_size_, small_corner_radius_, &transforms); 306 CalculateRectTransforms(small_size_, small_corner_radius_, &transforms);
303 AnimateToTransforms(transforms, GetAnimationDuration(SLOW_ACTION_PENDING), 307 AnimateToTransforms(transforms,
308 GetAnimationDuration(ALTERNATE_ACTION_PENDING),
304 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, 309 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET,
305 gfx::Tween::EASE_IN_OUT, animation_observer); 310 gfx::Tween::EASE_IN_OUT, animation_observer);
306 break; 311 break;
307 case InkDropState::SLOW_ACTION: { 312 case InkDropState::ALTERNATE_ACTION_TRIGGERED: {
308 DCHECK(old_ink_drop_state == InkDropState::SLOW_ACTION_PENDING); 313 DCHECK(old_ink_drop_state == InkDropState::ALTERNATE_ACTION_PENDING);
309 base::TimeDelta visible_duration = 314 base::TimeDelta visible_duration =
310 GetAnimationDuration(SLOW_ACTION_TRANSFORM) - 315 GetAnimationDuration(ALTERNATE_ACTION_TRIGGERED_TRANSFORM) -
311 GetAnimationDuration(SLOW_ACTION_FADE_OUT); 316 GetAnimationDuration(ALTERNATE_ACTION_TRIGGERED_FADE_OUT);
312 AnimateToOpacity(kVisibleOpacity, visible_duration, 317 AnimateToOpacity(kVisibleOpacity, visible_duration,
313 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, 318 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET,
314 gfx::Tween::EASE_IN_OUT, animation_observer); 319 gfx::Tween::EASE_IN_OUT, animation_observer);
315 AnimateToOpacity(kHiddenOpacity, 320 AnimateToOpacity(kHiddenOpacity, GetAnimationDuration(
316 GetAnimationDuration(SLOW_ACTION_FADE_OUT), 321 ALTERNATE_ACTION_TRIGGERED_FADE_OUT),
317 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION, 322 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION,
318 gfx::Tween::EASE_IN_OUT, animation_observer); 323 gfx::Tween::EASE_IN_OUT, animation_observer);
319 CalculateRectTransforms(large_size_, large_corner_radius_, &transforms); 324 CalculateRectTransforms(large_size_, large_corner_radius_, &transforms);
320 AnimateToTransforms(transforms, 325 AnimateToTransforms(transforms, GetAnimationDuration(
321 GetAnimationDuration(SLOW_ACTION_TRANSFORM), 326 ALTERNATE_ACTION_TRIGGERED_TRANSFORM),
322 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, 327 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET,
323 gfx::Tween::EASE_IN_OUT, animation_observer); 328 gfx::Tween::EASE_IN_OUT, animation_observer);
324 break; 329 break;
325 } 330 }
326 case InkDropState::ACTIVATED: { 331 case InkDropState::ACTIVATED: {
327 // Animate the opacity so that it cancels any opacity animations already 332 // Animate the opacity so that it cancels any opacity animations already
328 // in progress. 333 // in progress.
329 AnimateToOpacity(kVisibleOpacity, base::TimeDelta(), 334 AnimateToOpacity(kVisibleOpacity, base::TimeDelta(),
330 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, 335 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET,
331 gfx::Tween::EASE_IN_OUT, animation_observer); 336 gfx::Tween::EASE_IN_OUT, animation_observer);
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 layer->set_delegate(delegate); 546 layer->set_delegate(delegate);
542 layer->SetVisible(true); 547 layer->SetVisible(true);
543 layer->SetOpacity(1.0); 548 layer->SetOpacity(1.0);
544 layer->SetMasksToBounds(false); 549 layer->SetMasksToBounds(false);
545 layer->set_name("PAINTED_SHAPE_COUNT:" + ToLayerName(painted_shape)); 550 layer->set_name("PAINTED_SHAPE_COUNT:" + ToLayerName(painted_shape));
546 551
547 painted_layers_[painted_shape].reset(layer); 552 painted_layers_[painted_shape].reset(layer);
548 } 553 }
549 554
550 } // namespace views 555 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/square_ink_drop_animation.h ('k') | ui/views/controls/button/custom_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698