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

Side by Side Diff: ui/views/animation/flood_fill_ink_drop_animation.cc

Issue 1796623002: Added ink drop hover/ripple to menu hosting bookmark buttons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: 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 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/flood_fill_ink_drop_animation.h" 5 #include "ui/views/animation/flood_fill_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 "third_party/skia/include/core/SkColor.h" 10 #include "third_party/skia/include/core/SkColor.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 SetStateToHidden(); 152 SetStateToHidden();
153 } 153 }
154 154
155 FloodFillInkDropAnimation::~FloodFillInkDropAnimation() { 155 FloodFillInkDropAnimation::~FloodFillInkDropAnimation() {
156 // Explicitly aborting all the animations ensures all callbacks are invoked 156 // Explicitly aborting all the animations ensures all callbacks are invoked
157 // while this instance still exists. 157 // while this instance still exists.
158 AbortAllAnimations(); 158 AbortAllAnimations();
159 } 159 }
160 160
161 void FloodFillInkDropAnimation::SnapToActivated() {
162 InkDropAnimation::SnapToActivated();
163 SetOpacity(kVisibleOpacity);
164 painted_layer_.SetTransform(GetActivatedTargetTransform());
165 }
166
161 ui::Layer* FloodFillInkDropAnimation::GetRootLayer() { 167 ui::Layer* FloodFillInkDropAnimation::GetRootLayer() {
162 return &root_layer_; 168 return &root_layer_;
163 } 169 }
164 170
165 bool FloodFillInkDropAnimation::IsVisible() const { 171 bool FloodFillInkDropAnimation::IsVisible() const {
166 return root_layer_.visible(); 172 return root_layer_.visible();
167 } 173 }
168 174
169 void FloodFillInkDropAnimation::AnimateStateChange( 175 void FloodFillInkDropAnimation::AnimateStateChange(
170 InkDropState old_ink_drop_state, 176 InkDropState old_ink_drop_state,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 CalculateLargestDistanceToCorners(size_, center_point_)); 208 CalculateLargestDistanceToCorners(size_, center_point_));
203 AnimateToTransform(transform, 209 AnimateToTransform(transform,
204 GetAnimationDuration(ACTION_PENDING_TRANSFORM), 210 GetAnimationDuration(ACTION_PENDING_TRANSFORM),
205 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, 211 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET,
206 gfx::Tween::FAST_OUT_SLOW_IN, animation_observer); 212 gfx::Tween::FAST_OUT_SLOW_IN, animation_observer);
207 break; 213 break;
208 } 214 }
209 case InkDropState::QUICK_ACTION: { 215 case InkDropState::QUICK_ACTION: {
210 DCHECK(old_ink_drop_state == InkDropState::HIDDEN || 216 DCHECK(old_ink_drop_state == InkDropState::HIDDEN ||
211 old_ink_drop_state == InkDropState::ACTION_PENDING); 217 old_ink_drop_state == InkDropState::ACTION_PENDING);
212 218 if (old_ink_drop_state == InkDropState::HIDDEN) {
219 AnimateStateChange(old_ink_drop_state, InkDropState::ACTION_PENDING,
220 animation_observer);
221 }
213 AnimateToOpacity(kHiddenOpacity, 222 AnimateToOpacity(kHiddenOpacity,
214 GetAnimationDuration(QUICK_ACTION_FADE_OUT), 223 GetAnimationDuration(QUICK_ACTION_FADE_OUT),
215 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION, 224 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION,
216 gfx::Tween::EASE_IN_OUT, animation_observer); 225 gfx::Tween::EASE_IN_OUT, animation_observer);
217 break; 226 break;
218 } 227 }
219 case InkDropState::SLOW_ACTION_PENDING: { 228 case InkDropState::SLOW_ACTION_PENDING: {
220 DCHECK(old_ink_drop_state == InkDropState::ACTION_PENDING); 229 DCHECK(old_ink_drop_state == InkDropState::ACTION_PENDING);
221 AnimateToOpacity(kVisibleOpacity, 230 AnimateToOpacity(kVisibleOpacity,
222 GetAnimationDuration(SLOW_ACTION_PENDING), 231 GetAnimationDuration(SLOW_ACTION_PENDING),
(...skipping 10 matching lines...) Expand all
233 DCHECK(old_ink_drop_state == InkDropState::SLOW_ACTION_PENDING); 242 DCHECK(old_ink_drop_state == InkDropState::SLOW_ACTION_PENDING);
234 AnimateToOpacity(kHiddenOpacity, 243 AnimateToOpacity(kHiddenOpacity,
235 GetAnimationDuration(SLOW_ACTION_FADE_OUT), 244 GetAnimationDuration(SLOW_ACTION_FADE_OUT),
236 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION, 245 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION,
237 gfx::Tween::EASE_IN_OUT, animation_observer); 246 gfx::Tween::EASE_IN_OUT, animation_observer);
238 break; 247 break;
239 case InkDropState::ACTIVATED: { 248 case InkDropState::ACTIVATED: {
240 AnimateToOpacity(kVisibleOpacity, GetAnimationDuration(ACTIVATED_FADE_IN), 249 AnimateToOpacity(kVisibleOpacity, GetAnimationDuration(ACTIVATED_FADE_IN),
241 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, 250 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET,
242 gfx::Tween::EASE_IN, animation_observer); 251 gfx::Tween::EASE_IN, animation_observer);
243 const gfx::Transform transform = CalculateTransform( 252 AnimateToTransform(GetActivatedTargetTransform(),
244 CalculateLargestDistanceToCorners(size_, center_point_)); 253 GetAnimationDuration(ACTIVATED_TRANSFORM),
245 AnimateToTransform(transform, GetAnimationDuration(ACTIVATED_TRANSFORM),
246 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, 254 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET,
247 gfx::Tween::EASE_IN_OUT, animation_observer); 255 gfx::Tween::EASE_IN_OUT, animation_observer);
248 break; 256 break;
249 } 257 }
250 case InkDropState::DEACTIVATED: 258 case InkDropState::DEACTIVATED:
251 AnimateToOpacity(kHiddenOpacity, 259 AnimateToOpacity(kHiddenOpacity,
252 GetAnimationDuration(DEACTIVATED_FADE_OUT), 260 GetAnimationDuration(DEACTIVATED_FADE_OUT),
253 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION, 261 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION,
254 gfx::Tween::EASE_IN_OUT, animation_observer); 262 gfx::Tween::EASE_IN_OUT, animation_observer);
255 break; 263 break;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 ToRoundedPoint(circle_layer_delegate_.GetCenterPoint()); 329 ToRoundedPoint(circle_layer_delegate_.GetCenterPoint());
322 330
323 gfx::Transform transform = gfx::Transform(); 331 gfx::Transform transform = gfx::Transform();
324 transform.Translate(center_point_.x(), center_point_.y()); 332 transform.Translate(center_point_.x(), center_point_.y());
325 transform.Scale(target_scale, target_scale); 333 transform.Scale(target_scale, target_scale);
326 transform.Translate(-drawn_center_point.x(), -drawn_center_point.y()); 334 transform.Translate(-drawn_center_point.x(), -drawn_center_point.y());
327 335
328 return transform; 336 return transform;
329 } 337 }
330 338
339 gfx::Transform FloodFillInkDropAnimation::GetActivatedTargetTransform() const {
340 return CalculateTransform(
341 CalculateLargestDistanceToCorners(size_, center_point_));
342 }
343
331 } // namespace views 344 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/flood_fill_ink_drop_animation.h ('k') | ui/views/animation/ink_drop_animation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698