Chromium Code Reviews| 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/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/workspace/workspace_animations.h" | 9 #include "ash/wm/workspace/workspace_animations.h" |
| 10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 gfx::Transform GetFastCloseTransform() { | 60 gfx::Transform GetFastCloseTransform() { |
| 61 gfx::Size root_size = Shell::GetPrimaryRootWindow()->bounds().size(); | 61 gfx::Size root_size = Shell::GetPrimaryRootWindow()->bounds().size(); |
| 62 gfx::Transform transform; | 62 gfx::Transform transform; |
| 63 transform.SetScale(0.0, 0.0); | 63 transform.SetScale(0.0, 0.0); |
| 64 transform.ConcatTranslate(floor(0.5 * root_size.width() + 0.5), | 64 transform.ConcatTranslate(floor(0.5 * root_size.width() + 0.5), |
| 65 floor(0.5 * root_size.height() + 0.5)); | 65 floor(0.5 * root_size.height() + 0.5)); |
| 66 return transform; | 66 return transform; |
| 67 } | 67 } |
| 68 | 68 |
| 69 // Slowly shrinks |window| to a slightly-smaller size. | 69 // Slowly shrinks |window| to a slightly-smaller size. |
| 70 void StartSlowCloseAnimationForWindow(aura::Window* window) { | 70 void StartSlowCloseAnimationForWindow(aura::Window* window, |
| 71 ui::LayerAnimationObserver* observer) { | |
| 71 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 72 ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| 72 animator->set_preemption_strategy( | 73 animator->set_preemption_strategy( |
| 73 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 74 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 74 animator->StartAnimation( | 75 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( |
| 75 new ui::LayerAnimationSequence( | 76 ui::LayerAnimationElement::CreateTransformElement( |
| 76 ui::LayerAnimationElement::CreateTransformElement( | 77 GetSlowCloseTransform(), |
| 77 GetSlowCloseTransform(), | 78 base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs))); |
| 78 base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs)))); | 79 animator->StartAnimation(sequence); |
| 80 if (observer) | |
| 81 sequence->AddObserver(observer); | |
| 79 } | 82 } |
| 80 | 83 |
| 81 // Quickly undoes the effects of the slow-close animation on |window|. | 84 // Quickly undoes the effects of the slow-close animation on |window|. |
| 82 void StartUndoSlowCloseAnimationForWindow(aura::Window* window) { | 85 void StartUndoSlowCloseAnimationForWindow( |
| 86 aura::Window* window, | |
| 87 ui::LayerAnimationObserver* observer) { | |
| 83 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 88 ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| 84 animator->set_preemption_strategy( | 89 animator->set_preemption_strategy( |
| 85 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 90 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 86 animator->StartAnimation( | 91 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( |
| 87 new ui::LayerAnimationSequence( | 92 ui::LayerAnimationElement::CreateTransformElement( |
| 88 ui::LayerAnimationElement::CreateTransformElement( | 93 gfx::Transform(), |
| 89 gfx::Transform(), | 94 base::TimeDelta::FromMilliseconds(kUndoSlowCloseAnimMs))); |
| 90 base::TimeDelta::FromMilliseconds(kUndoSlowCloseAnimMs)))); | 95 animator->StartAnimation(sequence); |
| 96 if (observer) | |
| 97 sequence->AddObserver(observer); | |
| 91 } | 98 } |
| 92 | 99 |
| 93 // Quickly shrinks |window| down to a point in the center of the screen and | 100 // Quickly shrinks |window| down to a point in the center of the screen and |
| 94 // fades it out to 0 opacity. | 101 // fades it out to 0 opacity. |
| 95 void StartFastCloseAnimationForWindow(aura::Window* window) { | 102 void StartFastCloseAnimationForWindow(aura::Window* window, |
| 103 ui::LayerAnimationObserver* observer) { | |
| 96 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 104 ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| 97 animator->set_preemption_strategy( | 105 animator->set_preemption_strategy( |
| 98 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 106 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 99 animator->StartAnimation( | 107 animator->StartAnimation( |
| 100 new ui::LayerAnimationSequence( | 108 new ui::LayerAnimationSequence( |
| 101 ui::LayerAnimationElement::CreateTransformElement( | 109 ui::LayerAnimationElement::CreateTransformElement( |
| 102 GetFastCloseTransform(), | 110 GetFastCloseTransform(), |
| 103 base::TimeDelta::FromMilliseconds(kFastCloseAnimMs)))); | 111 base::TimeDelta::FromMilliseconds(kFastCloseAnimMs)))); |
| 104 animator->StartAnimation( | 112 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( |
| 105 new ui::LayerAnimationSequence( | 113 ui::LayerAnimationElement::CreateOpacityElement( |
| 106 ui::LayerAnimationElement::CreateOpacityElement( | 114 0.0, base::TimeDelta::FromMilliseconds(kFastCloseAnimMs))); |
| 107 0.0, base::TimeDelta::FromMilliseconds(kFastCloseAnimMs)))); | 115 animator->StartAnimation(sequence); |
| 116 if (observer) | |
| 117 sequence->AddObserver(observer); | |
| 108 } | 118 } |
| 109 | 119 |
| 110 // Fades |window| to |target_opacity| over |length| milliseconds. | 120 // Fades |window| to |target_opacity| over |length| milliseconds. |
| 111 void StartPartialFadeAnimation(aura::Window* window, | 121 void StartPartialFadeAnimation(aura::Window* window, |
| 112 float target_opacity, | 122 float target_opacity, |
| 113 base::TimeDelta length, | 123 base::TimeDelta length, |
| 114 ui::LayerAnimationObserver* observer) { | 124 ui::LayerAnimationObserver* observer) { |
| 115 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 125 ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| 116 animator->set_preemption_strategy( | 126 animator->set_preemption_strategy( |
| 117 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 127 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 118 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( | 128 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( |
| 119 ui::LayerAnimationElement::CreateOpacityElement( | 129 ui::LayerAnimationElement::CreateOpacityElement( |
| 120 target_opacity, length)); | 130 target_opacity, length)); |
| 121 animator->StartAnimation(sequence); | 131 animator->StartAnimation(sequence); |
| 122 if (observer) | 132 if (observer) |
| 123 sequence->AddObserver(observer); | 133 sequence->AddObserver(observer); |
| 124 } | 134 } |
| 125 | 135 |
| 126 // Fades |window| in to full opacity. | 136 // Fades |window| in to full opacity. |
| 127 void FadeInWindow(aura::Window* window) { | 137 void FadeInWindow(aura::Window* window, |
| 138 ui::LayerAnimationObserver* observer) { | |
| 128 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 139 ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| 129 animator->set_preemption_strategy( | 140 animator->set_preemption_strategy( |
| 130 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 141 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 131 animator->StartAnimation( | 142 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( |
| 132 new ui::LayerAnimationSequence( | 143 ui::LayerAnimationElement::CreateOpacityElement( |
| 133 ui::LayerAnimationElement::CreateOpacityElement( | 144 1.0, base::TimeDelta::FromMilliseconds(kLockFadeInAnimMs))); |
| 134 1.0, base::TimeDelta::FromMilliseconds(kLockFadeInAnimMs)))); | 145 animator->StartAnimation(sequence); |
| 146 if (observer) | |
| 147 sequence->AddObserver(observer); | |
| 135 } | 148 } |
| 136 | 149 |
| 137 // Makes |window| fully transparent instantaneously. | 150 // Makes |window| fully transparent instantaneously. |
| 138 void HideWindow(aura::Window* window) { | 151 void HideWindow(aura::Window* window, ui::LayerAnimationObserver* observer) { |
| 139 window->layer()->SetOpacity(0.0); | 152 window->layer()->SetOpacity(0.0); |
| 153 if (observer) | |
| 154 observer->OnLayerAnimationEnded(NULL); | |
| 140 } | 155 } |
| 141 | 156 |
| 142 // Restores |window| to its original position and scale and full opacity | 157 // Restores |window| to its original position and scale and full opacity |
| 143 // instantaneously. | 158 // instantaneously. |
| 144 void RestoreWindow(aura::Window* window) { | 159 void RestoreWindow(aura::Window* window, ui::LayerAnimationObserver* observer) { |
| 145 window->layer()->SetTransform(gfx::Transform()); | 160 window->layer()->SetTransform(gfx::Transform()); |
| 146 window->layer()->SetOpacity(1.0); | 161 window->layer()->SetOpacity(1.0); |
| 162 if (observer) | |
| 163 observer->OnLayerAnimationEnded(NULL); | |
| 147 } | 164 } |
| 148 | 165 |
| 149 void RaiseWindow(aura::Window* window, base::TimeDelta length) { | 166 void RaiseWindow(aura::Window* window, |
| 167 base::TimeDelta length, | |
| 168 ui::LayerAnimationObserver* observer) { | |
| 150 WorkspaceAnimationDetails details; | 169 WorkspaceAnimationDetails details; |
| 151 details.direction = WORKSPACE_ANIMATE_UP; | 170 details.direction = WORKSPACE_ANIMATE_UP; |
| 152 details.animate = true; | 171 details.animate = true; |
| 153 details.animate_scale = true; | 172 details.animate_scale = true; |
| 154 details.animate_opacity = true; | 173 details.animate_opacity = true; |
| 155 details.duration = length; | 174 details.duration = length; |
| 156 HideWorkspace(window, details); | 175 HideWorkspace(window, details); |
| 176 // A bit dirty trick: we need to catch the end of the animation we don't | |
|
Daniel Erat
2012/10/25 15:45:58
nit: s/bit dirty/bit of a dirty/ (same below)
| |
| 177 // control. So we use two facts we know: which animator will be used and the | |
| 178 // target opacity to add "Do nothing" animation sequence. | |
| 179 // Unfortunately, we can not just use empty LayerAnimationSequence, because | |
| 180 // it does not call NotifyEnded(). | |
| 181 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | |
|
Daniel Erat
2012/10/25 15:45:58
if you only need this if an observer has been supp
| |
| 182 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( | |
| 183 ui::LayerAnimationElement::CreateOpacityElement( | |
| 184 0.0, base::TimeDelta())); | |
| 185 if (observer) | |
| 186 sequence->AddObserver(observer); | |
| 187 animator->ScheduleAnimation(sequence); | |
| 157 } | 188 } |
| 158 | 189 |
| 159 void LowerWindow(aura::Window* window, base::TimeDelta length) { | 190 void LowerWindow(aura::Window* window, |
| 191 base::TimeDelta length, | |
| 192 ui::LayerAnimationObserver* observer) { | |
| 160 WorkspaceAnimationDetails details; | 193 WorkspaceAnimationDetails details; |
| 161 details.direction = WORKSPACE_ANIMATE_DOWN; | 194 details.direction = WORKSPACE_ANIMATE_DOWN; |
| 162 details.animate = true; | 195 details.animate = true; |
| 163 details.animate_scale = true; | 196 details.animate_scale = true; |
| 164 details.animate_opacity = true; | 197 details.animate_opacity = true; |
| 165 details.duration = length; | 198 details.duration = length; |
| 166 ShowWorkspace(window, details); | 199 ShowWorkspace(window, details); |
| 200 // A bit dirty trick: we need to catch the end of the animation we don't | |
| 201 // control. So we use two facts we know: which animator will be used and the | |
| 202 // target opacity to add "Do nothing" animation sequence. | |
| 203 // Unfortunately, we can not just use empty LayerAnimationSequence, because | |
| 204 // it does not call NotifyEnded(). | |
| 205 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | |
| 206 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( | |
| 207 ui::LayerAnimationElement::CreateOpacityElement( | |
| 208 1.0, base::TimeDelta())); | |
| 209 if (observer) | |
| 210 sequence->AddObserver(observer); | |
| 211 animator->ScheduleAnimation(sequence); | |
| 167 } | 212 } |
| 168 | 213 |
| 169 // Animation observer that will drop animated foreground once animation is | 214 // Animation observer that will drop animated foreground once animation is |
| 170 // finished. It is used in when undoing shutdown animation. | 215 // finished. It is used in when undoing shutdown animation. |
| 171 class ForegroundDropAnimationObserver : public ui::LayerAnimationObserver { | 216 class CallbackAnimationObserver : public ui::LayerAnimationObserver { |
| 172 public: | 217 public: |
| 173 explicit ForegroundDropAnimationObserver(SessionStateAnimator* animator) | 218 explicit CallbackAnimationObserver(base::Callback<void(void)> &callback) |
| 174 : animator_(animator) { | 219 : callback_(callback) { |
| 175 } | 220 } |
| 176 virtual ~ForegroundDropAnimationObserver() { | 221 virtual ~CallbackAnimationObserver() { |
| 177 } | 222 } |
| 178 | 223 |
| 179 private: | 224 private: |
| 180 // Overridden from ui::LayerAnimationObserver: | 225 // Overridden from ui::LayerAnimationObserver: |
| 181 virtual void OnLayerAnimationEnded(ui::LayerAnimationSequence* seq) | 226 virtual void OnLayerAnimationEnded(ui::LayerAnimationSequence* seq) |
| 182 OVERRIDE { | 227 OVERRIDE { |
| 183 // Drop foreground once animation is over. | 228 // Drop foreground once animation is over. |
| 184 animator_->DropForeground(); | 229 callback_.Run(); |
| 185 delete this; | 230 delete this; |
| 186 } | 231 } |
| 187 | 232 |
| 188 virtual void OnLayerAnimationAborted(ui::LayerAnimationSequence* seq) | 233 virtual void OnLayerAnimationAborted(ui::LayerAnimationSequence* seq) |
| 189 OVERRIDE { | 234 OVERRIDE { |
| 190 // Drop foreground once animation is over. | 235 // Drop foreground once animation is over. |
| 191 animator_->DropForeground(); | 236 callback_.Run(); |
| 192 delete this; | 237 delete this; |
| 193 } | 238 } |
| 194 | 239 |
| 195 virtual void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq) | 240 virtual void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq) |
| 196 OVERRIDE {} | 241 OVERRIDE {} |
| 197 | 242 |
| 198 SessionStateAnimator* animator_; | 243 base::Callback<void(void)> callback_; |
| 199 | 244 |
| 200 DISALLOW_COPY_AND_ASSIGN(ForegroundDropAnimationObserver); | 245 DISALLOW_COPY_AND_ASSIGN(CallbackAnimationObserver); |
| 201 }; | 246 }; |
| 202 | 247 |
| 203 } // namespace | 248 } // namespace |
| 204 | 249 |
| 205 void SessionStateAnimator::TestApi::TriggerHideBlackLayerTimeout() { | 250 void SessionStateAnimator::TestApi::TriggerHideBlackLayerTimeout() { |
| 206 animator_->DropBlackLayer(); | 251 animator_->DropBlackLayer(); |
| 207 animator_->hide_black_layer_timer_.Stop(); | 252 animator_->hide_black_layer_timer_.Stop(); |
| 208 } | 253 } |
| 209 | 254 |
| 210 bool SessionStateAnimator::TestApi::ContainersAreAnimated( | 255 bool SessionStateAnimator::TestApi::ContainersAreAnimated( |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 root_window, | 371 root_window, |
| 327 internal::kShellWindowId_LockScreenRelatedContainersContainer)); | 372 internal::kShellWindowId_LockScreenRelatedContainersContainer)); |
| 328 } | 373 } |
| 329 if (container_mask & LOCK_SCREEN_SYSTEM_FOREGROUND) { | 374 if (container_mask & LOCK_SCREEN_SYSTEM_FOREGROUND) { |
| 330 containers->push_back(Shell::GetContainer( | 375 containers->push_back(Shell::GetContainer( |
| 331 root_window, | 376 root_window, |
| 332 internal::kShellWindowId_PowerButtonAnimationContainer)); | 377 internal::kShellWindowId_PowerButtonAnimationContainer)); |
| 333 } | 378 } |
| 334 } | 379 } |
| 335 | 380 |
| 381 void SessionStateAnimator::StartAnimation(int container_mask, | |
| 382 AnimationType type) { | |
| 383 aura::Window::Windows containers; | |
| 384 GetContainers(container_mask, &containers); | |
| 385 for (aura::Window::Windows::const_iterator it = containers.begin(); | |
| 386 it != containers.end(); ++it) { | |
| 387 RunAnimationForWindow(*it, type, NULL); | |
| 388 } | |
| 389 } | |
| 390 | |
| 336 // Apply animation |type| to all containers described by |container_mask|. | 391 // Apply animation |type| to all containers described by |container_mask|. |
| 337 void SessionStateAnimator::StartAnimation(int container_mask, | 392 void SessionStateAnimator::StartAnimation( |
| 338 AnimationType type) { | 393 int container_mask, |
| 394 AnimationType type, | |
| 395 base::Callback<void(void)>& callback) { | |
| 339 aura::Window::Windows containers; | 396 aura::Window::Windows containers; |
| 340 GetContainers(container_mask, &containers); | 397 GetContainers(container_mask, &containers); |
| 341 | |
| 342 for (aura::Window::Windows::const_iterator it = containers.begin(); | 398 for (aura::Window::Windows::const_iterator it = containers.begin(); |
| 343 it != containers.end(); ++it) { | 399 it != containers.end(); ++it) { |
| 344 aura::Window* window = *it; | 400 ui::LayerAnimationObserver* observer = |
| 345 switch (type) { | 401 new CallbackAnimationObserver(callback); |
|
Daniel Erat
2012/10/25 15:45:58
nit: indent four spaces, not three
| |
| 346 case ANIMATION_PARTIAL_CLOSE: | 402 RunAnimationForWindow(*it, type, observer); |
| 347 StartSlowCloseAnimationForWindow(window); | |
| 348 break; | |
| 349 case ANIMATION_UNDO_PARTIAL_CLOSE: | |
| 350 StartUndoSlowCloseAnimationForWindow(window); | |
| 351 break; | |
| 352 case ANIMATION_FULL_CLOSE: | |
| 353 StartFastCloseAnimationForWindow(window); | |
| 354 break; | |
| 355 case ANIMATION_FADE_IN: | |
| 356 FadeInWindow(window); | |
| 357 break; | |
| 358 case ANIMATION_HIDE: | |
| 359 HideWindow(window); | |
| 360 break; | |
| 361 case ANIMATION_RESTORE: | |
| 362 RestoreWindow(window); | |
| 363 break; | |
| 364 case ANIMATION_RAISE: | |
| 365 RaiseWindow(window, | |
| 366 base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs)); | |
| 367 break; | |
| 368 case ANIMATION_LOWER: | |
| 369 LowerWindow(window, | |
| 370 base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs)); | |
| 371 break; | |
| 372 case ANIMATION_PARTIAL_FADE_IN: | |
| 373 StartPartialFadeAnimation(window, kPartialFadeRatio, | |
| 374 base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs), | |
| 375 NULL); | |
| 376 break; | |
| 377 case ANIMATION_UNDO_PARTIAL_FADE_IN: | |
| 378 StartPartialFadeAnimation(window, 0.0, | |
| 379 base::TimeDelta::FromMilliseconds(kUndoSlowCloseAnimMs), | |
| 380 new ForegroundDropAnimationObserver(this)); | |
| 381 break; | |
| 382 case ANIMATION_FULL_FADE_IN: | |
| 383 StartPartialFadeAnimation(window, 1.0, | |
| 384 base::TimeDelta::FromMilliseconds(kFastCloseAnimMs), NULL); | |
| 385 break; | |
| 386 default: | |
| 387 NOTREACHED() << "Unhandled animation type " << type; | |
| 388 } | |
| 389 } | 403 } |
| 390 } | 404 } |
| 391 | 405 |
| 406 void SessionStateAnimator::RunAnimationForWindow( | |
| 407 aura::Window* window, | |
| 408 AnimationType type, | |
| 409 ui::LayerAnimationObserver* observer) { | |
| 410 switch (type) { | |
| 411 case ANIMATION_PARTIAL_CLOSE: | |
| 412 StartSlowCloseAnimationForWindow(window, observer); | |
| 413 break; | |
| 414 case ANIMATION_UNDO_PARTIAL_CLOSE: | |
| 415 StartUndoSlowCloseAnimationForWindow(window, observer); | |
| 416 break; | |
| 417 case ANIMATION_FULL_CLOSE: | |
| 418 StartFastCloseAnimationForWindow(window, observer); | |
| 419 break; | |
| 420 case ANIMATION_FADE_IN: | |
| 421 FadeInWindow(window, observer); | |
| 422 break; | |
| 423 case ANIMATION_HIDE: | |
| 424 HideWindow(window, observer); | |
| 425 break; | |
| 426 case ANIMATION_RESTORE: | |
| 427 RestoreWindow(window, observer); | |
| 428 break; | |
| 429 case ANIMATION_RAISE: | |
| 430 RaiseWindow(window, | |
| 431 base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs), | |
| 432 observer); | |
| 433 break; | |
| 434 case ANIMATION_LOWER: | |
| 435 LowerWindow(window, | |
| 436 base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs), | |
| 437 observer); | |
| 438 break; | |
| 439 case ANIMATION_PARTIAL_FADE_IN: | |
| 440 StartPartialFadeAnimation(window, kPartialFadeRatio, | |
| 441 base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs), | |
| 442 observer); | |
| 443 break; | |
| 444 case ANIMATION_UNDO_PARTIAL_FADE_IN: | |
| 445 StartPartialFadeAnimation(window, 0.0, | |
| 446 base::TimeDelta::FromMilliseconds(kUndoSlowCloseAnimMs), | |
| 447 observer); | |
| 448 break; | |
| 449 case ANIMATION_FULL_FADE_IN: | |
| 450 StartPartialFadeAnimation(window, 1.0, | |
| 451 base::TimeDelta::FromMilliseconds(kFastCloseAnimMs), | |
| 452 observer); | |
| 453 break; | |
| 454 default: | |
| 455 NOTREACHED() << "Unhandled animation type " << type; | |
| 456 } | |
| 457 } | |
| 458 | |
| 392 void SessionStateAnimator::OnRootWindowResized(const aura::RootWindow* root, | 459 void SessionStateAnimator::OnRootWindowResized(const aura::RootWindow* root, |
| 393 const gfx::Size& new_size) { | 460 const gfx::Size& new_size) { |
| 394 if (black_layer_.get()) | 461 if (black_layer_.get()) |
| 395 black_layer_->SetBounds(gfx::Rect(root->bounds().size())); | 462 black_layer_->SetBounds(gfx::Rect(root->bounds().size())); |
| 396 } | 463 } |
| 397 | 464 |
| 398 void SessionStateAnimator::ShowBlackLayer() { | 465 void SessionStateAnimator::ShowBlackLayer() { |
| 399 if (hide_black_layer_timer_.IsRunning()) | 466 if (hide_black_layer_timer_.IsRunning()) |
| 400 hide_black_layer_timer_.Stop(); | 467 hide_black_layer_timer_.Stop(); |
| 401 | 468 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 422 base::TimeDelta::FromMilliseconds(kUndoSlowCloseAnimMs), | 489 base::TimeDelta::FromMilliseconds(kUndoSlowCloseAnimMs), |
| 423 this, &SessionStateAnimator::DropBlackLayer); | 490 this, &SessionStateAnimator::DropBlackLayer); |
| 424 } | 491 } |
| 425 | 492 |
| 426 void SessionStateAnimator::CreateForeground() { | 493 void SessionStateAnimator::CreateForeground() { |
| 427 if (foreground_.get()) | 494 if (foreground_.get()) |
| 428 return; | 495 return; |
| 429 aura::Window* window = Shell::GetContainer( | 496 aura::Window* window = Shell::GetContainer( |
| 430 Shell::GetPrimaryRootWindow(), | 497 Shell::GetPrimaryRootWindow(), |
| 431 internal::kShellWindowId_PowerButtonAnimationContainer); | 498 internal::kShellWindowId_PowerButtonAnimationContainer); |
| 432 HideWindow(window); | 499 HideWindow(window, NULL); |
| 433 foreground_.reset( | 500 foreground_.reset( |
| 434 new ColoredWindowController(window, "SessionStateAnimatorForeground")); | 501 new ColoredWindowController(window, "SessionStateAnimatorForeground")); |
| 435 foreground_->SetColor(SK_ColorWHITE); | 502 foreground_->SetColor(SK_ColorWHITE); |
| 436 foreground_->GetWidget()->Show(); | 503 foreground_->GetWidget()->Show(); |
| 437 } | 504 } |
| 438 | 505 |
| 439 void SessionStateAnimator::DropForeground() { | 506 void SessionStateAnimator::DropForeground() { |
| 440 foreground_.reset(); | 507 foreground_.reset(); |
| 441 } | 508 } |
| 442 | 509 |
| 443 } // namespace internal | 510 } // namespace internal |
| 444 } // namespace ash | 511 } // namespace ash |
| OLD | NEW |