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/window_animations.h" | 9 #include "ash/wm/window_animations.h" |
| 10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 animator->set_preemption_strategy( | 113 animator->set_preemption_strategy( |
| 114 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 114 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 115 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( | 115 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( |
| 116 ui::LayerAnimationElement::CreateOpacityElement( | 116 ui::LayerAnimationElement::CreateOpacityElement( |
| 117 target_opacity, duration)); | 117 target_opacity, duration)); |
| 118 animator->StartAnimation(sequence); | 118 animator->StartAnimation(sequence); |
| 119 if (observer) | 119 if (observer) |
| 120 sequence->AddObserver(observer); | 120 sequence->AddObserver(observer); |
| 121 } | 121 } |
| 122 | 122 |
| 123 // Fades |window| in to full opacity over |duration|. | 123 // Fades |window| in to |opacity| over |duration|. |
|
Daniel Erat
2012/12/13 05:02:02
nit: s/Fades |window| in to/Fades |window| to/
Denis Kuznetsov (DE-MUC)
2012/12/13 17:59:51
Done.
| |
| 124 void FadeInWindow(aura::Window* window, | 124 void StartOpacityAnimationForWindow(aura::Window* window, |
| 125 base::TimeDelta duration, | 125 float opacity, |
| 126 ui::LayerAnimationObserver* observer) { | 126 base::TimeDelta duration, |
| 127 ui::LayerAnimationObserver* observer) { | |
| 127 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 128 ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| 128 animator->set_preemption_strategy( | 129 animator->set_preemption_strategy( |
| 129 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 130 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 130 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( | 131 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( |
| 131 ui::LayerAnimationElement::CreateOpacityElement(1.0, duration)); | 132 ui::LayerAnimationElement::CreateOpacityElement(opacity, duration)); |
| 132 animator->StartAnimation(sequence); | 133 animator->StartAnimation(sequence); |
| 133 if (observer) | 134 if (observer) |
| 134 sequence->AddObserver(observer); | 135 sequence->AddObserver(observer); |
| 135 } | 136 } |
| 136 | 137 |
| 137 // Makes |window| fully transparent instantaneously. | 138 // Makes |window| fully transparent instantaneously. |
| 138 void HideWindowImmediately(aura::Window* window, | 139 void HideWindowImmediately(aura::Window* window, |
| 139 ui::LayerAnimationObserver* observer) { | 140 ui::LayerAnimationObserver* observer) { |
| 140 window->layer()->SetOpacity(0.0); | 141 window->layer()->SetOpacity(0.0); |
| 141 if (observer) | 142 if (observer) |
| 142 observer->OnLayerAnimationEnded(NULL); | 143 observer->OnLayerAnimationEnded(NULL); |
| 143 } | 144 } |
| 144 | 145 |
| 145 // Restores |window| to its original position and scale and full opacity | 146 // Restores |window| to its original position and scale and full opacity |
| 146 // instantaneously. | 147 // instantaneously. |
| 147 void RestoreWindow(aura::Window* window, ui::LayerAnimationObserver* observer) { | 148 void RestoreWindow(aura::Window* window, ui::LayerAnimationObserver* observer) { |
| 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 bool above, | 157 bool above, |
| 157 ui::LayerAnimationObserver* observer) { | 158 ui::LayerAnimationObserver* observer) { |
| 158 ui::Layer* layer = window->layer(); | 159 ui::Layer* layer = window->layer(); |
| 159 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); | 160 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); |
| 160 | 161 |
| 162 settings.SetPreemptionStrategy( | |
| 163 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | |
| 161 settings.SetTransitionDuration(duration); | 164 settings.SetTransitionDuration(duration); |
| 162 | 165 |
| 163 settings.SetTweenType(ui::Tween::EASE_OUT); | 166 settings.SetTweenType(ui::Tween::EASE_OUT); |
| 164 SetTransformForScaleAnimation(layer, | 167 SetTransformForScaleAnimation(layer, |
| 165 above ? LAYER_SCALE_ANIMATION_ABOVE : LAYER_SCALE_ANIMATION_BELOW); | 168 above ? LAYER_SCALE_ANIMATION_ABOVE : LAYER_SCALE_ANIMATION_BELOW); |
| 166 | 169 |
| 167 settings.SetTweenType(ui::Tween::EASE_IN_OUT); | 170 settings.SetTweenType(ui::Tween::EASE_IN_OUT); |
| 168 layer->SetOpacity(0.0f); | 171 layer->SetOpacity(0.0f); |
| 169 | 172 |
| 170 // After the animation completes snap the transform back to the identity, | 173 // After the animation completes snap the transform back to the identity, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 181 // it does not call NotifyEnded(). | 184 // it does not call NotifyEnded(). |
| 182 if (observer) { | 185 if (observer) { |
| 183 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( | 186 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( |
| 184 ui::LayerAnimationElement::CreateOpacityElement( | 187 ui::LayerAnimationElement::CreateOpacityElement( |
| 185 0.0, base::TimeDelta())); | 188 0.0, base::TimeDelta())); |
| 186 sequence->AddObserver(observer); | 189 sequence->AddObserver(observer); |
| 187 layer->GetAnimator()->ScheduleAnimation(sequence); | 190 layer->GetAnimator()->ScheduleAnimation(sequence); |
| 188 } | 191 } |
| 189 } | 192 } |
| 190 | 193 |
| 191 void ShowWindow(aura::Window* window, | 194 void TransformWindowToBaseState(aura::Window* window, |
| 192 base::TimeDelta duration, | 195 base::TimeDelta duration, |
| 193 bool above, | 196 ui::LayerAnimationObserver* observer) { |
| 194 ui::LayerAnimationObserver* observer) { | |
| 195 ui::Layer* layer = window->layer(); | 197 ui::Layer* layer = window->layer(); |
| 196 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); | 198 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); |
| 197 | 199 |
| 198 // Set initial state of animation | |
| 199 settings.SetTransitionDuration(base::TimeDelta()); | |
| 200 SetTransformForScaleAnimation(layer, | |
| 201 above ? LAYER_SCALE_ANIMATION_ABOVE : LAYER_SCALE_ANIMATION_BELOW); | |
| 202 | |
| 203 // Animate to target values. | 200 // Animate to target values. |
| 201 settings.SetPreemptionStrategy( | |
| 202 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | |
| 204 settings.SetTransitionDuration(duration); | 203 settings.SetTransitionDuration(duration); |
| 205 | 204 |
| 206 settings.SetTweenType(ui::Tween::EASE_OUT); | 205 settings.SetTweenType(ui::Tween::EASE_OUT); |
| 207 layer->SetTransform(gfx::Transform()); | 206 layer->SetTransform(gfx::Transform()); |
| 208 | 207 |
| 209 settings.SetTweenType(ui::Tween::EASE_IN_OUT); | 208 settings.SetTweenType(ui::Tween::EASE_IN_OUT); |
| 210 layer->SetOpacity(1.0f); | 209 layer->SetOpacity(1.0f); |
| 211 | 210 |
| 212 // A bit of a dirty trick: we need to catch the end of the animation we don't | 211 // A bit of a dirty trick: we need to catch the end of the animation we don't |
| 213 // control. So we use two facts we know: which animator will be used and the | 212 // control. So we use two facts we know: which animator will be used and the |
| 214 // target opacity to add "Do nothing" animation sequence. | 213 // target opacity to add "Do nothing" animation sequence. |
| 215 // Unfortunately, we can not just use empty LayerAnimationSequence, because | 214 // Unfortunately, we can not just use empty LayerAnimationSequence, because |
| 216 // it does not call NotifyEnded(). | 215 // it does not call NotifyEnded(). |
| 217 if (observer) { | 216 if (observer) { |
| 218 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( | 217 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( |
| 219 ui::LayerAnimationElement::CreateOpacityElement( | 218 ui::LayerAnimationElement::CreateOpacityElement( |
| 220 1.0, base::TimeDelta())); | 219 1.0, base::TimeDelta())); |
| 221 sequence->AddObserver(observer); | 220 sequence->AddObserver(observer); |
| 222 layer->GetAnimator()->ScheduleAnimation(sequence); | 221 layer->GetAnimator()->ScheduleAnimation(sequence); |
| 223 } | 222 } |
| 224 } | 223 } |
| 225 | 224 |
| 225 void ShowWindow(aura::Window* window, | |
| 226 base::TimeDelta duration, | |
| 227 bool above, | |
| 228 ui::LayerAnimationObserver* observer) { | |
| 229 ui::Layer* layer = window->layer(); | |
| 230 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); | |
| 231 | |
| 232 // Set initial state of animation | |
| 233 settings.SetPreemptionStrategy( | |
| 234 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | |
| 235 settings.SetTransitionDuration(base::TimeDelta()); | |
| 236 SetTransformForScaleAnimation(layer, | |
| 237 above ? LAYER_SCALE_ANIMATION_ABOVE : LAYER_SCALE_ANIMATION_BELOW); | |
| 238 | |
| 239 TransformWindowToBaseState(window, duration, observer); | |
| 240 } | |
| 241 | |
| 226 // Starts grayscale/brightness animation for |window| over |duration|. Target | 242 // Starts grayscale/brightness animation for |window| over |duration|. Target |
| 227 // value for both grayscale and brightness are specified by |target|. | 243 // value for both grayscale and brightness are specified by |target|. |
| 228 void StartGrayscaleBrightnessAnimationForWindow( | 244 void StartGrayscaleBrightnessAnimationForWindow( |
| 229 aura::Window* window, | 245 aura::Window* window, |
| 230 float target, | 246 float target, |
| 231 base::TimeDelta duration, | 247 base::TimeDelta duration, |
| 232 ui::LayerAnimationObserver* observer) { | 248 ui::LayerAnimationObserver* observer) { |
| 233 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 249 ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| 234 | 250 |
| 235 std::vector<ui::LayerAnimationSequence*> animations = | 251 scoped_ptr<ui::LayerAnimationSequence> brightness_sequence( |
| 236 CreateBrightnessGrayscaleAnimationSequence(target, duration); | 252 new ui::LayerAnimationSequence()); |
| 253 scoped_ptr<ui::LayerAnimationSequence> grayscale_sequence( | |
| 254 new ui::LayerAnimationSequence()); | |
| 255 | |
| 256 scoped_ptr<ui::LayerAnimationElement> brightness_element( | |
| 257 ui::LayerAnimationElement::CreateBrightnessElement( | |
| 258 target, duration)); | |
| 259 brightness_element->set_tween_type(ui::Tween::EASE_IN); | |
| 260 brightness_sequence->AddElement(brightness_element.release()); | |
| 261 | |
| 262 scoped_ptr<ui::LayerAnimationElement> grayscale_element( | |
| 263 ui::LayerAnimationElement::CreateGrayscaleElement( | |
| 264 target, duration)); | |
| 265 grayscale_element->set_tween_type(ui::Tween::EASE_IN); | |
| 266 grayscale_sequence->AddElement(grayscale_element.release()); | |
| 267 | |
| 268 std::vector<ui::LayerAnimationSequence*> animations; | |
| 269 animations.push_back(brightness_sequence.release()); | |
| 270 animations.push_back(grayscale_sequence.release()); | |
| 237 | 271 |
| 238 if (observer) | 272 if (observer) |
| 239 animations[0]->AddObserver(observer); | 273 animations[0]->AddObserver(observer); |
| 240 | 274 |
| 241 animator->set_preemption_strategy( | 275 animator->set_preemption_strategy( |
| 242 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 276 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 243 | 277 |
| 244 animator->StartTogether(animations); | 278 animator->StartTogether(animations); |
| 245 } | 279 } |
| 246 | 280 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 292 break; | 326 break; |
| 293 case SessionStateAnimator::ANIMATION_FULL_CLOSE: | 327 case SessionStateAnimator::ANIMATION_FULL_CLOSE: |
| 294 if (layer->GetTargetTransform() != GetFastCloseTransform() || | 328 if (layer->GetTargetTransform() != GetFastCloseTransform() || |
| 295 layer->GetTargetOpacity() > 0.0001) | 329 layer->GetTargetOpacity() > 0.0001) |
| 296 return false; | 330 return false; |
| 297 break; | 331 break; |
| 298 case SessionStateAnimator::ANIMATION_FADE_IN: | 332 case SessionStateAnimator::ANIMATION_FADE_IN: |
| 299 if (layer->GetTargetOpacity() < 0.9999) | 333 if (layer->GetTargetOpacity() < 0.9999) |
| 300 return false; | 334 return false; |
| 301 break; | 335 break; |
| 336 case SessionStateAnimator::ANIMATION_FADE_OUT: | |
| 337 if (layer->GetTargetOpacity() > 0.0001) | |
| 338 return false; | |
| 339 break; | |
| 302 case SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY: | 340 case SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY: |
| 303 if (layer->GetTargetOpacity() > 0.0001) | 341 if (layer->GetTargetOpacity() > 0.0001) |
| 304 return false; | 342 return false; |
| 305 break; | 343 break; |
| 306 case SessionStateAnimator::ANIMATION_RESTORE: | 344 case SessionStateAnimator::ANIMATION_RESTORE: |
| 307 if (layer->opacity() < 0.9999 || layer->transform() != gfx::Transform()) | 345 if (layer->opacity() < 0.9999 || layer->transform() != gfx::Transform()) |
| 308 return false; | 346 return false; |
| 309 break; | 347 break; |
| 310 case SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS: | 348 case SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS: |
| 311 if ((layer->GetTargetBrightness() < 0.9999) || | 349 if ((layer->GetTargetBrightness() < 0.9999) || |
| 312 (layer->GetTargetGrayscale() < 0.9999)) | 350 (layer->GetTargetGrayscale() < 0.9999)) |
| 313 return false; | 351 return false; |
| 314 break; | 352 break; |
| 315 case SessionStateAnimator::ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS: | 353 case SessionStateAnimator::ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS: |
| 316 if ((layer->GetTargetBrightness() > 0.0001) || | 354 if ((layer->GetTargetBrightness() > 0.0001) || |
| 317 (layer->GetTargetGrayscale() > 0.0001)) | 355 (layer->GetTargetGrayscale() > 0.0001)) |
| 318 return false; | 356 return false; |
| 319 break; | 357 break; |
| 320 case SessionStateAnimator::ANIMATION_DROP: | 358 case SessionStateAnimator::ANIMATION_DROP: |
| 359 case SessionStateAnimator::ANIMATION_UNDO_LIFT: | |
| 321 //ToDo(antim) : check other effects | 360 //ToDo(antim) : check other effects |
| 322 if (layer->GetTargetOpacity() < 0.9999) | 361 if (layer->GetTargetOpacity() < 0.9999) |
| 323 return false; | 362 return false; |
| 324 break; | 363 break; |
| 325 //ToDo(antim) : check other effects | 364 //ToDo(antim) : check other effects |
| 326 case SessionStateAnimator::ANIMATION_LIFT: | 365 case SessionStateAnimator::ANIMATION_LIFT: |
| 327 if (layer->GetTargetOpacity() > 0.0001) | 366 if (layer->GetTargetOpacity() > 0.0001) |
| 328 return false; | 367 return false; |
| 329 break; | 368 break; |
| 330 case SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN: | 369 case SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN: |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 SessionStateAnimator::~SessionStateAnimator() { | 423 SessionStateAnimator::~SessionStateAnimator() { |
| 385 } | 424 } |
| 386 | 425 |
| 387 base::TimeDelta SessionStateAnimator::GetDuration(AnimationSpeed speed) { | 426 base::TimeDelta SessionStateAnimator::GetDuration(AnimationSpeed speed) { |
| 388 switch (speed) { | 427 switch (speed) { |
| 389 case ANIMATION_SPEED_IMMEDIATE: | 428 case ANIMATION_SPEED_IMMEDIATE: |
| 390 return base::TimeDelta(); | 429 return base::TimeDelta(); |
| 391 case ANIMATION_SPEED_UNDOABLE: | 430 case ANIMATION_SPEED_UNDOABLE: |
| 392 return base::TimeDelta::FromMilliseconds(400); | 431 return base::TimeDelta::FromMilliseconds(400); |
| 393 case ANIMATION_SPEED_REVERT: | 432 case ANIMATION_SPEED_REVERT: |
| 394 return base::TimeDelta::FromMilliseconds(100); | 433 return base::TimeDelta::FromMilliseconds(150); |
| 395 case ANIMATION_SPEED_FAST: | 434 case ANIMATION_SPEED_FAST: |
| 396 return base::TimeDelta::FromMilliseconds(150); | 435 return base::TimeDelta::FromMilliseconds(150); |
| 397 case ANIMATION_SPEED_SHOW_LOCK_SCREEN: | 436 case ANIMATION_SPEED_SHOW_LOCK_SCREEN: |
| 398 return base::TimeDelta::FromMilliseconds(200); | 437 return base::TimeDelta::FromMilliseconds(200); |
| 399 case ANIMATION_SPEED_MOVE_WINDOWS: | 438 case ANIMATION_SPEED_MOVE_WINDOWS: |
| 400 return base::TimeDelta::FromMilliseconds(400); | 439 return base::TimeDelta::FromMilliseconds(350); |
| 401 case ANIMATION_SPEED_UNDO_MOVE_WINDOWS: | 440 case ANIMATION_SPEED_UNDO_MOVE_WINDOWS: |
| 402 return base::TimeDelta::FromMilliseconds(600); | 441 return base::TimeDelta::FromMilliseconds(500); |
| 403 case ANIMATION_SPEED_SHUTDOWN: | 442 case ANIMATION_SPEED_SHUTDOWN: |
| 404 return base::TimeDelta::FromMilliseconds(1000); | 443 return base::TimeDelta::FromMilliseconds(1000); |
| 405 case ANIMATION_SPEED_REVERT_SHUTDOWN: | 444 case ANIMATION_SPEED_REVERT_SHUTDOWN: |
| 406 return base::TimeDelta::FromMilliseconds(1500); | 445 return base::TimeDelta::FromMilliseconds(1500); |
| 407 } | 446 } |
| 408 // Satisfy compilers that do not understand that we will return from switch | 447 // Satisfy compilers that do not understand that we will return from switch |
| 409 // above anyway. | 448 // above anyway. |
| 410 DCHECK(false) << "Unhandled animation speed " << speed; | 449 DCHECK(false) << "Unhandled animation speed " << speed; |
| 411 return base::TimeDelta(); | 450 return base::TimeDelta(); |
| 412 } | 451 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 451 if (container_mask & LOCK_SCREEN_CONTAINERS) { | 490 if (container_mask & LOCK_SCREEN_CONTAINERS) { |
| 452 containers->push_back(Shell::GetContainer( | 491 containers->push_back(Shell::GetContainer( |
| 453 root_window, | 492 root_window, |
| 454 internal::kShellWindowId_LockScreenContainersContainer)); | 493 internal::kShellWindowId_LockScreenContainersContainer)); |
| 455 } | 494 } |
| 456 if (container_mask & LOCK_SCREEN_RELATED_CONTAINERS) { | 495 if (container_mask & LOCK_SCREEN_RELATED_CONTAINERS) { |
| 457 containers->push_back(Shell::GetContainer( | 496 containers->push_back(Shell::GetContainer( |
| 458 root_window, | 497 root_window, |
| 459 internal::kShellWindowId_LockScreenRelatedContainersContainer)); | 498 internal::kShellWindowId_LockScreenRelatedContainersContainer)); |
| 460 } | 499 } |
| 461 if (container_mask & LOCK_SCREEN_SYSTEM_FOREGROUND) { | |
| 462 containers->push_back(Shell::GetContainer( | |
| 463 root_window, | |
| 464 internal::kShellWindowId_PowerButtonAnimationContainer)); | |
| 465 } | |
| 466 } | 500 } |
| 467 | 501 |
| 468 void SessionStateAnimator::StartAnimation(int container_mask, | 502 void SessionStateAnimator::StartAnimation(int container_mask, |
| 469 AnimationType type, | 503 AnimationType type, |
| 470 AnimationSpeed speed) { | 504 AnimationSpeed speed) { |
| 471 aura::Window::Windows containers; | 505 aura::Window::Windows containers; |
| 472 GetContainers(container_mask, &containers); | 506 GetContainers(container_mask, &containers); |
| 473 for (aura::Window::Windows::const_iterator it = containers.begin(); | 507 for (aura::Window::Windows::const_iterator it = containers.begin(); |
| 474 it != containers.end(); ++it) { | 508 it != containers.end(); ++it) { |
| 475 RunAnimationForWindow(*it, type, speed, NULL); | 509 RunAnimationForWindow(*it, type, speed, NULL); |
| 476 } | 510 } |
| 477 } | 511 } |
| 478 | 512 |
| 479 // Apply animation |type| to all containers described by |container_mask|. | 513 // Apply animation |type| to all containers described by |container_mask|. |
|
Daniel Erat
2012/12/13 05:02:02
nit: delete this comment; it should be in the head
Denis Kuznetsov (DE-MUC)
2012/12/13 17:59:51
Done.
| |
| 480 void SessionStateAnimator::StartAnimationWithCallback( | 514 void SessionStateAnimator::StartAnimationWithCallback( |
| 481 int container_mask, | 515 int container_mask, |
| 482 AnimationType type, | 516 AnimationType type, |
| 483 AnimationSpeed speed, | 517 AnimationSpeed speed, |
| 484 base::Callback<void(void)>& callback) { | 518 base::Callback<void(void)>& callback) { |
| 485 aura::Window::Windows containers; | 519 aura::Window::Windows containers; |
| 486 GetContainers(container_mask, &containers); | 520 GetContainers(container_mask, &containers); |
| 487 for (aura::Window::Windows::const_iterator it = containers.begin(); | 521 for (aura::Window::Windows::const_iterator it = containers.begin(); |
| 488 it != containers.end(); ++it) { | 522 it != containers.end(); ++it) { |
| 489 ui::LayerAnimationObserver* observer = | 523 ui::LayerAnimationObserver* observer = |
| 490 new CallbackAnimationObserver(callback); | 524 new CallbackAnimationObserver(callback); |
| 491 RunAnimationForWindow(*it, type, speed, observer); | 525 RunAnimationForWindow(*it, type, speed, observer); |
| 492 } | 526 } |
| 493 } | 527 } |
| 494 | 528 |
| 529 void SessionStateAnimator::StartAnimationWithObserver( | |
|
Daniel Erat
2012/12/13 05:02:02
this is almost exactly the same as StartAnimationW
| |
| 530 int container_mask, | |
| 531 AnimationType type, | |
| 532 AnimationSpeed speed, | |
| 533 ui::LayerAnimationObserver* observer) { | |
| 534 aura::Window::Windows containers; | |
| 535 GetContainers(container_mask, &containers); | |
| 536 for (aura::Window::Windows::const_iterator it = containers.begin(); | |
| 537 it != containers.end(); ++it) { | |
| 538 RunAnimationForWindow(*it, type, speed, observer); | |
| 539 } | |
| 540 } | |
| 541 | |
| 495 void SessionStateAnimator::StartGlobalAnimation(AnimationType type, | 542 void SessionStateAnimator::StartGlobalAnimation(AnimationType type, |
| 496 AnimationSpeed speed) { | 543 AnimationSpeed speed) { |
| 497 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); | 544 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); |
| 498 RunAnimationForWindow(root_window, type, speed, NULL); | 545 RunAnimationForWindow(root_window, type, speed, NULL); |
| 499 } | 546 } |
| 500 | 547 |
| 501 void SessionStateAnimator::RunAnimationForWindow( | 548 void SessionStateAnimator::RunAnimationForWindow( |
| 502 aura::Window* window, | 549 aura::Window* window, |
| 503 AnimationType type, | 550 AnimationType type, |
| 504 AnimationSpeed speed, | 551 AnimationSpeed speed, |
| 505 ui::LayerAnimationObserver* observer) { | 552 ui::LayerAnimationObserver* observer) { |
| 506 base::TimeDelta duration = GetDuration(speed); | 553 base::TimeDelta duration = GetDuration(speed); |
| 507 | 554 |
| 508 switch (type) { | 555 switch (type) { |
| 509 case ANIMATION_PARTIAL_CLOSE: | 556 case ANIMATION_PARTIAL_CLOSE: |
| 510 StartSlowCloseAnimationForWindow(window, duration, observer); | 557 StartSlowCloseAnimationForWindow(window, duration, observer); |
| 511 break; | 558 break; |
| 512 case ANIMATION_UNDO_PARTIAL_CLOSE: | 559 case ANIMATION_UNDO_PARTIAL_CLOSE: |
| 513 StartUndoSlowCloseAnimationForWindow(window, duration, observer); | 560 StartUndoSlowCloseAnimationForWindow(window, duration, observer); |
| 514 break; | 561 break; |
| 515 case ANIMATION_FULL_CLOSE: | 562 case ANIMATION_FULL_CLOSE: |
| 516 StartFastCloseAnimationForWindow(window, duration, observer); | 563 StartFastCloseAnimationForWindow(window, duration, observer); |
| 517 break; | 564 break; |
| 518 case ANIMATION_FADE_IN: | 565 case ANIMATION_FADE_IN: |
| 519 FadeInWindow(window, duration, observer); | 566 StartOpacityAnimationForWindow(window, 1.0, duration, observer); |
| 567 break; | |
| 568 case ANIMATION_FADE_OUT: | |
| 569 StartOpacityAnimationForWindow(window, 0.0, duration, observer); | |
| 520 break; | 570 break; |
| 521 case ANIMATION_HIDE_IMMEDIATELY: | 571 case ANIMATION_HIDE_IMMEDIATELY: |
| 522 DCHECK_EQ(speed, ANIMATION_SPEED_IMMEDIATE); | 572 DCHECK_EQ(speed, ANIMATION_SPEED_IMMEDIATE); |
| 523 HideWindowImmediately(window, observer); | 573 HideWindowImmediately(window, observer); |
| 524 break; | 574 break; |
| 525 case ANIMATION_RESTORE: | 575 case ANIMATION_RESTORE: |
| 526 DCHECK_EQ(speed, ANIMATION_SPEED_IMMEDIATE); | 576 DCHECK_EQ(speed, ANIMATION_SPEED_IMMEDIATE); |
| 527 RestoreWindow(window, observer); | 577 RestoreWindow(window, observer); |
| 528 break; | 578 break; |
| 529 case ANIMATION_LIFT: | 579 case ANIMATION_LIFT: |
| 530 HideWindow(window, duration, true, observer); | 580 HideWindow(window, duration, true, observer); |
| 531 break; | 581 break; |
| 532 case ANIMATION_DROP: | 582 case ANIMATION_DROP: |
| 533 ShowWindow(window, duration, true, observer); | 583 ShowWindow(window, duration, true, observer); |
| 534 break; | 584 break; |
| 585 case ANIMATION_UNDO_LIFT: | |
| 586 TransformWindowToBaseState(window, duration, observer); | |
| 587 break; | |
| 535 case ANIMATION_RAISE_TO_SCREEN: | 588 case ANIMATION_RAISE_TO_SCREEN: |
| 536 ShowWindow(window, duration, false, observer); | 589 ShowWindow(window, duration, false, observer); |
| 537 break; | 590 break; |
| 538 case ANIMATION_LOWER_BELOW_SCREEN: | 591 case ANIMATION_LOWER_BELOW_SCREEN: |
| 539 HideWindow(window, duration, false, observer); | 592 HideWindow(window, duration, false, observer); |
| 540 break; | 593 break; |
| 541 case ANIMATION_PARTIAL_FADE_IN: | 594 case ANIMATION_PARTIAL_FADE_IN: |
| 542 StartPartialFadeAnimation( | 595 StartPartialFadeAnimation( |
| 543 window, kPartialFadeRatio, duration, observer); | 596 window, kPartialFadeRatio, duration, observer); |
| 544 break; | 597 break; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 571 foreground_->SetColor(SK_ColorWHITE); | 624 foreground_->SetColor(SK_ColorWHITE); |
| 572 foreground_->GetWidget()->Show(); | 625 foreground_->GetWidget()->Show(); |
| 573 } | 626 } |
| 574 | 627 |
| 575 void SessionStateAnimator::DropForeground() { | 628 void SessionStateAnimator::DropForeground() { |
| 576 foreground_.reset(); | 629 foreground_.reset(); |
| 577 } | 630 } |
| 578 | 631 |
| 579 } // namespace internal | 632 } // namespace internal |
| 580 } // namespace ash | 633 } // namespace ash |
| OLD | NEW |