summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorvarkha@chromium.org <varkha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-02 22:35:50 +0000
committervarkha@chromium.org <varkha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-02 22:35:50 +0000
commitfbc94488149d051eb37f09e9e5ba546f9d18880e (patch)
tree04208ff6f3b8d8f34f05a6a2a2114774aeccd5ca /ui
parentdd3e22f4d33b083713620f00a9f0b19bab06e20a (diff)
downloadchromium_src-fbc94488149d051eb37f09e9e5ba546f9d18880e.zip
chromium_src-fbc94488149d051eb37f09e9e5ba546f9d18880e.tar.gz
chromium_src-fbc94488149d051eb37f09e9e5ba546f9d18880e.tar.bz2
Changes sequence of docked animations when evicting windows from dock. Windows that are restored into docked area are slid from below rather than from above as before. Additionally minimizing animation for the windows that no longer fit in the dock is slowed down in hopes of making it less confusing.
To allow this a new ScopedLayerAnimationSettings::LockTransitionDuration method is introduced which locks the current animation transition duration until the ScopedLayerAnimationSettings object that invoked it goes out of scope. BUG=323188 TEST=ash_unittests --gtest_filter=WindowAnimationsTest.LockAnimationDuration Review URL: https://codereview.chromium.org/82573002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238212 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/compositor/layer_animator.cc11
-rw-r--r--ui/compositor/layer_animator.h13
-rw-r--r--ui/compositor/scoped_layer_animation_settings.cc16
-rw-r--r--ui/compositor/scoped_layer_animation_settings.h7
4 files changed, 38 insertions, 9 deletions
diff --git a/ui/compositor/layer_animator.cc b/ui/compositor/layer_animator.cc
index dd727a6..0fad04a 100644
--- a/ui/compositor/layer_animator.cc
+++ b/ui/compositor/layer_animator.cc
@@ -55,6 +55,7 @@ gfx::AnimationContainer* GetAnimationContainer() {
LayerAnimator::LayerAnimator(base::TimeDelta transition_duration)
: delegate_(NULL),
preemption_strategy_(IMMEDIATELY_SET_NEW_TARGET),
+ is_transition_duration_locked_(false),
transition_duration_(transition_duration),
tween_type_(gfx::Tween::LINEAR),
is_started_(false),
@@ -118,6 +119,10 @@ ANIMATED_PROPERTY(float, BRIGHTNESS, Brightness, float, brightness);
ANIMATED_PROPERTY(float, GRAYSCALE, Grayscale, float, grayscale);
ANIMATED_PROPERTY(SkColor, COLOR, Color, SkColor, color);
+base::TimeDelta LayerAnimator::GetTransitionDuration() const {
+ return transition_duration_;
+}
+
void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) {
delegate_ = delegate;
}
@@ -810,8 +815,10 @@ void LayerAnimator::OnScheduled(LayerAnimationSequence* sequence) {
sequence->OnScheduled();
}
-base::TimeDelta LayerAnimator::GetTransitionDuration() const {
- return transition_duration_;
+void LayerAnimator::SetTransitionDuration(base::TimeDelta duration) {
+ if (is_transition_duration_locked_)
+ return;
+ transition_duration_ = duration;
}
void LayerAnimator::ClearAnimationsInternal() {
diff --git a/ui/compositor/layer_animator.h b/ui/compositor/layer_animator.h
index 5fe0d5c..ad3754d 100644
--- a/ui/compositor/layer_animator.h
+++ b/ui/compositor/layer_animator.h
@@ -88,6 +88,10 @@ class COMPOSITOR_EXPORT LayerAnimator
virtual void SetColor(SkColor color);
SkColor GetTargetColor() const;
+ // Returns the default length of animations, including adjustment for slow
+ // animation mode if set.
+ base::TimeDelta GetTransitionDuration() const;
+
// Sets the layer animation delegate the animator is associated with. The
// animator does not own the delegate. The layer animator expects a non-NULL
// delegate for most of its operations, so do not call any methods without
@@ -294,9 +298,8 @@ class COMPOSITOR_EXPORT LayerAnimator
// starting the animation or adding to the queue.
void OnScheduled(LayerAnimationSequence* sequence);
- // Returns the default length of animations, including adjustment for slow
- // animation mode if set.
- base::TimeDelta GetTransitionDuration() const;
+ // Sets |transition_duration_| unless |is_transition_duration_locked_| is set.
+ void SetTransitionDuration(base::TimeDelta duration);
// Clears the animation queues and notifies any running animations that they
// have been aborted.
@@ -317,6 +320,10 @@ class COMPOSITOR_EXPORT LayerAnimator
// Determines how animations are replaced.
PreemptionStrategy preemption_strategy_;
+ // Whether the length of animations is locked. While it is locked
+ // SetTransitionDuration does not set |transition_duration_|.
+ bool is_transition_duration_locked_;
+
// The default length of animations.
base::TimeDelta transition_duration_;
diff --git a/ui/compositor/scoped_layer_animation_settings.cc b/ui/compositor/scoped_layer_animation_settings.cc
index b5bad67..84456ee 100644
--- a/ui/compositor/scoped_layer_animation_settings.cc
+++ b/ui/compositor/scoped_layer_animation_settings.cc
@@ -81,7 +81,9 @@ class InvertingObserver : public ImplicitAnimationObserver {
ScopedLayerAnimationSettings::ScopedLayerAnimationSettings(
LayerAnimator* animator)
: animator_(animator),
- old_transition_duration_(animator->transition_duration_),
+ old_is_transition_duration_locked_(
+ animator->is_transition_duration_locked_),
+ old_transition_duration_(animator->GetTransitionDuration()),
old_tween_type_(animator->tween_type()),
old_preemption_strategy_(animator->preemption_strategy()),
inverse_observer_(new InvertingObserver()) {
@@ -90,7 +92,9 @@ ScopedLayerAnimationSettings::ScopedLayerAnimationSettings(
}
ScopedLayerAnimationSettings::~ScopedLayerAnimationSettings() {
- animator_->transition_duration_ = old_transition_duration_;
+ animator_->is_transition_duration_locked_ =
+ old_is_transition_duration_locked_;
+ animator_->SetTransitionDuration(old_transition_duration_);
animator_->set_tween_type(old_tween_type_);
animator_->set_preemption_strategy(old_preemption_strategy_);
@@ -113,11 +117,15 @@ void ScopedLayerAnimationSettings::AddObserver(
void ScopedLayerAnimationSettings::SetTransitionDuration(
base::TimeDelta duration) {
- animator_->transition_duration_ = duration;
+ animator_->SetTransitionDuration(duration);
+}
+
+void ScopedLayerAnimationSettings::LockTransitionDuration() {
+ animator_->is_transition_duration_locked_ = true;
}
base::TimeDelta ScopedLayerAnimationSettings::GetTransitionDuration() const {
- return animator_->transition_duration_;
+ return animator_->GetTransitionDuration();
}
void ScopedLayerAnimationSettings::SetTweenType(gfx::Tween::Type tween_type) {
diff --git a/ui/compositor/scoped_layer_animation_settings.h b/ui/compositor/scoped_layer_animation_settings.h
index e36b853..e8a1b46 100644
--- a/ui/compositor/scoped_layer_animation_settings.h
+++ b/ui/compositor/scoped_layer_animation_settings.h
@@ -34,6 +34,12 @@ class COMPOSITOR_EXPORT ScopedLayerAnimationSettings {
void SetTransitionDuration(base::TimeDelta duration);
base::TimeDelta GetTransitionDuration() const;
+ // Locks transition duration in |animator_|. When transition duration
+ // is locked any subsequent changes to it are ignored until the
+ // ScopedLayerAnimationSettings object that has locked the duration goes out
+ // of scope.
+ void LockTransitionDuration();
+
void SetTweenType(gfx::Tween::Type tween_type);
gfx::Tween::Type GetTweenType() const;
@@ -50,6 +56,7 @@ class COMPOSITOR_EXPORT ScopedLayerAnimationSettings {
private:
LayerAnimator* animator_;
+ bool old_is_transition_duration_locked_;
base::TimeDelta old_transition_duration_;
gfx::Tween::Type old_tween_type_;
LayerAnimator::PreemptionStrategy old_preemption_strategy_;