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 of a dirty trick: we need to catch the end of the animation we don't | |
| 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::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( | |
| 182 ui::LayerAnimationElement::CreateOpacityElement( | |
| 183 0.0, base::TimeDelta())); | |
| 184 if (observer) | |
|
Nikita (slow)
2012/10/26 10:34:35
nit: You could move everything under the if (obser
| |
| 185 sequence->AddObserver(observer); | |
| 186 window->layer()->GetAnimator()->ScheduleAnimation(sequence); | |
| 157 } | 187 } |
| 158 | 188 |
| 159 void LowerWindow(aura::Window* window, base::TimeDelta length) { | 189 void LowerWindow(aura::Window* window, |
| 190 base::TimeDelta length, | |
| 191 ui::LayerAnimationObserver* observer) { | |
| 160 WorkspaceAnimationDetails details; | 192 WorkspaceAnimationDetails details; |
| 161 details.direction = WORKSPACE_ANIMATE_DOWN; | 193 details.direction = WORKSPACE_ANIMATE_DOWN; |
| 162 details.animate = true; | 194 details.animate = true; |
| 163 details.animate_scale = true; | 195 details.animate_scale = true; |
| 164 details.animate_opacity = true; | 196 details.animate_opacity = true; |
| 165 details.duration = length; | 197 details.duration = length; |
| 166 ShowWorkspace(window, details); | 198 ShowWorkspace(window, details); |
| 199 // A bit of a dirty trick: we need to catch the end of the animation we don't | |
| 200 // control. So we use two facts we know: which animator will be used and the | |
| 201 // target opacity to add "Do nothing" animation sequence. | |
| 202 // Unfortunately, we can not just use empty LayerAnimationSequence, because | |
| 203 // it does not call NotifyEnded(). | |
| 204 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( | |
| 205 ui::LayerAnimationElement::CreateOpacityElement( | |
| 206 1.0, base::TimeDelta())); | |
| 207 if (observer) | |
|
Nikita (slow)
2012/10/26 10:34:35
nit: same here
| |
| 208 sequence->AddObserver(observer); | |
| 209 window->layer()->GetAnimator()->ScheduleAnimation(sequence); | |
| 167 } | 210 } |
| 168 | 211 |
| 169 // Animation observer that will drop animated foreground once animation is | 212 // Animation observer that will drop animated foreground once animation is |
| 170 // finished. It is used in when undoing shutdown animation. | 213 // finished. It is used in when undoing shutdown animation. |
| 171 class ForegroundDropAnimationObserver : public ui::LayerAnimationObserver { | 214 class CallbackAnimationObserver : public ui::LayerAnimationObserver { |
| 172 public: | 215 public: |
| 173 explicit ForegroundDropAnimationObserver(SessionStateAnimator* animator) | 216 explicit CallbackAnimationObserver(base::Callback<void(void)> &callback) |
| 174 : animator_(animator) { | 217 : callback_(callback) { |
| 175 } | 218 } |
| 176 virtual ~ForegroundDropAnimationObserver() { | 219 virtual ~CallbackAnimationObserver() { |
| 177 } | 220 } |
| 178 | 221 |
| 179 private: | 222 private: |
| 180 // Overridden from ui::LayerAnimationObserver: | 223 // Overridden from ui::LayerAnimationObserver: |
| 181 virtual void OnLayerAnimationEnded(ui::LayerAnimationSequence* seq) | 224 virtual void OnLayerAnimationEnded(ui::LayerAnimationSequence* seq) |
| 182 OVERRIDE { | 225 OVERRIDE { |
| 183 // Drop foreground once animation is over. | 226 // Drop foreground once animation is over. |
| 184 animator_->DropForeground(); | 227 callback_.Run(); |
| 185 delete this; | 228 delete this; |
| 186 } | 229 } |
| 187 | 230 |
| 188 virtual void OnLayerAnimationAborted(ui::LayerAnimationSequence* seq) | 231 virtual void OnLayerAnimationAborted(ui::LayerAnimationSequence* seq) |
| 189 OVERRIDE { | 232 OVERRIDE { |
| 190 // Drop foreground once animation is over. | 233 // Drop foreground once animation is over. |
| 191 animator_->DropForeground(); | 234 callback_.Run(); |
| 192 delete this; | 235 delete this; |
| 193 } | 236 } |
| 194 | 237 |
| 195 virtual void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq) | 238 virtual void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq) |
| 196 OVERRIDE {} | 239 OVERRIDE {} |
| 197 | 240 |
| 198 SessionStateAnimator* animator_; | 241 base::Callback<void(void)> callback_; |
| 199 | 242 |
| 200 DISALLOW_COPY_AND_ASSIGN(ForegroundDropAnimationObserver); | 243 DISALLOW_COPY_AND_ASSIGN(CallbackAnimationObserver); |
| 201 }; | 244 }; |
| 202 | 245 |
| 203 } // namespace | 246 } // namespace |
| 204 | 247 |
| 205 void SessionStateAnimator::TestApi::TriggerHideBlackLayerTimeout() { | 248 void SessionStateAnimator::TestApi::TriggerHideBlackLayerTimeout() { |
| 206 animator_->DropBlackLayer(); | 249 animator_->DropBlackLayer(); |
| 207 animator_->hide_black_layer_timer_.Stop(); | 250 animator_->hide_black_layer_timer_.Stop(); |
| 208 } | 251 } |
| 209 | 252 |
| 210 bool SessionStateAnimator::TestApi::ContainersAreAnimated( | 253 bool SessionStateAnimator::TestApi::ContainersAreAnimated( |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 root_window, | 369 root_window, |
| 327 internal::kShellWindowId_LockScreenRelatedContainersContainer)); | 370 internal::kShellWindowId_LockScreenRelatedContainersContainer)); |
| 328 } | 371 } |
| 329 if (container_mask & LOCK_SCREEN_SYSTEM_FOREGROUND) { | 372 if (container_mask & LOCK_SCREEN_SYSTEM_FOREGROUND) { |
| 330 containers->push_back(Shell::GetContainer( | 373 containers->push_back(Shell::GetContainer( |
| 331 root_window, | 374 root_window, |
| 332 internal::kShellWindowId_PowerButtonAnimationContainer)); | 375 internal::kShellWindowId_PowerButtonAnimationContainer)); |
| 333 } | 376 } |
| 334 } | 377 } |
| 335 | 378 |
| 379 void SessionStateAnimator::StartAnimation(int container_mask, | |
| 380 AnimationType type) { | |
| 381 aura::Window::Windows containers; | |
| 382 GetContainers(container_mask, &containers); | |
| 383 for (aura::Window::Windows::const_iterator it = containers.begin(); | |
| 384 it != containers.end(); ++it) { | |
| 385 RunAnimationForWindow(*it, type, NULL); | |
| 386 } | |
| 387 } | |
| 388 | |
| 336 // Apply animation |type| to all containers described by |container_mask|. | 389 // Apply animation |type| to all containers described by |container_mask|. |
| 337 void SessionStateAnimator::StartAnimation(int container_mask, | 390 void SessionStateAnimator::StartAnimationWithCallback( |
| 338 AnimationType type) { | 391 int container_mask, |
| 392 AnimationType type, | |
| 393 base::Callback<void(void)>& callback) { | |
| 339 aura::Window::Windows containers; | 394 aura::Window::Windows containers; |
| 340 GetContainers(container_mask, &containers); | 395 GetContainers(container_mask, &containers); |
| 341 | |
| 342 for (aura::Window::Windows::const_iterator it = containers.begin(); | 396 for (aura::Window::Windows::const_iterator it = containers.begin(); |
| 343 it != containers.end(); ++it) { | 397 it != containers.end(); ++it) { |
| 344 aura::Window* window = *it; | 398 ui::LayerAnimationObserver* observer = |
| 345 switch (type) { | 399 new CallbackAnimationObserver(callback); |
| 346 case ANIMATION_PARTIAL_CLOSE: | 400 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 } | 401 } |
| 390 } | 402 } |
| 391 | 403 |
| 404 void SessionStateAnimator::RunAnimationForWindow( | |
| 405 aura::Window* window, | |
| 406 AnimationType type, | |
| 407 ui::LayerAnimationObserver* observer) { | |
| 408 switch (type) { | |
| 409 case ANIMATION_PARTIAL_CLOSE: | |
| 410 StartSlowCloseAnimationForWindow(window, observer); | |
| 411 break; | |
| 412 case ANIMATION_UNDO_PARTIAL_CLOSE: | |
| 413 StartUndoSlowCloseAnimationForWindow(window, observer); | |
| 414 break; | |
| 415 case ANIMATION_FULL_CLOSE: | |
| 416 StartFastCloseAnimationForWindow(window, observer); | |
| 417 break; | |
| 418 case ANIMATION_FADE_IN: | |
| 419 FadeInWindow(window, observer); | |
| 420 break; | |
| 421 case ANIMATION_HIDE: | |
| 422 HideWindow(window, observer); | |
| 423 break; | |
| 424 case ANIMATION_RESTORE: | |
| 425 RestoreWindow(window, observer); | |
| 426 break; | |
| 427 case ANIMATION_RAISE: | |
| 428 RaiseWindow(window, | |
| 429 base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs), | |
| 430 observer); | |
| 431 break; | |
| 432 case ANIMATION_LOWER: | |
| 433 LowerWindow(window, | |
| 434 base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs), | |
| 435 observer); | |
| 436 break; | |
| 437 case ANIMATION_PARTIAL_FADE_IN: | |
| 438 StartPartialFadeAnimation(window, kPartialFadeRatio, | |
| 439 base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs), | |
| 440 observer); | |
| 441 break; | |
| 442 case ANIMATION_UNDO_PARTIAL_FADE_IN: | |
| 443 StartPartialFadeAnimation(window, 0.0, | |
| 444 base::TimeDelta::FromMilliseconds(kUndoSlowCloseAnimMs), | |
| 445 observer); | |
| 446 break; | |
| 447 case ANIMATION_FULL_FADE_IN: | |
| 448 StartPartialFadeAnimation(window, 1.0, | |
| 449 base::TimeDelta::FromMilliseconds(kFastCloseAnimMs), | |
| 450 observer); | |
| 451 break; | |
| 452 default: | |
| 453 NOTREACHED() << "Unhandled animation type " << type; | |
| 454 } | |
| 455 } | |
| 456 | |
| 392 void SessionStateAnimator::OnRootWindowResized(const aura::RootWindow* root, | 457 void SessionStateAnimator::OnRootWindowResized(const aura::RootWindow* root, |
| 393 const gfx::Size& new_size) { | 458 const gfx::Size& new_size) { |
| 394 if (black_layer_.get()) | 459 if (black_layer_.get()) |
| 395 black_layer_->SetBounds(gfx::Rect(root->bounds().size())); | 460 black_layer_->SetBounds(gfx::Rect(root->bounds().size())); |
| 396 } | 461 } |
| 397 | 462 |
| 398 void SessionStateAnimator::ShowBlackLayer() { | 463 void SessionStateAnimator::ShowBlackLayer() { |
| 399 if (hide_black_layer_timer_.IsRunning()) | 464 if (hide_black_layer_timer_.IsRunning()) |
| 400 hide_black_layer_timer_.Stop(); | 465 hide_black_layer_timer_.Stop(); |
| 401 | 466 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 422 base::TimeDelta::FromMilliseconds(kUndoSlowCloseAnimMs), | 487 base::TimeDelta::FromMilliseconds(kUndoSlowCloseAnimMs), |
| 423 this, &SessionStateAnimator::DropBlackLayer); | 488 this, &SessionStateAnimator::DropBlackLayer); |
| 424 } | 489 } |
| 425 | 490 |
| 426 void SessionStateAnimator::CreateForeground() { | 491 void SessionStateAnimator::CreateForeground() { |
| 427 if (foreground_.get()) | 492 if (foreground_.get()) |
| 428 return; | 493 return; |
| 429 aura::Window* window = Shell::GetContainer( | 494 aura::Window* window = Shell::GetContainer( |
| 430 Shell::GetPrimaryRootWindow(), | 495 Shell::GetPrimaryRootWindow(), |
| 431 internal::kShellWindowId_PowerButtonAnimationContainer); | 496 internal::kShellWindowId_PowerButtonAnimationContainer); |
| 432 HideWindow(window); | 497 HideWindow(window, NULL); |
| 433 foreground_.reset( | 498 foreground_.reset( |
| 434 new ColoredWindowController(window, "SessionStateAnimatorForeground")); | 499 new ColoredWindowController(window, "SessionStateAnimatorForeground")); |
| 435 foreground_->SetColor(SK_ColorWHITE); | 500 foreground_->SetColor(SK_ColorWHITE); |
| 436 foreground_->GetWidget()->Show(); | 501 foreground_->GetWidget()->Show(); |
| 437 } | 502 } |
| 438 | 503 |
| 439 void SessionStateAnimator::DropForeground() { | 504 void SessionStateAnimator::DropForeground() { |
| 440 foreground_.reset(); | 505 foreground_.reset(); |
| 441 } | 506 } |
| 442 | 507 |
| 443 } // namespace internal | 508 } // namespace internal |
| 444 } // namespace ash | 509 } // namespace ash |
| OLD | NEW |