Chromium Code Reviews| Index: ash/wm/session_state_animator.cc |
| diff --git a/ash/wm/session_state_animator.cc b/ash/wm/session_state_animator.cc |
| index 6f55b90a6b5f965c84df2702587cad6fe5f375b1..5aad5ea2c837153ad039b8e5ada311ea05a47d95 100644 |
| --- a/ash/wm/session_state_animator.cc |
| +++ b/ash/wm/session_state_animator.cc |
| @@ -120,15 +120,16 @@ void StartPartialFadeAnimation(aura::Window* window, |
| sequence->AddObserver(observer); |
| } |
| -// Fades |window| in to full opacity over |duration|. |
| -void FadeInWindow(aura::Window* window, |
| - base::TimeDelta duration, |
| - ui::LayerAnimationObserver* observer) { |
| +// Fades |window| in to |opacity| over |duration|. |
| +void StartOpacityAnimationForWindow(aura::Window* window, |
| + float opacity, |
| + base::TimeDelta duration, |
| + ui::LayerAnimationObserver* observer) { |
| ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| animator->set_preemption_strategy( |
| ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( |
| - ui::LayerAnimationElement::CreateOpacityElement(1.0, duration)); |
| + ui::LayerAnimationElement::CreateOpacityElement(opacity, duration)); |
| animator->StartAnimation(sequence); |
| if (observer) |
| sequence->AddObserver(observer); |
| @@ -158,6 +159,8 @@ void HideWindow(aura::Window* window, |
| ui::Layer* layer = window->layer(); |
| ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); |
| + settings.SetPreemptionStrategy( |
| + ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| settings.SetTransitionDuration(duration); |
| settings.SetTweenType(ui::Tween::EASE_OUT); |
| @@ -188,19 +191,15 @@ void HideWindow(aura::Window* window, |
| } |
| } |
| -void ShowWindow(aura::Window* window, |
| - base::TimeDelta duration, |
| - bool above, |
| - ui::LayerAnimationObserver* observer) { |
| +void TransformWindowToBaseState(aura::Window* window, |
|
sky
2012/12/12 20:35:56
Add a comment for this. How about naming SetToInit
Denis Kuznetsov (DE-MUC)
2012/12/13 18:11:24
Added comment.
I don't like BaseState, but I think
|
| + base::TimeDelta duration, |
| + ui::LayerAnimationObserver* observer) { |
| ui::Layer* layer = window->layer(); |
| ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); |
| - // Set initial state of animation |
| - settings.SetTransitionDuration(base::TimeDelta()); |
| - SetTransformForScaleAnimation(layer, |
| - above ? LAYER_SCALE_ANIMATION_ABOVE : LAYER_SCALE_ANIMATION_BELOW); |
| - |
| // Animate to target values. |
| + settings.SetPreemptionStrategy( |
|
sky
2012/12/12 20:35:56
Why do you need this (say question on 162)?
Denis Kuznetsov (DE-MUC)
2012/12/13 17:59:50
This method can be called directly (without ShowWi
|
| + ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| settings.SetTransitionDuration(duration); |
| settings.SetTweenType(ui::Tween::EASE_OUT); |
| @@ -223,6 +222,23 @@ void ShowWindow(aura::Window* window, |
| } |
| } |
| +void ShowWindow(aura::Window* window, |
| + base::TimeDelta duration, |
| + bool above, |
| + ui::LayerAnimationObserver* observer) { |
| + ui::Layer* layer = window->layer(); |
| + ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); |
|
sky
2012/12/12 20:35:56
Why do you need a ScopedLayerAnimationSettings her
|
| + |
| + // Set initial state of animation |
| + settings.SetPreemptionStrategy( |
| + ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| + settings.SetTransitionDuration(base::TimeDelta()); |
| + SetTransformForScaleAnimation(layer, |
| + above ? LAYER_SCALE_ANIMATION_ABOVE : LAYER_SCALE_ANIMATION_BELOW); |
| + |
| + TransformWindowToBaseState(window, duration, observer); |
|
sky
2012/12/12 20:35:56
This means you'll have two ScopedLayerAnimationSet
Denis Kuznetsov (DE-MUC)
2012/12/13 17:59:50
As TransformWindowToBaseState can be called outsid
|
| +} |
| + |
| // Starts grayscale/brightness animation for |window| over |duration|. Target |
| // value for both grayscale and brightness are specified by |target|. |
| void StartGrayscaleBrightnessAnimationForWindow( |
| @@ -232,8 +248,26 @@ void StartGrayscaleBrightnessAnimationForWindow( |
| ui::LayerAnimationObserver* observer) { |
| ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| - std::vector<ui::LayerAnimationSequence*> animations = |
| - CreateBrightnessGrayscaleAnimationSequence(target, duration); |
| + scoped_ptr<ui::LayerAnimationSequence> brightness_sequence( |
| + new ui::LayerAnimationSequence()); |
| + scoped_ptr<ui::LayerAnimationSequence> grayscale_sequence( |
| + new ui::LayerAnimationSequence()); |
| + |
| + scoped_ptr<ui::LayerAnimationElement> brightness_element( |
| + ui::LayerAnimationElement::CreateBrightnessElement( |
| + target, duration)); |
| + brightness_element->set_tween_type(ui::Tween::EASE_IN); |
| + brightness_sequence->AddElement(brightness_element.release()); |
| + |
| + scoped_ptr<ui::LayerAnimationElement> grayscale_element( |
| + ui::LayerAnimationElement::CreateGrayscaleElement( |
| + target, duration)); |
| + grayscale_element->set_tween_type(ui::Tween::EASE_IN); |
| + grayscale_sequence->AddElement(grayscale_element.release()); |
| + |
| + std::vector<ui::LayerAnimationSequence*> animations; |
| + animations.push_back(brightness_sequence.release()); |
| + animations.push_back(grayscale_sequence.release()); |
| if (observer) |
| animations[0]->AddObserver(observer); |
| @@ -299,6 +333,10 @@ bool IsLayerAnimated(ui::Layer* layer, |
| if (layer->GetTargetOpacity() < 0.9999) |
| return false; |
| break; |
| + case SessionStateAnimator::ANIMATION_FADE_OUT: |
| + if (layer->GetTargetOpacity() > 0.0001) |
| + return false; |
| + break; |
| case SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY: |
| if (layer->GetTargetOpacity() > 0.0001) |
| return false; |
| @@ -318,6 +356,7 @@ bool IsLayerAnimated(ui::Layer* layer, |
| return false; |
| break; |
| case SessionStateAnimator::ANIMATION_DROP: |
| + case SessionStateAnimator::ANIMATION_UNDO_LIFT: |
| //ToDo(antim) : check other effects |
| if (layer->GetTargetOpacity() < 0.9999) |
| return false; |
| @@ -391,15 +430,15 @@ base::TimeDelta SessionStateAnimator::GetDuration(AnimationSpeed speed) { |
| case ANIMATION_SPEED_UNDOABLE: |
| return base::TimeDelta::FromMilliseconds(400); |
| case ANIMATION_SPEED_REVERT: |
| - return base::TimeDelta::FromMilliseconds(100); |
| + return base::TimeDelta::FromMilliseconds(150); |
| case ANIMATION_SPEED_FAST: |
| return base::TimeDelta::FromMilliseconds(150); |
| case ANIMATION_SPEED_SHOW_LOCK_SCREEN: |
| return base::TimeDelta::FromMilliseconds(200); |
| case ANIMATION_SPEED_MOVE_WINDOWS: |
| - return base::TimeDelta::FromMilliseconds(400); |
| + return base::TimeDelta::FromMilliseconds(350); |
| case ANIMATION_SPEED_UNDO_MOVE_WINDOWS: |
| - return base::TimeDelta::FromMilliseconds(600); |
| + return base::TimeDelta::FromMilliseconds(500); |
| case ANIMATION_SPEED_SHUTDOWN: |
| return base::TimeDelta::FromMilliseconds(1000); |
| case ANIMATION_SPEED_REVERT_SHUTDOWN: |
| @@ -458,11 +497,6 @@ void SessionStateAnimator::GetContainers(int container_mask, |
| root_window, |
| internal::kShellWindowId_LockScreenRelatedContainersContainer)); |
| } |
| - if (container_mask & LOCK_SCREEN_SYSTEM_FOREGROUND) { |
| - containers->push_back(Shell::GetContainer( |
| - root_window, |
| - internal::kShellWindowId_PowerButtonAnimationContainer)); |
| - } |
| } |
| void SessionStateAnimator::StartAnimation(int container_mask, |
| @@ -492,6 +526,19 @@ void SessionStateAnimator::StartAnimationWithCallback( |
| } |
| } |
| +void SessionStateAnimator::StartAnimationWithObserver( |
|
sky
2012/12/12 20:35:56
Is this used?
Denis Kuznetsov (DE-MUC)
2012/12/13 17:59:50
Yes, SessionStateControllerImpl2 uses it.
|
| + int container_mask, |
| + AnimationType type, |
| + AnimationSpeed speed, |
| + ui::LayerAnimationObserver* observer) { |
| + aura::Window::Windows containers; |
| + GetContainers(container_mask, &containers); |
| + for (aura::Window::Windows::const_iterator it = containers.begin(); |
| + it != containers.end(); ++it) { |
| + RunAnimationForWindow(*it, type, speed, observer); |
| + } |
| +} |
| + |
| void SessionStateAnimator::StartGlobalAnimation(AnimationType type, |
| AnimationSpeed speed) { |
| aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); |
| @@ -516,7 +563,10 @@ void SessionStateAnimator::RunAnimationForWindow( |
| StartFastCloseAnimationForWindow(window, duration, observer); |
| break; |
| case ANIMATION_FADE_IN: |
| - FadeInWindow(window, duration, observer); |
| + StartOpacityAnimationForWindow(window, 1.0, duration, observer); |
| + break; |
| + case ANIMATION_FADE_OUT: |
| + StartOpacityAnimationForWindow(window, 0.0, duration, observer); |
| break; |
| case ANIMATION_HIDE_IMMEDIATELY: |
| DCHECK_EQ(speed, ANIMATION_SPEED_IMMEDIATE); |
| @@ -532,6 +582,9 @@ void SessionStateAnimator::RunAnimationForWindow( |
| case ANIMATION_DROP: |
| ShowWindow(window, duration, true, observer); |
| break; |
| + case ANIMATION_UNDO_LIFT: |
| + TransformWindowToBaseState(window, duration, observer); |
| + break; |
| case ANIMATION_RAISE_TO_SCREEN: |
| ShowWindow(window, duration, false, observer); |
| break; |