| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "views/animation/bounds_animator.h" | 5 #include "views/animation/bounds_animator.h" |
| 6 | 6 |
| 7 #include "app/slide_animation.h" | 7 #include "app/slide_animation.h" |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "views/view.h" | 9 #include "views/view.h" |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 animation->Show(); | 80 animation->Show(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 const SlideAnimation* BoundsAnimator::GetAnimationForView(View* view) { | 83 const SlideAnimation* BoundsAnimator::GetAnimationForView(View* view) { |
| 84 return data_.find(view) == data_.end() ? NULL : data_[view].animation; | 84 return data_.find(view) == data_.end() ? NULL : data_[view].animation; |
| 85 } | 85 } |
| 86 | 86 |
| 87 void BoundsAnimator::SetAnimationDelegate(View* view, | 87 void BoundsAnimator::SetAnimationDelegate(View* view, |
| 88 AnimationDelegate* delegate, | 88 AnimationDelegate* delegate, |
| 89 bool delete_when_done) { | 89 bool delete_when_done) { |
| 90 #if defined(OS_LINUX) | |
| 91 if (!IsAnimating(view)) | |
| 92 LOG(ERROR) << "SetAnimationDelegate: not animating view"; | |
| 93 if (data_[view].delegate) | |
| 94 LOG(ERROR) << "SetAnimationDelegate: delegate already set: leaking"; | |
| 95 #endif | |
| 96 | |
| 97 DCHECK(IsAnimating(view)); | 90 DCHECK(IsAnimating(view)); |
| 98 data_[view].delegate = delegate; | 91 data_[view].delegate = delegate; |
| 99 data_[view].delete_delegate_when_done = delete_when_done; | 92 data_[view].delete_delegate_when_done = delete_when_done; |
| 100 } | 93 } |
| 101 | 94 |
| 102 void BoundsAnimator::StopAnimatingView(View* view) { | 95 void BoundsAnimator::StopAnimatingView(View* view) { |
| 103 if (data_.find(view) == data_.end()) | 96 if (data_.find(view) == data_.end()) |
| 104 return; | 97 return; |
| 105 | 98 |
| 106 data_[view].animation->Stop(); | 99 data_[view].animation->Stop(); |
| 107 } | 100 } |
| 108 | 101 |
| 109 bool BoundsAnimator::IsAnimating(View* view) const { | 102 bool BoundsAnimator::IsAnimating(View* view) const { |
| 110 return data_.find(view) != data_.end(); | 103 return data_.find(view) != data_.end(); |
| 111 } | 104 } |
| 112 | 105 |
| 113 bool BoundsAnimator::IsAnimating() const { | 106 bool BoundsAnimator::IsAnimating() const { |
| 114 return !data_.empty(); | 107 return !data_.empty(); |
| 115 } | 108 } |
| 116 | 109 |
| 117 void BoundsAnimator::Cancel() { | 110 void BoundsAnimator::Cancel() { |
| 118 if (data_.empty()) | 111 if (data_.empty()) |
| 119 return; | 112 return; |
| 120 | 113 |
| 121 #if defined(OS_LINUX) | |
| 122 LOG(ERROR) << "Cancelling animations"; | |
| 123 #endif | |
| 124 | |
| 125 while (!data_.empty()) | 114 while (!data_.empty()) |
| 126 data_.begin()->second.animation->Stop(); | 115 data_.begin()->second.animation->Stop(); |
| 127 | 116 |
| 128 // Invoke AnimationContainerProgressed to force a repaint and notify delegate. | 117 // Invoke AnimationContainerProgressed to force a repaint and notify delegate. |
| 129 AnimationContainerProgressed(container_.get()); | 118 AnimationContainerProgressed(container_.get()); |
| 130 } | 119 } |
| 131 | 120 |
| 132 SlideAnimation* BoundsAnimator::CreateAnimation() { | 121 SlideAnimation* BoundsAnimator::CreateAnimation() { |
| 133 SlideAnimation* animation = new SlideAnimation(this); | 122 SlideAnimation* animation = new SlideAnimation(this); |
| 134 animation->SetContainer(container_.get()); | 123 animation->SetContainer(container_.get()); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 // Notify here rather than from AnimationXXX to avoid deleting the animation | 224 // Notify here rather than from AnimationXXX to avoid deleting the animation |
| 236 // while the animaion is calling us. | 225 // while the animaion is calling us. |
| 237 observer_->OnBoundsAnimatorDone(this); | 226 observer_->OnBoundsAnimatorDone(this); |
| 238 } | 227 } |
| 239 } | 228 } |
| 240 | 229 |
| 241 void BoundsAnimator::AnimationContainerEmpty(AnimationContainer* container) { | 230 void BoundsAnimator::AnimationContainerEmpty(AnimationContainer* container) { |
| 242 } | 231 } |
| 243 | 232 |
| 244 } // namespace views | 233 } // namespace views |
| OLD | NEW |