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