OLD | NEW |
---|---|
1 // Copyright (c) 2012 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 "ash/wm/workspace/workspace_animations.h" | 5 #include "ash/wm/workspace/workspace_animations.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/compositor/layer.h" | 10 #include "ui/compositor/layer.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 | 42 |
43 // If |details.duration| is not-empty it is returned, otherwise | 43 // If |details.duration| is not-empty it is returned, otherwise |
44 // |kWorkspaceSwitchTimeMS| is returned. | 44 // |kWorkspaceSwitchTimeMS| is returned. |
45 base::TimeDelta DurationForWorkspaceShowOrHide( | 45 base::TimeDelta DurationForWorkspaceShowOrHide( |
46 const WorkspaceAnimationDetails& details) { | 46 const WorkspaceAnimationDetails& details) { |
47 return details.duration == base::TimeDelta() ? | 47 return details.duration == base::TimeDelta() ? |
48 base::TimeDelta::FromMilliseconds(kWorkspaceSwitchTimeMS) : | 48 base::TimeDelta::FromMilliseconds(kWorkspaceSwitchTimeMS) : |
49 details.duration; | 49 details.duration; |
50 } | 50 } |
51 | 51 |
52 void HideWindow(aura::Window* window) { | |
53 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); | |
54 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); | |
55 settings.SetTransitionDuration(base::TimeDelta()); | |
56 window->Hide(); | |
57 } | |
58 | |
52 } // namespace | 59 } // namespace |
53 | 60 |
54 WorkspaceAnimationDetails::WorkspaceAnimationDetails() | 61 WorkspaceAnimationDetails::WorkspaceAnimationDetails() |
55 : direction(WORKSPACE_ANIMATE_UP), | 62 : direction(WORKSPACE_ANIMATE_UP), |
56 animate(false), | 63 animate(false), |
57 animate_opacity(false), | 64 animate_opacity(false), |
58 animate_scale(false), | 65 animate_scale(false), |
59 pause_time_ms(0) { | 66 pause_time_ms(0) { |
60 } | 67 } |
61 | 68 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 settings.SetTransitionDuration(DurationForWorkspaceShowOrHide(details)); | 140 settings.SetTransitionDuration(DurationForWorkspaceShowOrHide(details)); |
134 settings.SetTweenType(kWorkspaceTweenType); | 141 settings.SetTweenType(kWorkspaceTweenType); |
135 if (details.animate_scale) { | 142 if (details.animate_scale) { |
136 ApplyWorkspaceScale(window->layer(), | 143 ApplyWorkspaceScale(window->layer(), |
137 details.direction == WORKSPACE_ANIMATE_UP ? | 144 details.direction == WORKSPACE_ANIMATE_UP ? |
138 WORKSPACE_SCALE_ABOVE : WORKSPACE_SCALE_BELOW); | 145 WORKSPACE_SCALE_ABOVE : WORKSPACE_SCALE_BELOW); |
139 } else { | 146 } else { |
140 window->layer()->SetTransform(gfx::Transform()); | 147 window->layer()->SetTransform(gfx::Transform()); |
141 } | 148 } |
142 | 149 |
143 // NOTE: Hide() must be before SetOpacity(), else | 150 window->layer()->SetVisible(false); |
144 // VisibilityController::UpdateLayerVisibility doesn't pass the false to the | |
145 // layer so that the layer and window end up out of sync and confused. | |
146 window->Hide(); | |
147 | 151 |
148 if (details.animate_opacity) | 152 if (details.animate_opacity) |
149 window->layer()->SetOpacity(0.0f); | 153 window->layer()->SetOpacity(0.0f); |
150 | 154 |
155 base::Closure hide_window_callback = base::Bind(&HideWindow, window); | |
Daniel Erat
2012/11/27 18:32:11
add a comment describing why you're doing this
Denis Kuznetsov (DE-MUC)
2012/11/27 18:46:59
Done.
| |
156 window->layer()->GetAnimator()->ScheduleSuccessCallbackForProperties( | |
157 hide_window_callback, | |
158 ui::LayerAnimationElement::VISIBILITY, | |
159 -1 | |
160 ); | |
161 | |
151 // After the animation completes snap the transform back to the identity, | 162 // After the animation completes snap the transform back to the identity, |
152 // otherwise any one that asks for screen bounds gets a slightly scaled | 163 // otherwise any one that asks for screen bounds gets a slightly scaled |
153 // version. | 164 // version. |
154 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); | 165 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); |
155 settings.SetTransitionDuration(base::TimeDelta()); | 166 settings.SetTransitionDuration(base::TimeDelta()); |
156 window->layer()->SetTransform(gfx::Transform()); | 167 window->layer()->SetTransform(gfx::Transform()); |
168 | |
Daniel Erat
2012/11/27 18:32:11
nit: remove extra blank line
Denis Kuznetsov (DE-MUC)
2012/11/27 18:46:59
Done.
| |
157 } | 169 } |
158 | 170 |
159 } // namespace internal | 171 } // namespace internal |
160 } // namespace ash | 172 } // namespace ash |
OLD | NEW |