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 #include "ui/compositor/scoped_layer_animation_settings.h" | 5 #include "ui/compositor/scoped_layer_animation_settings.h" |
6 | 6 |
7 #include "ui/compositor/layer.h" | 7 #include "ui/compositor/layer.h" |
8 #include "ui/compositor/layer_animation_observer.h" | 8 #include "ui/compositor/layer_animation_observer.h" |
9 #include "ui/compositor/layer_animation_sequence.h" | 9 #include "ui/compositor/layer_animation_sequence.h" |
10 #include "ui/compositor/layer_animator.h" | 10 #include "ui/compositor/layer_animator.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 Layer* base_layer_; | 74 Layer* base_layer_; |
75 // child layers | 75 // child layers |
76 std::vector<Layer*> inverse_layers_; | 76 std::vector<Layer*> inverse_layers_; |
77 }; | 77 }; |
78 | 78 |
79 | 79 |
80 // ScoperLayerAnimationSettings ------------------------------------------------ | 80 // ScoperLayerAnimationSettings ------------------------------------------------ |
81 ScopedLayerAnimationSettings::ScopedLayerAnimationSettings( | 81 ScopedLayerAnimationSettings::ScopedLayerAnimationSettings( |
82 LayerAnimator* animator) | 82 LayerAnimator* animator) |
83 : animator_(animator), | 83 : animator_(animator), |
84 old_transition_duration_(animator->transition_duration_), | 84 is_transition_duration_locked_(animator->is_transition_duration_locked_), |
85 old_is_transition_duration_locked_( | |
86 animator->is_transition_duration_locked_), | |
87 old_transition_duration_(animator->GetTransitionDuration()), | |
85 old_tween_type_(animator->tween_type()), | 88 old_tween_type_(animator->tween_type()), |
86 old_preemption_strategy_(animator->preemption_strategy()), | 89 old_preemption_strategy_(animator->preemption_strategy()), |
87 inverse_observer_(new InvertingObserver()) { | 90 inverse_observer_(new InvertingObserver()) { |
88 SetTransitionDuration( | 91 SetTransitionDuration( |
89 base::TimeDelta::FromMilliseconds(kDefaultTransitionDurationMs)); | 92 base::TimeDelta::FromMilliseconds(kDefaultTransitionDurationMs)); |
90 } | 93 } |
91 | 94 |
92 ScopedLayerAnimationSettings::~ScopedLayerAnimationSettings() { | 95 ScopedLayerAnimationSettings::~ScopedLayerAnimationSettings() { |
93 animator_->transition_duration_ = old_transition_duration_; | 96 animator_->is_transition_duration_locked_ = |
97 old_is_transition_duration_locked_; | |
98 animator_->SetTransitionDuration(old_transition_duration_); | |
94 animator_->set_tween_type(old_tween_type_); | 99 animator_->set_tween_type(old_tween_type_); |
95 animator_->set_preemption_strategy(old_preemption_strategy_); | 100 animator_->set_preemption_strategy(old_preemption_strategy_); |
96 | 101 |
97 for (std::set<ImplicitAnimationObserver*>::const_iterator i = | 102 for (std::set<ImplicitAnimationObserver*>::const_iterator i = |
98 observers_.begin(); i != observers_.end(); ++i) { | 103 observers_.begin(); i != observers_.end(); ++i) { |
99 animator_->observers_.RemoveObserver(*i); | 104 animator_->observers_.RemoveObserver(*i); |
100 (*i)->SetActive(true); | 105 (*i)->SetActive(true); |
101 } | 106 } |
102 | 107 |
103 if (inverse_observer_->layer()) { | 108 if (inverse_observer_->layer()) { |
104 animator_->observers_.RemoveObserver(inverse_observer_.get()); | 109 animator_->observers_.RemoveObserver(inverse_observer_.get()); |
105 } | 110 } |
106 } | 111 } |
107 | 112 |
108 void ScopedLayerAnimationSettings::AddObserver( | 113 void ScopedLayerAnimationSettings::AddObserver( |
109 ImplicitAnimationObserver* observer) { | 114 ImplicitAnimationObserver* observer) { |
110 observers_.insert(observer); | 115 observers_.insert(observer); |
111 animator_->AddObserver(observer); | 116 animator_->AddObserver(observer); |
112 } | 117 } |
113 | 118 |
114 void ScopedLayerAnimationSettings::SetTransitionDuration( | 119 void ScopedLayerAnimationSettings::SetTransitionDuration( |
115 base::TimeDelta duration) { | 120 base::TimeDelta duration) { |
116 animator_->transition_duration_ = duration; | 121 animator_->SetTransitionDuration(duration); |
122 } | |
123 | |
124 void ScopedLayerAnimationSettings::SetTransitionDurationLocked(bool is_locked) { | |
125 is_transition_duration_locked_ = is_locked; | |
Ian Vollick
2013/11/29 04:33:31
What is SLAS::is_transition_duration_locked_ used
varkha
2013/11/29 06:05:54
Done.
| |
126 animator_->is_transition_duration_locked_ = is_locked; | |
117 } | 127 } |
118 | 128 |
119 base::TimeDelta ScopedLayerAnimationSettings::GetTransitionDuration() const { | 129 base::TimeDelta ScopedLayerAnimationSettings::GetTransitionDuration() const { |
120 return animator_->transition_duration_; | 130 return animator_->GetTransitionDuration(); |
121 } | 131 } |
122 | 132 |
123 void ScopedLayerAnimationSettings::SetTweenType(gfx::Tween::Type tween_type) { | 133 void ScopedLayerAnimationSettings::SetTweenType(gfx::Tween::Type tween_type) { |
124 animator_->set_tween_type(tween_type); | 134 animator_->set_tween_type(tween_type); |
125 } | 135 } |
126 | 136 |
127 gfx::Tween::Type ScopedLayerAnimationSettings::GetTweenType() const { | 137 gfx::Tween::Type ScopedLayerAnimationSettings::GetTweenType() const { |
128 return animator_->tween_type(); | 138 return animator_->tween_type(); |
129 } | 139 } |
130 | 140 |
(...skipping 15 matching lines...) Expand all Loading... | |
146 } | 156 } |
147 inverse_observer_->SetLayer(base); | 157 inverse_observer_->SetLayer(base); |
148 } | 158 } |
149 | 159 |
150 void ScopedLayerAnimationSettings::AddInverselyAnimatedLayer( | 160 void ScopedLayerAnimationSettings::AddInverselyAnimatedLayer( |
151 Layer* inverse_layer) { | 161 Layer* inverse_layer) { |
152 inverse_observer_->AddInverselyAnimatedLayer(inverse_layer); | 162 inverse_observer_->AddInverselyAnimatedLayer(inverse_layer); |
153 } | 163 } |
154 | 164 |
155 } // namespace ui | 165 } // namespace ui |
OLD | NEW |