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/views/animation/bounds_animator.h" | 5 #include "ui/views/animation/bounds_animator.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include <memory> |
| 8 |
8 #include "ui/gfx/animation/animation_container.h" | 9 #include "ui/gfx/animation/animation_container.h" |
9 #include "ui/gfx/animation/slide_animation.h" | 10 #include "ui/gfx/animation/slide_animation.h" |
10 #include "ui/views/animation/bounds_animator_observer.h" | 11 #include "ui/views/animation/bounds_animator_observer.h" |
11 #include "ui/views/view.h" | 12 #include "ui/views/view.h" |
12 | 13 |
13 // Duration in milliseconds for animations. | 14 // Duration in milliseconds for animations. |
14 static const int kDefaultAnimationDuration = 200; | 15 static const int kDefaultAnimationDuration = 200; |
15 | 16 |
16 using gfx::Animation; | 17 using gfx::Animation; |
17 using gfx::AnimationContainer; | 18 using gfx::AnimationContainer; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 gfx::Rect BoundsAnimator::GetTargetBounds(View* view) { | 83 gfx::Rect BoundsAnimator::GetTargetBounds(View* view) { |
83 if (!IsAnimating(view)) | 84 if (!IsAnimating(view)) |
84 return view->bounds(); | 85 return view->bounds(); |
85 return data_[view].target_bounds; | 86 return data_[view].target_bounds; |
86 } | 87 } |
87 | 88 |
88 void BoundsAnimator::SetAnimationForView(View* view, | 89 void BoundsAnimator::SetAnimationForView(View* view, |
89 SlideAnimation* animation) { | 90 SlideAnimation* animation) { |
90 DCHECK(animation); | 91 DCHECK(animation); |
91 | 92 |
92 scoped_ptr<SlideAnimation> animation_wrapper(animation); | 93 std::unique_ptr<SlideAnimation> animation_wrapper(animation); |
93 | 94 |
94 if (!IsAnimating(view)) | 95 if (!IsAnimating(view)) |
95 return; | 96 return; |
96 | 97 |
97 // We delay deleting the animation until the end so that we don't prematurely | 98 // We delay deleting the animation until the end so that we don't prematurely |
98 // send out notification that we're done. | 99 // send out notification that we're done. |
99 scoped_ptr<Animation> old_animation(ResetAnimationForView(view)); | 100 std::unique_ptr<Animation> old_animation(ResetAnimationForView(view)); |
100 | 101 |
101 data_[view].animation = animation_wrapper.release(); | 102 data_[view].animation = animation_wrapper.release(); |
102 animation_to_view_[animation] = view; | 103 animation_to_view_[animation] = view; |
103 | 104 |
104 animation->set_delegate(this); | 105 animation->set_delegate(this); |
105 animation->SetContainer(container_.get()); | 106 animation->SetContainer(container_.get()); |
106 animation->Show(); | 107 animation->Show(); |
107 } | 108 } |
108 | 109 |
109 const SlideAnimation* BoundsAnimator::GetAnimationForView(View* view) { | 110 const SlideAnimation* BoundsAnimator::GetAnimationForView(View* view) { |
110 return !IsAnimating(view) ? NULL : data_[view].animation; | 111 return !IsAnimating(view) ? NULL : data_[view].animation; |
111 } | 112 } |
112 | 113 |
113 void BoundsAnimator::SetAnimationDelegate( | 114 void BoundsAnimator::SetAnimationDelegate( |
114 View* view, | 115 View* view, |
115 scoped_ptr<AnimationDelegate> delegate) { | 116 std::unique_ptr<AnimationDelegate> delegate) { |
116 DCHECK(IsAnimating(view)); | 117 DCHECK(IsAnimating(view)); |
117 | 118 |
118 data_[view].delegate = delegate.release(); | 119 data_[view].delegate = delegate.release(); |
119 } | 120 } |
120 | 121 |
121 void BoundsAnimator::StopAnimatingView(View* view) { | 122 void BoundsAnimator::StopAnimatingView(View* view) { |
122 if (!IsAnimating(view)) | 123 if (!IsAnimating(view)) |
123 return; | 124 return; |
124 | 125 |
125 data_[view].animation->Stop(); | 126 data_[view].animation->Stop(); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 FOR_EACH_OBSERVER(BoundsAnimatorObserver, | 274 FOR_EACH_OBSERVER(BoundsAnimatorObserver, |
274 observers_, | 275 observers_, |
275 OnBoundsAnimatorDone(this)); | 276 OnBoundsAnimatorDone(this)); |
276 } | 277 } |
277 } | 278 } |
278 | 279 |
279 void BoundsAnimator::AnimationContainerEmpty(AnimationContainer* container) { | 280 void BoundsAnimator::AnimationContainerEmpty(AnimationContainer* container) { |
280 } | 281 } |
281 | 282 |
282 } // namespace views | 283 } // namespace views |
OLD | NEW |