OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ink_drop_hover.h" | 5 #include "ui/views/animation/ink_drop_hover.h" |
6 | 6 |
7 #include "third_party/skia/include/core/SkColor.h" | 7 #include "third_party/skia/include/core/SkColor.h" |
8 #include "ui/compositor/callback_layer_animation_observer.h" | 8 #include "ui/compositor/callback_layer_animation_observer.h" |
9 #include "ui/compositor/layer.h" | 9 #include "ui/compositor/layer.h" |
10 #include "ui/compositor/layer_animation_sequence.h" | 10 #include "ui/compositor/layer_animation_sequence.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 const base::TimeDelta& duration) { | 60 const base::TimeDelta& duration) { |
61 // The |animation_observer| will be destroyed when the | 61 // The |animation_observer| will be destroyed when the |
62 // AnimationStartedCallback() returns true. | 62 // AnimationStartedCallback() returns true. |
63 ui::CallbackLayerAnimationObserver* animation_observer = | 63 ui::CallbackLayerAnimationObserver* animation_observer = |
64 new ui::CallbackLayerAnimationObserver( | 64 new ui::CallbackLayerAnimationObserver( |
65 base::Bind(&InkDropHover::AnimationEndedCallback, | 65 base::Bind(&InkDropHover::AnimationEndedCallback, |
66 base::Unretained(this), animation_type)); | 66 base::Unretained(this), animation_type)); |
67 | 67 |
68 ui::LayerAnimator* animator = layer_->GetAnimator(); | 68 ui::LayerAnimator* animator = layer_->GetAnimator(); |
69 ui::ScopedLayerAnimationSettings animation(animator); | 69 ui::ScopedLayerAnimationSettings animation(animator); |
| 70 animation.SetTweenType(gfx::Tween::EASE_IN_OUT); |
70 animation.SetPreemptionStrategy( | 71 animation.SetPreemptionStrategy( |
71 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 72 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
72 ui::LayerAnimationElement* animation_element = | 73 ui::LayerAnimationElement* animation_element = |
73 ui::LayerAnimationElement::CreateOpacityElement( | 74 ui::LayerAnimationElement::CreateOpacityElement( |
74 animation_type == FADE_IN ? kHoverVisibleOpacity : kHiddenOpacity, | 75 animation_type == FADE_IN ? kHoverVisibleOpacity : kHiddenOpacity, |
75 duration); | 76 duration); |
76 ui::LayerAnimationSequence* animation_sequence = | 77 ui::LayerAnimationSequence* animation_sequence = |
77 new ui::LayerAnimationSequence(animation_element); | 78 new ui::LayerAnimationSequence(animation_element); |
78 animation_sequence->AddObserver(animation_observer); | 79 animation_sequence->AddObserver(animation_observer); |
79 | 80 |
(...skipping 13 matching lines...) Expand all Loading... |
93 HoverAnimationType animation_type, | 94 HoverAnimationType animation_type, |
94 const ui::CallbackLayerAnimationObserver& observer) { | 95 const ui::CallbackLayerAnimationObserver& observer) { |
95 // AnimationEndedCallback() may be invoked when this is being destroyed and | 96 // AnimationEndedCallback() may be invoked when this is being destroyed and |
96 // |layer_| may be null. | 97 // |layer_| may be null. |
97 if (animation_type == FADE_OUT && layer_) | 98 if (animation_type == FADE_OUT && layer_) |
98 layer_->SetVisible(false); | 99 layer_->SetVisible(false); |
99 return true; | 100 return true; |
100 } | 101 } |
101 | 102 |
102 } // namespace views | 103 } // namespace views |
OLD | NEW |