Index: ash/wm/workspace/workspace_animations.cc |
diff --git a/ash/wm/workspace/workspace_animations.cc b/ash/wm/workspace/workspace_animations.cc |
index 2abed13b3fa578e430bfd6ef2f4ccacb54163fe9..d732fab88971f098511d1eaf11830b649d4a70f1 100644 |
--- a/ash/wm/workspace/workspace_animations.cc |
+++ b/ash/wm/workspace/workspace_animations.cc |
@@ -61,26 +61,70 @@ WorkspaceAnimationDetails::WorkspaceAnimationDetails() |
WorkspaceAnimationDetails::~WorkspaceAnimationDetails() { |
} |
+void SetWorkspaceAnimationStartParameters( |
+ aura::Window* window, |
+ const WorkspaceAnimationDetails& details, |
+ bool show, |
+ bool force) { |
+ ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); |
+ settings.SetTweenType(kWorkspaceTweenType); |
+ if (details.animate_scale || force) { |
sky
2012/11/29 19:06:51
Why do we need both force and scale?
|
+ if (show) { |
+ ApplyWorkspaceScale(window->layer(), |
+ details.direction == WORKSPACE_ANIMATE_UP ? |
+ WORKSPACE_SCALE_BELOW : WORKSPACE_SCALE_ABOVE); |
+ } else { |
+ // Identity transform at the beginning of hide animation. |
+ window->layer()->SetTransform(gfx::Transform()); |
+ } |
+ } |
+ if (details.animate_opacity || force) { |
+ if (show) { |
+ window->layer()->SetOpacity(0.0f); |
+ } else { |
+ window->layer()->SetOpacity(1.0f); |
+ } |
+ } |
+} |
+ |
+void SetWorkspaceAnimationTargetParameters( |
+ aura::Window* window, |
+ const WorkspaceAnimationDetails& details, |
+ bool show, |
+ bool force) { |
+ if (details.animate_scale || force) { |
+ if (show) { |
+ // Identity transform at the end of show animation. |
+ window->layer()->SetTransform(gfx::Transform()); |
+ } else { |
+ ApplyWorkspaceScale(window->layer(), |
+ details.direction == WORKSPACE_ANIMATE_UP ? |
+ WORKSPACE_SCALE_ABOVE : WORKSPACE_SCALE_BELOW); |
+ } |
+ } |
+ if (details.animate_opacity || force) { |
+ if (show) { |
+ window->layer()->SetOpacity(1.0f); |
+ } else { |
+ window->layer()->SetOpacity(0.0f); |
+ } |
+ } |
+} |
+ |
void ShowWorkspace(aura::Window* window, |
const WorkspaceAnimationDetails& details) { |
window->Show(); |
+ const bool show = true; |
+ const bool force = true; |
+ const bool noforce = false; |
if (!details.animate || views::corewm::WindowAnimationsDisabled(NULL)) { |
- window->layer()->SetOpacity(1.0f); |
- window->layer()->SetTransform(gfx::Transform()); |
+ SetWorkspaceAnimationTargetParameters(window, details, show, force); |
return; |
} |
- window->layer()->SetOpacity(details.animate_opacity ? 0.0f : 1.0f); |
- if (details.animate_scale) { |
- ApplyWorkspaceScale(window->layer(), |
- details.direction == WORKSPACE_ANIMATE_UP ? |
- WORKSPACE_SCALE_BELOW : WORKSPACE_SCALE_ABOVE); |
- } else { |
- window->layer()->SetTransform(gfx::Transform()); |
- } |
- |
- // In order for pause to work we need to stop animations. |
+ SetWorkspaceAnimationStartParameters(window, details, show, noforce); |
+// In order for pause to work we need to stop animations. |
window->layer()->GetAnimator()->StopAnimating(); |
{ |
@@ -97,17 +141,18 @@ void ShowWorkspace(aura::Window* window, |
-1); |
} |
- settings.SetTweenType(kWorkspaceTweenType); |
settings.SetTransitionDuration(DurationForWorkspaceShowOrHide(details)); |
- window->layer()->SetTransform(gfx::Transform()); |
- window->layer()->SetOpacity(1.0f); |
+ SetWorkspaceAnimationTargetParameters(window, details, show, force); |
} |
} |
void HideWorkspace(aura::Window* window, |
const WorkspaceAnimationDetails& details) { |
- window->layer()->SetTransform(gfx::Transform()); |
- window->layer()->SetOpacity(1.0f); |
+ const bool hide = false; |
+ const bool force = true; |
+ const bool noforce = true; |
+ |
+ SetWorkspaceAnimationStartParameters(window, details, hide, force); |
window->layer()->GetAnimator()->StopAnimating(); |
if (!details.animate || views::corewm::WindowAnimationsDisabled(NULL)) { |
@@ -128,22 +173,13 @@ void HideWorkspace(aura::Window* window, |
} |
settings.SetTransitionDuration(DurationForWorkspaceShowOrHide(details)); |
- settings.SetTweenType(kWorkspaceTweenType); |
- if (details.animate_scale) { |
- ApplyWorkspaceScale(window->layer(), |
- details.direction == WORKSPACE_ANIMATE_UP ? |
- WORKSPACE_SCALE_ABOVE : WORKSPACE_SCALE_BELOW); |
- } else { |
- window->layer()->SetTransform(gfx::Transform()); |
- } |
// NOTE: Hide() must be before SetOpacity(), else |
// VisibilityController::UpdateLayerVisibility doesn't pass the false to the |
// layer so that the layer and window end up out of sync and confused. |
window->Hide(); |
- if (details.animate_opacity) |
- window->layer()->SetOpacity(0.0f); |
+ SetWorkspaceAnimationTargetParameters(window, details, hide, noforce); |
// After the animation completes snap the transform back to the identity, |
// otherwise any one that asks for screen bounds gets a slightly scaled |