| 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 old_is_transition_duration_locked_( |
| 85 animator->is_transition_duration_locked_), |
| 86 old_transition_duration_(animator->GetTransitionDuration()), |
| 85 old_tween_type_(animator->tween_type()), | 87 old_tween_type_(animator->tween_type()), |
| 86 old_preemption_strategy_(animator->preemption_strategy()), | 88 old_preemption_strategy_(animator->preemption_strategy()), |
| 87 inverse_observer_(new InvertingObserver()) { | 89 inverse_observer_(new InvertingObserver()) { |
| 88 SetTransitionDuration( | 90 SetTransitionDuration( |
| 89 base::TimeDelta::FromMilliseconds(kDefaultTransitionDurationMs)); | 91 base::TimeDelta::FromMilliseconds(kDefaultTransitionDurationMs)); |
| 90 } | 92 } |
| 91 | 93 |
| 92 ScopedLayerAnimationSettings::~ScopedLayerAnimationSettings() { | 94 ScopedLayerAnimationSettings::~ScopedLayerAnimationSettings() { |
| 93 animator_->transition_duration_ = old_transition_duration_; | 95 animator_->is_transition_duration_locked_ = |
| 96 old_is_transition_duration_locked_; |
| 97 animator_->SetTransitionDuration(old_transition_duration_); |
| 94 animator_->set_tween_type(old_tween_type_); | 98 animator_->set_tween_type(old_tween_type_); |
| 95 animator_->set_preemption_strategy(old_preemption_strategy_); | 99 animator_->set_preemption_strategy(old_preemption_strategy_); |
| 96 | 100 |
| 97 for (std::set<ImplicitAnimationObserver*>::const_iterator i = | 101 for (std::set<ImplicitAnimationObserver*>::const_iterator i = |
| 98 observers_.begin(); i != observers_.end(); ++i) { | 102 observers_.begin(); i != observers_.end(); ++i) { |
| 99 animator_->observers_.RemoveObserver(*i); | 103 animator_->observers_.RemoveObserver(*i); |
| 100 (*i)->SetActive(true); | 104 (*i)->SetActive(true); |
| 101 } | 105 } |
| 102 | 106 |
| 103 if (inverse_observer_->layer()) { | 107 if (inverse_observer_->layer()) { |
| 104 animator_->observers_.RemoveObserver(inverse_observer_.get()); | 108 animator_->observers_.RemoveObserver(inverse_observer_.get()); |
| 105 } | 109 } |
| 106 } | 110 } |
| 107 | 111 |
| 108 void ScopedLayerAnimationSettings::AddObserver( | 112 void ScopedLayerAnimationSettings::AddObserver( |
| 109 ImplicitAnimationObserver* observer) { | 113 ImplicitAnimationObserver* observer) { |
| 110 observers_.insert(observer); | 114 observers_.insert(observer); |
| 111 animator_->AddObserver(observer); | 115 animator_->AddObserver(observer); |
| 112 } | 116 } |
| 113 | 117 |
| 114 void ScopedLayerAnimationSettings::SetTransitionDuration( | 118 void ScopedLayerAnimationSettings::SetTransitionDuration( |
| 115 base::TimeDelta duration) { | 119 base::TimeDelta duration) { |
| 116 animator_->transition_duration_ = duration; | 120 animator_->SetTransitionDuration(duration); |
| 121 } |
| 122 |
| 123 void ScopedLayerAnimationSettings::LockTransitionDuration() { |
| 124 animator_->is_transition_duration_locked_ = true; |
| 117 } | 125 } |
| 118 | 126 |
| 119 base::TimeDelta ScopedLayerAnimationSettings::GetTransitionDuration() const { | 127 base::TimeDelta ScopedLayerAnimationSettings::GetTransitionDuration() const { |
| 120 return animator_->GetTransitionDuration(); | 128 return animator_->GetTransitionDuration(); |
| 121 } | 129 } |
| 122 | 130 |
| 123 void ScopedLayerAnimationSettings::SetTweenType(gfx::Tween::Type tween_type) { | 131 void ScopedLayerAnimationSettings::SetTweenType(gfx::Tween::Type tween_type) { |
| 124 animator_->set_tween_type(tween_type); | 132 animator_->set_tween_type(tween_type); |
| 125 } | 133 } |
| 126 | 134 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 146 } | 154 } |
| 147 inverse_observer_->SetLayer(base); | 155 inverse_observer_->SetLayer(base); |
| 148 } | 156 } |
| 149 | 157 |
| 150 void ScopedLayerAnimationSettings::AddInverselyAnimatedLayer( | 158 void ScopedLayerAnimationSettings::AddInverselyAnimatedLayer( |
| 151 Layer* inverse_layer) { | 159 Layer* inverse_layer) { |
| 152 inverse_observer_->AddInverselyAnimatedLayer(inverse_layer); | 160 inverse_observer_->AddInverselyAnimatedLayer(inverse_layer); |
| 153 } | 161 } |
| 154 | 162 |
| 155 } // namespace ui | 163 } // namespace ui |
| OLD | NEW |