Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(586)

Side by Side Diff: ui/views/animation/bounds_animator.cc

Issue 10068027: ash: Fix launcher icon overlaps with status. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/animation/bounds_animator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 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 "base/memory/scoped_ptr.h"
8 #include "ui/base/animation/animation_container.h" 8 #include "ui/base/animation/animation_container.h"
9 #include "ui/base/animation/slide_animation.h" 9 #include "ui/base/animation/slide_animation.h"
10 #include "ui/views/view.h" 10 #include "ui/views/view.h"
11 11
12 // Duration in milliseconds for animations. 12 // Duration in milliseconds for animations.
13 static const int kAnimationDuration = 200; 13 static const int kDefaultAnimationDuration = 200;
14 14
15 using ui::Animation; 15 using ui::Animation;
16 using ui::AnimationContainer; 16 using ui::AnimationContainer;
17 using ui::SlideAnimation; 17 using ui::SlideAnimation;
18 using ui::Tween; 18 using ui::Tween;
19 19
20 namespace views { 20 namespace views {
21 21
22 BoundsAnimator::BoundsAnimator(View* parent) 22 BoundsAnimator::BoundsAnimator(View* parent)
23 : parent_(parent), 23 : parent_(parent),
24 observer_(NULL), 24 container_(new AnimationContainer()),
25 container_(new AnimationContainer()) { 25 animation_duration_ms_(kDefaultAnimationDuration) {
26 container_->set_observer(this); 26 container_->set_observer(this);
27 } 27 }
28 28
29 BoundsAnimator::~BoundsAnimator() { 29 BoundsAnimator::~BoundsAnimator() {
30 // Reset the delegate so that we don't attempt to notify our observer from 30 // Reset the delegate so that we don't attempt to notify our observer from
31 // the destructor. 31 // the destructor.
32 container_->set_observer(NULL); 32 container_->set_observer(NULL);
33 33
34 // Delete all the animations, but don't remove any child views. We assume the 34 // Delete all the animations, but don't remove any child views. We assume the
35 // view owns us and is going to be deleted anyway. 35 // view owns us and is going to be deleted anyway.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 if (data_.empty()) 130 if (data_.empty())
131 return; 131 return;
132 132
133 while (!data_.empty()) 133 while (!data_.empty())
134 data_.begin()->second.animation->Stop(); 134 data_.begin()->second.animation->Stop();
135 135
136 // Invoke AnimationContainerProgressed to force a repaint and notify delegate. 136 // Invoke AnimationContainerProgressed to force a repaint and notify delegate.
137 AnimationContainerProgressed(container_.get()); 137 AnimationContainerProgressed(container_.get());
138 } 138 }
139 139
140 void BoundsAnimator::SetAnimationDuration(int duration_ms) {
141 animation_duration_ms_ = duration_ms;
142 }
143
144 void BoundsAnimator::AddObserver(BoundsAnimatorObserver* observer) {
145 observers_.AddObserver(observer);
146 }
147
148 void BoundsAnimator::RemoveObserver(BoundsAnimatorObserver* observer) {
149 observers_.RemoveObserver(observer);
150 }
151
140 SlideAnimation* BoundsAnimator::CreateAnimation() { 152 SlideAnimation* BoundsAnimator::CreateAnimation() {
141 SlideAnimation* animation = new SlideAnimation(this); 153 SlideAnimation* animation = new SlideAnimation(this);
142 animation->SetContainer(container_.get()); 154 animation->SetContainer(container_.get());
143 animation->SetSlideDuration(kAnimationDuration); 155 animation->SetSlideDuration(animation_duration_ms_);
144 animation->SetTweenType(Tween::EASE_OUT); 156 animation->SetTweenType(Tween::EASE_OUT);
145 return animation; 157 return animation;
146 } 158 }
147 159
148 void BoundsAnimator::RemoveFromMaps(View* view) { 160 void BoundsAnimator::RemoveFromMaps(View* view) {
149 DCHECK(data_.count(view) > 0); 161 DCHECK(data_.count(view) > 0);
150 DCHECK(animation_to_view_.count(data_[view].animation) > 0); 162 DCHECK(animation_to_view_.count(data_[view].animation) > 0);
151 163
152 animation_to_view_.erase(data_[view].animation); 164 animation_to_view_.erase(data_[view].animation);
153 data_.erase(view); 165 data_.erase(view);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 void BoundsAnimator::AnimationContainerProgressed( 254 void BoundsAnimator::AnimationContainerProgressed(
243 AnimationContainer* container) { 255 AnimationContainer* container) {
244 if (!repaint_bounds_.IsEmpty()) { 256 if (!repaint_bounds_.IsEmpty()) {
245 // Adjust for rtl. 257 // Adjust for rtl.
246 repaint_bounds_.set_x(parent_->GetMirroredXWithWidthInView( 258 repaint_bounds_.set_x(parent_->GetMirroredXWithWidthInView(
247 repaint_bounds_.x(), repaint_bounds_.width())); 259 repaint_bounds_.x(), repaint_bounds_.width()));
248 parent_->SchedulePaintInRect(repaint_bounds_); 260 parent_->SchedulePaintInRect(repaint_bounds_);
249 repaint_bounds_.SetRect(0, 0, 0, 0); 261 repaint_bounds_.SetRect(0, 0, 0, 0);
250 } 262 }
251 263
252 if (observer_ && !IsAnimating()) { 264 if (!IsAnimating()) {
253 // Notify here rather than from AnimationXXX to avoid deleting the animation 265 // Notify here rather than from AnimationXXX to avoid deleting the animation
254 // while the animation is calling us. 266 // while the animation is calling us.
255 observer_->OnBoundsAnimatorDone(this); 267 FOR_EACH_OBSERVER(BoundsAnimatorObserver,
268 observers_,
269 OnBoundsAnimatorDone(this));
256 } 270 }
257 } 271 }
258 272
259 void BoundsAnimator::AnimationContainerEmpty(AnimationContainer* container) { 273 void BoundsAnimator::AnimationContainerEmpty(AnimationContainer* container) {
260 } 274 }
261 275
262 } // namespace views 276 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/bounds_animator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698