OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef UI_COMPOSITOR_SCOPED_LAYER_ANIMATION_SETTINGS_H_ | 5 #ifndef UI_COMPOSITOR_SCOPED_LAYER_ANIMATION_SETTINGS_H_ |
6 #define UI_COMPOSITOR_SCOPED_LAYER_ANIMATION_SETTINGS_H_ | 6 #define UI_COMPOSITOR_SCOPED_LAYER_ANIMATION_SETTINGS_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 | 12 |
13 #include "ui/base/animation/tween.h" | |
14 #include "ui/compositor/compositor_export.h" | 13 #include "ui/compositor/compositor_export.h" |
15 #include "ui/compositor/layer_animator.h" | 14 #include "ui/compositor/layer_animator.h" |
| 15 #include "ui/gfx/animation/tween.h" |
16 | 16 |
17 namespace ui { | 17 namespace ui { |
18 | 18 |
19 class ImplicitAnimationObserver; | 19 class ImplicitAnimationObserver; |
20 class LayerAnimationObserver; | 20 class LayerAnimationObserver; |
21 class InvertingObserver; | 21 class InvertingObserver; |
22 | 22 |
23 // Scoped settings allow you to temporarily change the animator's settings and | 23 // Scoped settings allow you to temporarily change the animator's settings and |
24 // these changes are reverted when the object is destroyed. NOTE: when the | 24 // these changes are reverted when the object is destroyed. NOTE: when the |
25 // settings object is created, it applies the default transition duration | 25 // settings object is created, it applies the default transition duration |
26 // (200ms). | 26 // (200ms). |
27 class COMPOSITOR_EXPORT ScopedLayerAnimationSettings { | 27 class COMPOSITOR_EXPORT ScopedLayerAnimationSettings { |
28 public: | 28 public: |
29 explicit ScopedLayerAnimationSettings(LayerAnimator* animator); | 29 explicit ScopedLayerAnimationSettings(LayerAnimator* animator); |
30 virtual ~ScopedLayerAnimationSettings(); | 30 virtual ~ScopedLayerAnimationSettings(); |
31 | 31 |
32 void AddObserver(ImplicitAnimationObserver* observer); | 32 void AddObserver(ImplicitAnimationObserver* observer); |
33 | 33 |
34 void SetTransitionDuration(base::TimeDelta duration); | 34 void SetTransitionDuration(base::TimeDelta duration); |
35 base::TimeDelta GetTransitionDuration() const; | 35 base::TimeDelta GetTransitionDuration() const; |
36 | 36 |
37 void SetTweenType(Tween::Type tween_type); | 37 void SetTweenType(gfx::Tween::Type tween_type); |
38 Tween::Type GetTweenType() const; | 38 gfx::Tween::Type GetTweenType() const; |
39 | 39 |
40 void SetPreemptionStrategy(LayerAnimator::PreemptionStrategy strategy); | 40 void SetPreemptionStrategy(LayerAnimator::PreemptionStrategy strategy); |
41 LayerAnimator::PreemptionStrategy GetPreemptionStrategy() const; | 41 LayerAnimator::PreemptionStrategy GetPreemptionStrategy() const; |
42 | 42 |
43 // Sets the base layer whose animation will be countered. | 43 // Sets the base layer whose animation will be countered. |
44 void SetInverselyAnimatedBaseLayer(Layer* base); | 44 void SetInverselyAnimatedBaseLayer(Layer* base); |
45 | 45 |
46 // Adds the layer to be counter-animated when a transform animation is | 46 // Adds the layer to be counter-animated when a transform animation is |
47 // scheduled on the animator_. Must call SetInverselyAnimatedBaseLayer with | 47 // scheduled on the animator_. Must call SetInverselyAnimatedBaseLayer with |
48 // the layer associated with animator_ before animating. | 48 // the layer associated with animator_ before animating. |
49 void AddInverselyAnimatedLayer(Layer* inverse_layer); | 49 void AddInverselyAnimatedLayer(Layer* inverse_layer); |
50 | 50 |
51 private: | 51 private: |
52 LayerAnimator* animator_; | 52 LayerAnimator* animator_; |
53 base::TimeDelta old_transition_duration_; | 53 base::TimeDelta old_transition_duration_; |
54 Tween::Type old_tween_type_; | 54 gfx::Tween::Type old_tween_type_; |
55 LayerAnimator::PreemptionStrategy old_preemption_strategy_; | 55 LayerAnimator::PreemptionStrategy old_preemption_strategy_; |
56 std::set<ImplicitAnimationObserver*> observers_; | 56 std::set<ImplicitAnimationObserver*> observers_; |
57 scoped_ptr<InvertingObserver> inverse_observer_; | 57 scoped_ptr<InvertingObserver> inverse_observer_; |
58 | 58 |
59 DISALLOW_COPY_AND_ASSIGN(ScopedLayerAnimationSettings); | 59 DISALLOW_COPY_AND_ASSIGN(ScopedLayerAnimationSettings); |
60 }; | 60 }; |
61 | 61 |
62 } // namespace ui | 62 } // namespace ui |
63 | 63 |
64 #endif // UI_COMPOSITOR_SCOPED_LAYER_ANIMATION_SETTINGS_H_ | 64 #endif // UI_COMPOSITOR_SCOPED_LAYER_ANIMATION_SETTINGS_H_ |
OLD | NEW |