OLD | NEW |
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_ripple.h" | 5 #include "ui/views/animation/square_ink_drop_ripple.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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 base::TimeDelta duration, | 444 base::TimeDelta duration, |
445 ui::LayerAnimator::PreemptionStrategy preemption_strategy, | 445 ui::LayerAnimator::PreemptionStrategy preemption_strategy, |
446 gfx::Tween::Type tween, | 446 gfx::Tween::Type tween, |
447 ui::LayerAnimationObserver* observer) { | 447 ui::LayerAnimationObserver* observer) { |
448 ui::LayerAnimator* animator = root_layer_.GetAnimator(); | 448 ui::LayerAnimator* animator = root_layer_.GetAnimator(); |
449 ui::ScopedLayerAnimationSettings animation(animator); | 449 ui::ScopedLayerAnimationSettings animation(animator); |
450 animation.SetPreemptionStrategy(preemption_strategy); | 450 animation.SetPreemptionStrategy(preemption_strategy); |
451 animation.SetTweenType(tween); | 451 animation.SetTweenType(tween); |
452 gfx::Transform transform; | 452 gfx::Transform transform; |
453 transform.Translate(target_center_point_.x(), target_center_point_.y()); | 453 transform.Translate(target_center_point_.x(), target_center_point_.y()); |
454 ui::LayerAnimationElement* element = | 454 std::unique_ptr<ui::LayerAnimationElement> element = |
455 ui::LayerAnimationElement::CreateTransformElement(transform, duration); | 455 ui::LayerAnimationElement::CreateTransformElement(transform, duration); |
456 ui::LayerAnimationSequence* sequence = | 456 ui::LayerAnimationSequence* sequence = |
457 new ui::LayerAnimationSequence(element); | 457 new ui::LayerAnimationSequence(std::move(element)); |
458 | 458 |
459 if (observer) | 459 if (observer) |
460 sequence->AddObserver(observer); | 460 sequence->AddObserver(observer); |
461 | 461 |
462 animator->StartAnimation(sequence); | 462 animator->StartAnimation(sequence); |
463 } | 463 } |
464 | 464 |
465 void SquareInkDropRipple::AnimateToTransforms( | 465 void SquareInkDropRipple::AnimateToTransforms( |
466 const InkDropTransforms transforms, | 466 const InkDropTransforms transforms, |
467 base::TimeDelta duration, | 467 base::TimeDelta duration, |
468 ui::LayerAnimator::PreemptionStrategy preemption_strategy, | 468 ui::LayerAnimator::PreemptionStrategy preemption_strategy, |
469 gfx::Tween::Type tween, | 469 gfx::Tween::Type tween, |
470 ui::LayerAnimationObserver* animation_observer) { | 470 ui::LayerAnimationObserver* animation_observer) { |
471 for (int i = 0; i < PAINTED_SHAPE_COUNT; ++i) { | 471 for (int i = 0; i < PAINTED_SHAPE_COUNT; ++i) { |
472 ui::LayerAnimator* animator = painted_layers_[i]->GetAnimator(); | 472 ui::LayerAnimator* animator = painted_layers_[i]->GetAnimator(); |
473 ui::ScopedLayerAnimationSettings animation(animator); | 473 ui::ScopedLayerAnimationSettings animation(animator); |
474 animation.SetPreemptionStrategy(preemption_strategy); | 474 animation.SetPreemptionStrategy(preemption_strategy); |
475 animation.SetTweenType(tween); | 475 animation.SetTweenType(tween); |
476 ui::LayerAnimationElement* element = | 476 std::unique_ptr<ui::LayerAnimationElement> element = |
477 ui::LayerAnimationElement::CreateTransformElement(transforms[i], | 477 ui::LayerAnimationElement::CreateTransformElement(transforms[i], |
478 duration); | 478 duration); |
479 ui::LayerAnimationSequence* sequence = | 479 ui::LayerAnimationSequence* sequence = |
480 new ui::LayerAnimationSequence(element); | 480 new ui::LayerAnimationSequence(std::move(element)); |
481 | 481 |
482 if (animation_observer) | 482 if (animation_observer) |
483 sequence->AddObserver(animation_observer); | 483 sequence->AddObserver(animation_observer); |
484 | 484 |
485 animator->StartAnimation(sequence); | 485 animator->StartAnimation(sequence); |
486 } | 486 } |
487 } | 487 } |
488 | 488 |
489 void SquareInkDropRipple::SetTransforms(const InkDropTransforms transforms) { | 489 void SquareInkDropRipple::SetTransforms(const InkDropTransforms transforms) { |
490 for (int i = 0; i < PAINTED_SHAPE_COUNT; ++i) | 490 for (int i = 0; i < PAINTED_SHAPE_COUNT; ++i) |
491 painted_layers_[i]->SetTransform(transforms[i]); | 491 painted_layers_[i]->SetTransform(transforms[i]); |
492 } | 492 } |
493 | 493 |
494 void SquareInkDropRipple::SetOpacity(float opacity) { | 494 void SquareInkDropRipple::SetOpacity(float opacity) { |
495 root_layer_.SetOpacity(opacity); | 495 root_layer_.SetOpacity(opacity); |
496 } | 496 } |
497 | 497 |
498 void SquareInkDropRipple::AnimateToOpacity( | 498 void SquareInkDropRipple::AnimateToOpacity( |
499 float opacity, | 499 float opacity, |
500 base::TimeDelta duration, | 500 base::TimeDelta duration, |
501 ui::LayerAnimator::PreemptionStrategy preemption_strategy, | 501 ui::LayerAnimator::PreemptionStrategy preemption_strategy, |
502 gfx::Tween::Type tween, | 502 gfx::Tween::Type tween, |
503 ui::LayerAnimationObserver* animation_observer) { | 503 ui::LayerAnimationObserver* animation_observer) { |
504 ui::LayerAnimator* animator = root_layer_.GetAnimator(); | 504 ui::LayerAnimator* animator = root_layer_.GetAnimator(); |
505 ui::ScopedLayerAnimationSettings animation_settings(animator); | 505 ui::ScopedLayerAnimationSettings animation_settings(animator); |
506 animation_settings.SetPreemptionStrategy(preemption_strategy); | 506 animation_settings.SetPreemptionStrategy(preemption_strategy); |
507 animation_settings.SetTweenType(tween); | 507 animation_settings.SetTweenType(tween); |
508 ui::LayerAnimationElement* animation_element = | 508 std::unique_ptr<ui::LayerAnimationElement> animation_element = |
509 ui::LayerAnimationElement::CreateOpacityElement(opacity, duration); | 509 ui::LayerAnimationElement::CreateOpacityElement(opacity, duration); |
510 ui::LayerAnimationSequence* animation_sequence = | 510 ui::LayerAnimationSequence* animation_sequence = |
511 new ui::LayerAnimationSequence(animation_element); | 511 new ui::LayerAnimationSequence(std::move(animation_element)); |
512 | 512 |
513 if (animation_observer) | 513 if (animation_observer) |
514 animation_sequence->AddObserver(animation_observer); | 514 animation_sequence->AddObserver(animation_observer); |
515 | 515 |
516 animator->StartAnimation(animation_sequence); | 516 animator->StartAnimation(animation_sequence); |
517 } | 517 } |
518 | 518 |
519 void SquareInkDropRipple::CalculateCircleTransforms( | 519 void SquareInkDropRipple::CalculateCircleTransforms( |
520 const gfx::Size& size, | 520 const gfx::Size& size, |
521 InkDropTransforms* transforms_out) const { | 521 InkDropTransforms* transforms_out) const { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 layer->set_delegate(delegate); | 639 layer->set_delegate(delegate); |
640 layer->SetVisible(true); | 640 layer->SetVisible(true); |
641 layer->SetOpacity(1.0); | 641 layer->SetOpacity(1.0); |
642 layer->SetMasksToBounds(false); | 642 layer->SetMasksToBounds(false); |
643 layer->set_name("PAINTED_SHAPE_COUNT:" + ToLayerName(painted_shape)); | 643 layer->set_name("PAINTED_SHAPE_COUNT:" + ToLayerName(painted_shape)); |
644 | 644 |
645 painted_layers_[painted_shape].reset(layer); | 645 painted_layers_[painted_shape].reset(layer); |
646 } | 646 } |
647 | 647 |
648 } // namespace views | 648 } // namespace views |
OLD | NEW |