Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: ash/wm/session_state_animator.cc

Issue 11419225: Decouple workspace animation from other actions on windows (e.g. hide/show), so that animations can… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merge with ToT Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/session_state_animator.h" 5 #include "ash/wm/session_state_animator.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_window_ids.h" 8 #include "ash/shell_window_ids.h"
9 #include "ash/wm/window_animations.h" 9 #include "ash/wm/window_animations.h"
10 #include "ash/wm/workspace/workspace_animations.h" 10 #include "ash/wm/workspace/workspace_animations.h"
11 #include "ui/aura/client/aura_constants.h" 11 #include "ui/aura/client/aura_constants.h"
12 #include "ui/aura/root_window.h" 12 #include "ui/aura/root_window.h"
13 #include "ui/compositor/layer_animation_observer.h" 13 #include "ui/compositor/layer_animation_observer.h"
14 #include "ui/compositor/layer_animation_sequence.h" 14 #include "ui/compositor/layer_animation_sequence.h"
15 #include "ui/compositor/scoped_layer_animation_settings.h"
15 #include "ui/views/widget/widget.h" 16 #include "ui/views/widget/widget.h"
16 17
17 namespace ash { 18 namespace ash {
18 namespace internal { 19 namespace internal {
19 20
20 namespace { 21 namespace {
21 22
22 // Slightly-smaller size that we scale the screen down to for the pre-lock and 23 // Slightly-smaller size that we scale the screen down to for the pre-lock and
23 // pre-shutdown states. 24 // pre-shutdown states.
24 const float kSlowCloseSizeRatio = 0.95f; 25 const float kSlowCloseSizeRatio = 0.95f;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 window->layer()->SetTransform(gfx::Transform()); 149 window->layer()->SetTransform(gfx::Transform());
149 window->layer()->SetOpacity(1.0); 150 window->layer()->SetOpacity(1.0);
150 if (observer) 151 if (observer)
151 observer->OnLayerAnimationEnded(NULL); 152 observer->OnLayerAnimationEnded(NULL);
152 } 153 }
153 154
154 void HideWindow(aura::Window* window, 155 void HideWindow(aura::Window* window,
155 base::TimeDelta duration, 156 base::TimeDelta duration,
156 WorkspaceAnimationDirection direction, 157 WorkspaceAnimationDirection direction,
157 ui::LayerAnimationObserver* observer) { 158 ui::LayerAnimationObserver* observer) {
159 ui::LayerAnimator* animator = window->layer()->GetAnimator();
160
158 WorkspaceAnimationDetails details; 161 WorkspaceAnimationDetails details;
159 details.direction = direction; 162 details.direction = direction;
160 details.animate = true; 163 details.animate = true;
161 details.animate_scale = true; 164 details.animate_scale = true;
162 details.animate_opacity = true; 165 details.animate_opacity = true;
163 details.duration = duration; 166 details.duration = duration;
164 HideWorkspace(window, details); 167
168 const bool noforce = false;
169 const bool hide = false;
170
171 ui::ScopedLayerAnimationSettings settings(animator);
172 settings.SetTransitionDuration(duration);
173
174 SetWorkspaceAnimationTargetParameters(window, details, hide, noforce);
175
176 // After the animation completes snap the transform back to the identity,
177 // otherwise any one that asks for screen bounds gets a slightly scaled
178 // version.
179 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
180 settings.SetTransitionDuration(base::TimeDelta());
181 window->layer()->SetTransform(gfx::Transform());
182
165 // A bit of a dirty trick: we need to catch the end of the animation we don't 183 // A bit of a dirty trick: we need to catch the end of the animation we don't
166 // control. So we use two facts we know: which animator will be used and the 184 // control. So we use two facts we know: which animator will be used and the
167 // target opacity to add "Do nothing" animation sequence. 185 // target opacity to add "Do nothing" animation sequence.
168 // Unfortunately, we can not just use empty LayerAnimationSequence, because 186 // Unfortunately, we can not just use empty LayerAnimationSequence, because
169 // it does not call NotifyEnded(). 187 // it does not call NotifyEnded().
170 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( 188 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence(
171 ui::LayerAnimationElement::CreateOpacityElement( 189 ui::LayerAnimationElement::CreateOpacityElement(
172 0.0, base::TimeDelta())); 190 0.0, base::TimeDelta()));
173 if (observer) 191 if (observer)
174 sequence->AddObserver(observer); 192 sequence->AddObserver(observer);
175 window->layer()->GetAnimator()->ScheduleAnimation(sequence); 193 animator->ScheduleAnimation(sequence);
176 } 194 }
177 195
178 void ShowWindow(aura::Window* window, 196 void ShowWindow(aura::Window* window,
179 base::TimeDelta length, 197 base::TimeDelta duration,
180 WorkspaceAnimationDirection direction, 198 WorkspaceAnimationDirection direction,
181 ui::LayerAnimationObserver* observer) { 199 ui::LayerAnimationObserver* observer) {
200 ui::LayerAnimator* animator = window->layer()->GetAnimator();
201
182 WorkspaceAnimationDetails details; 202 WorkspaceAnimationDetails details;
183 details.direction = direction; 203 details.direction = direction;
184 details.animate = true; 204 details.animate = true;
185 details.animate_scale = true; 205 details.animate_scale = true;
186 details.animate_opacity = true; 206 details.animate_opacity = true;
187 details.duration = length; 207 details.duration = duration;
188 ShowWorkspace(window, details); 208
209 const bool noforce = false;
210 const bool show = true;
211
212 ui::ScopedLayerAnimationSettings settings(animator);
213 settings.SetTransitionDuration(duration);
214
215 SetWorkspaceAnimationTargetParameters(window, details, show, noforce);
216
189 // A bit of a dirty trick: we need to catch the end of the animation we don't 217 // A bit of a dirty trick: we need to catch the end of the animation we don't
190 // control. So we use two facts we know: which animator will be used and the 218 // control. So we use two facts we know: which animator will be used and the
191 // target opacity to add "Do nothing" animation sequence. 219 // target opacity to add "Do nothing" animation sequence.
192 // Unfortunately, we can not just use empty LayerAnimationSequence, because 220 // Unfortunately, we can not just use empty LayerAnimationSequence, because
193 // it does not call NotifyEnded(). 221 // it does not call NotifyEnded().
194 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( 222 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence(
195 ui::LayerAnimationElement::CreateOpacityElement( 223 ui::LayerAnimationElement::CreateOpacityElement(
196 1.0, base::TimeDelta())); 224 1.0, base::TimeDelta()));
197 if (observer) 225 if (observer)
198 sequence->AddObserver(observer); 226 sequence->AddObserver(observer);
199 window->layer()->GetAnimator()->ScheduleAnimation(sequence); 227 animator->ScheduleAnimation(sequence);
200 } 228 }
201 229
202 // Starts grayscale/brightness animation for |window| over |duration|. Target 230 // Starts grayscale/brightness animation for |window| over |duration|. Target
203 // value for both grayscale and brightness are specified by |target|. 231 // value for both grayscale and brightness are specified by |target|.
204 void StartGrayscaleBrightnessAnimationForWindow( 232 void StartGrayscaleBrightnessAnimationForWindow(
205 aura::Window* window, 233 aura::Window* window,
206 float target, 234 float target,
207 base::TimeDelta duration, 235 base::TimeDelta duration,
208 ui::LayerAnimationObserver* observer) { 236 ui::LayerAnimationObserver* observer) {
209 ui::LayerAnimator* animator = window->layer()->GetAnimator(); 237 ui::LayerAnimator* animator = window->layer()->GetAnimator();
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 foreground_->SetColor(SK_ColorWHITE); 573 foreground_->SetColor(SK_ColorWHITE);
546 foreground_->GetWidget()->Show(); 574 foreground_->GetWidget()->Show();
547 } 575 }
548 576
549 void SessionStateAnimator::DropForeground() { 577 void SessionStateAnimator::DropForeground() {
550 foreground_.reset(); 578 foreground_.reset();
551 } 579 }
552 580
553 } // namespace internal 581 } // namespace internal
554 } // namespace ash 582 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/wm/workspace/workspace_animations.h » ('j') | ash/wm/workspace/workspace_animations.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698