diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-24 02:08:54 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-24 02:08:54 +0000 |
commit | cec3dc4cbab2fbe94089a5177ee4191d6cf6e7ac (patch) | |
tree | 47f7996fc980983af1ede8ebeb48c751dded5b01 /ui | |
parent | 6e8ac9af5c73f256555d2e3b2782ad82e44350c9 (diff) | |
download | chromium_src-cec3dc4cbab2fbe94089a5177ee4191d6cf6e7ac.zip chromium_src-cec3dc4cbab2fbe94089a5177ee4191d6cf6e7ac.tar.gz chromium_src-cec3dc4cbab2fbe94089a5177ee4191d6cf6e7ac.tar.bz2 |
ash: Fix launcher icon overlaps with status.
- Make LauncherView::CalculateIdealBounds to return last visible index;
- In LauncherView::LauncherItemAdded, use the last visible index to determine if
we need the animation;
BUG=122482
TEST=Verify fix for issue 122482.
Review URL: http://codereview.chromium.org/10068027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133603 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/views/animation/bounds_animator.cc | 28 | ||||
-rw-r--r-- | ui/views/animation/bounds_animator.h | 18 |
2 files changed, 33 insertions, 13 deletions
diff --git a/ui/views/animation/bounds_animator.cc b/ui/views/animation/bounds_animator.cc index 2e4b0c1..3e7c93e 100644 --- a/ui/views/animation/bounds_animator.cc +++ b/ui/views/animation/bounds_animator.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,7 +10,7 @@ #include "ui/views/view.h" // Duration in milliseconds for animations. -static const int kAnimationDuration = 200; +static const int kDefaultAnimationDuration = 200; using ui::Animation; using ui::AnimationContainer; @@ -21,8 +21,8 @@ namespace views { BoundsAnimator::BoundsAnimator(View* parent) : parent_(parent), - observer_(NULL), - container_(new AnimationContainer()) { + container_(new AnimationContainer()), + animation_duration_ms_(kDefaultAnimationDuration) { container_->set_observer(this); } @@ -137,10 +137,22 @@ void BoundsAnimator::Cancel() { AnimationContainerProgressed(container_.get()); } +void BoundsAnimator::SetAnimationDuration(int duration_ms) { + animation_duration_ms_ = duration_ms; +} + +void BoundsAnimator::AddObserver(BoundsAnimatorObserver* observer) { + observers_.AddObserver(observer); +} + +void BoundsAnimator::RemoveObserver(BoundsAnimatorObserver* observer) { + observers_.RemoveObserver(observer); +} + SlideAnimation* BoundsAnimator::CreateAnimation() { SlideAnimation* animation = new SlideAnimation(this); animation->SetContainer(container_.get()); - animation->SetSlideDuration(kAnimationDuration); + animation->SetSlideDuration(animation_duration_ms_); animation->SetTweenType(Tween::EASE_OUT); return animation; } @@ -249,10 +261,12 @@ void BoundsAnimator::AnimationContainerProgressed( repaint_bounds_.SetRect(0, 0, 0, 0); } - if (observer_ && !IsAnimating()) { + if (!IsAnimating()) { // Notify here rather than from AnimationXXX to avoid deleting the animation // while the animation is calling us. - observer_->OnBoundsAnimatorDone(this); + FOR_EACH_OBSERVER(BoundsAnimatorObserver, + observers_, + OnBoundsAnimatorDone(this)); } } diff --git a/ui/views/animation/bounds_animator.h b/ui/views/animation/bounds_animator.h index d0e2c2e..f84c2d0 100644 --- a/ui/views/animation/bounds_animator.h +++ b/ui/views/animation/bounds_animator.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,6 +10,7 @@ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" +#include "base/observer_list.h" #include "ui/base/animation/animation_container_observer.h" #include "ui/base/animation/animation_delegate.h" #include "ui/gfx/rect.h" @@ -24,7 +25,7 @@ namespace views { class BoundsAnimator; class View; -class BoundsAnimatorObserver { +class VIEWS_EXPORT BoundsAnimatorObserver { public: // Invoked when all animations are complete. virtual void OnBoundsAnimatorDone(BoundsAnimator* animator) = 0; @@ -92,9 +93,12 @@ class VIEWS_EXPORT BoundsAnimator : public ui::AnimationDelegate, // size. Any views marked for deletion are deleted. void Cancel(); - void set_observer(BoundsAnimatorObserver* observer) { - observer_ = observer; - } + // Overrides default animation duration. |duration_ms| is the new duration in + // milliseconds. + void SetAnimationDuration(int duration_ms); + + void AddObserver(BoundsAnimatorObserver* observer); + void RemoveObserver(BoundsAnimatorObserver* observer); protected: // Creates the animation to use for animating views. @@ -165,7 +169,7 @@ class VIEWS_EXPORT BoundsAnimator : public ui::AnimationDelegate, // Parent of all views being animated. View* parent_; - BoundsAnimatorObserver* observer_; + ObserverList<BoundsAnimatorObserver> observers_; // All animations we create up with the same container. scoped_refptr<ui::AnimationContainer> container_; @@ -182,6 +186,8 @@ class VIEWS_EXPORT BoundsAnimator : public ui::AnimationDelegate, // to repaint these bounds. gfx::Rect repaint_bounds_; + int animation_duration_ms_; + DISALLOW_COPY_AND_ASSIGN(BoundsAnimator); }; |