Hide X11 dependencies when use_x11=0.
[chromium-blink-merge.git] / ui / compositor / scoped_layer_animation_settings.h
blobe8a1b468ba6f94df2fb1baf1dbfd93704756c40b
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
3 // found in the LICENSE file.
5 #ifndef UI_COMPOSITOR_SCOPED_LAYER_ANIMATION_SETTINGS_H_
6 #define UI_COMPOSITOR_SCOPED_LAYER_ANIMATION_SETTINGS_H_
8 #include <set>
10 #include "base/memory/scoped_vector.h"
11 #include "base/time/time.h"
13 #include "ui/compositor/compositor_export.h"
14 #include "ui/compositor/layer_animator.h"
15 #include "ui/gfx/animation/tween.h"
17 namespace ui {
19 class ImplicitAnimationObserver;
20 class LayerAnimationObserver;
21 class InvertingObserver;
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
25 // settings object is created, it applies the default transition duration
26 // (200ms).
27 class COMPOSITOR_EXPORT ScopedLayerAnimationSettings {
28 public:
29 explicit ScopedLayerAnimationSettings(LayerAnimator* animator);
30 virtual ~ScopedLayerAnimationSettings();
32 void AddObserver(ImplicitAnimationObserver* observer);
34 void SetTransitionDuration(base::TimeDelta duration);
35 base::TimeDelta GetTransitionDuration() const;
37 // Locks transition duration in |animator_|. When transition duration
38 // is locked any subsequent changes to it are ignored until the
39 // ScopedLayerAnimationSettings object that has locked the duration goes out
40 // of scope.
41 void LockTransitionDuration();
43 void SetTweenType(gfx::Tween::Type tween_type);
44 gfx::Tween::Type GetTweenType() const;
46 void SetPreemptionStrategy(LayerAnimator::PreemptionStrategy strategy);
47 LayerAnimator::PreemptionStrategy GetPreemptionStrategy() const;
49 // Sets the base layer whose animation will be countered.
50 void SetInverselyAnimatedBaseLayer(Layer* base);
52 // Adds the layer to be counter-animated when a transform animation is
53 // scheduled on the animator_. Must call SetInverselyAnimatedBaseLayer with
54 // the layer associated with animator_ before animating.
55 void AddInverselyAnimatedLayer(Layer* inverse_layer);
57 private:
58 LayerAnimator* animator_;
59 bool old_is_transition_duration_locked_;
60 base::TimeDelta old_transition_duration_;
61 gfx::Tween::Type old_tween_type_;
62 LayerAnimator::PreemptionStrategy old_preemption_strategy_;
63 std::set<ImplicitAnimationObserver*> observers_;
64 scoped_ptr<InvertingObserver> inverse_observer_;
66 DISALLOW_COPY_AND_ASSIGN(ScopedLayerAnimationSettings);
69 } // namespace ui
71 #endif // UI_COMPOSITOR_SCOPED_LAYER_ANIMATION_SETTINGS_H_