| 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_impl.h" | 5 #include "ash/wm/session_state_animator_impl.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/common/shell_window_ids.h" | 9 #include "ash/common/shell_window_ids.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 } | 61 } |
| 62 | 62 |
| 63 // Slowly shrinks |window| to a slightly-smaller size. | 63 // Slowly shrinks |window| to a slightly-smaller size. |
| 64 void StartSlowCloseAnimationForWindow(aura::Window* window, | 64 void StartSlowCloseAnimationForWindow(aura::Window* window, |
| 65 base::TimeDelta duration, | 65 base::TimeDelta duration, |
| 66 ui::LayerAnimationObserver* observer) { | 66 ui::LayerAnimationObserver* observer) { |
| 67 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 67 ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| 68 animator->set_preemption_strategy( | 68 animator->set_preemption_strategy( |
| 69 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 69 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 70 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( | 70 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( |
| 71 ui::LayerAnimationElement::CreateTransformElement( | 71 ui::LayerAnimationElement::CreateTransformElement(GetSlowCloseTransform(), |
| 72 GetSlowCloseTransform(), | 72 duration)); |
| 73 duration)); | |
| 74 if (observer) | 73 if (observer) |
| 75 sequence->AddObserver(observer); | 74 sequence->AddObserver(observer); |
| 76 animator->StartAnimation(sequence); | 75 animator->StartAnimation(sequence); |
| 77 } | 76 } |
| 78 | 77 |
| 79 // Quickly undoes the effects of the slow-close animation on |window|. | 78 // Quickly undoes the effects of the slow-close animation on |window|. |
| 80 void StartUndoSlowCloseAnimationForWindow( | 79 void StartUndoSlowCloseAnimationForWindow( |
| 81 aura::Window* window, | 80 aura::Window* window, |
| 82 base::TimeDelta duration, | 81 base::TimeDelta duration, |
| 83 ui::LayerAnimationObserver* observer) { | 82 ui::LayerAnimationObserver* observer) { |
| 84 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 83 ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| 85 animator->set_preemption_strategy( | 84 animator->set_preemption_strategy( |
| 86 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 85 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 87 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( | 86 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( |
| 88 ui::LayerAnimationElement::CreateTransformElement( | 87 ui::LayerAnimationElement::CreateTransformElement(gfx::Transform(), |
| 89 gfx::Transform(), | 88 duration)); |
| 90 duration)); | |
| 91 if (observer) | 89 if (observer) |
| 92 sequence->AddObserver(observer); | 90 sequence->AddObserver(observer); |
| 93 animator->StartAnimation(sequence); | 91 animator->StartAnimation(sequence); |
| 94 } | 92 } |
| 95 | 93 |
| 96 // Quickly shrinks |window| down to a point in the center of the screen and | 94 // Quickly shrinks |window| down to a point in the center of the screen and |
| 97 // fades it out to 0 opacity. | 95 // fades it out to 0 opacity. |
| 98 void StartFastCloseAnimationForWindow(aura::Window* window, | 96 void StartFastCloseAnimationForWindow(aura::Window* window, |
| 99 base::TimeDelta duration, | 97 base::TimeDelta duration, |
| 100 ui::LayerAnimationObserver* observer) { | 98 ui::LayerAnimationObserver* observer) { |
| 101 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 99 ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| 102 animator->set_preemption_strategy( | 100 animator->set_preemption_strategy( |
| 103 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 101 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 104 animator->StartAnimation( | 102 animator->StartAnimation(new ui::LayerAnimationSequence( |
| 105 new ui::LayerAnimationSequence( | 103 ui::LayerAnimationElement::CreateTransformElement(GetFastCloseTransform(), |
| 106 ui::LayerAnimationElement::CreateTransformElement( | 104 duration))); |
| 107 GetFastCloseTransform(), duration))); | |
| 108 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( | 105 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( |
| 109 ui::LayerAnimationElement::CreateOpacityElement(0.0, duration)); | 106 ui::LayerAnimationElement::CreateOpacityElement(0.0, duration)); |
| 110 if (observer) | 107 if (observer) |
| 111 sequence->AddObserver(observer); | 108 sequence->AddObserver(observer); |
| 112 animator->StartAnimation(sequence); | 109 animator->StartAnimation(sequence); |
| 113 } | 110 } |
| 114 | 111 |
| 115 // Fades |window| to |target_opacity| over |duration|. | 112 // Fades |window| to |target_opacity| over |duration|. |
| 116 void StartPartialFadeAnimation(aura::Window* window, | 113 void StartPartialFadeAnimation(aura::Window* window, |
| 117 float target_opacity, | 114 float target_opacity, |
| 118 base::TimeDelta duration, | 115 base::TimeDelta duration, |
| 119 ui::LayerAnimationObserver* observer) { | 116 ui::LayerAnimationObserver* observer) { |
| 120 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 117 ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| 121 animator->set_preemption_strategy( | 118 animator->set_preemption_strategy( |
| 122 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 119 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 123 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( | 120 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( |
| 124 ui::LayerAnimationElement::CreateOpacityElement( | 121 ui::LayerAnimationElement::CreateOpacityElement(target_opacity, |
| 125 target_opacity, duration)); | 122 duration)); |
| 126 if (observer) | 123 if (observer) |
| 127 sequence->AddObserver(observer); | 124 sequence->AddObserver(observer); |
| 128 animator->StartAnimation(sequence); | 125 animator->StartAnimation(sequence); |
| 129 } | 126 } |
| 130 | 127 |
| 131 // Fades |window| to |opacity| over |duration|. | 128 // Fades |window| to |opacity| over |duration|. |
| 132 void StartOpacityAnimationForWindow(aura::Window* window, | 129 void StartOpacityAnimationForWindow(aura::Window* window, |
| 133 float opacity, | 130 float opacity, |
| 134 base::TimeDelta duration, | 131 base::TimeDelta duration, |
| 135 ui::LayerAnimationObserver* observer) { | 132 ui::LayerAnimationObserver* observer) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 165 bool above, | 162 bool above, |
| 166 ui::LayerAnimationObserver* observer) { | 163 ui::LayerAnimationObserver* observer) { |
| 167 ui::Layer* layer = window->layer(); | 164 ui::Layer* layer = window->layer(); |
| 168 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); | 165 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); |
| 169 | 166 |
| 170 settings.SetPreemptionStrategy( | 167 settings.SetPreemptionStrategy( |
| 171 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 168 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 172 settings.SetTransitionDuration(duration); | 169 settings.SetTransitionDuration(duration); |
| 173 | 170 |
| 174 settings.SetTweenType(gfx::Tween::EASE_OUT); | 171 settings.SetTweenType(gfx::Tween::EASE_OUT); |
| 175 SetTransformForScaleAnimation(layer, | 172 SetTransformForScaleAnimation( |
| 176 above ? LAYER_SCALE_ANIMATION_ABOVE : LAYER_SCALE_ANIMATION_BELOW); | 173 layer, above ? LAYER_SCALE_ANIMATION_ABOVE : LAYER_SCALE_ANIMATION_BELOW); |
| 177 | 174 |
| 178 settings.SetTweenType(gfx::Tween::EASE_IN_OUT); | 175 settings.SetTweenType(gfx::Tween::EASE_IN_OUT); |
| 179 layer->SetOpacity(0.0f); | 176 layer->SetOpacity(0.0f); |
| 180 | 177 |
| 181 // After the animation completes snap the transform back to the identity, | 178 // After the animation completes snap the transform back to the identity, |
| 182 // otherwise any one that asks for screen bounds gets a slightly scaled | 179 // otherwise any one that asks for screen bounds gets a slightly scaled |
| 183 // version. | 180 // version. |
| 184 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); | 181 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); |
| 185 settings.SetTransitionDuration(base::TimeDelta()); | 182 settings.SetTransitionDuration(base::TimeDelta()); |
| 186 layer->SetTransform(gfx::Transform()); | 183 layer->SetTransform(gfx::Transform()); |
| 187 | 184 |
| 188 // A bit of a dirty trick: we need to catch the end of the animation we don't | 185 // A bit of a dirty trick: we need to catch the end of the animation we don't |
| 189 // control. So we use two facts we know: which animator will be used and the | 186 // control. So we use two facts we know: which animator will be used and the |
| 190 // target opacity to add "Do nothing" animation sequence. | 187 // target opacity to add "Do nothing" animation sequence. |
| 191 // Unfortunately, we can not just use empty LayerAnimationSequence, because | 188 // Unfortunately, we can not just use empty LayerAnimationSequence, because |
| 192 // it does not call NotifyEnded(). | 189 // it does not call NotifyEnded(). |
| 193 if (observer) { | 190 if (observer) { |
| 194 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( | 191 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( |
| 195 ui::LayerAnimationElement::CreateOpacityElement( | 192 ui::LayerAnimationElement::CreateOpacityElement(0.0, |
| 196 0.0, base::TimeDelta())); | 193 base::TimeDelta())); |
| 197 sequence->AddObserver(observer); | 194 sequence->AddObserver(observer); |
| 198 layer->GetAnimator()->ScheduleAnimation(sequence); | 195 layer->GetAnimator()->ScheduleAnimation(sequence); |
| 199 } | 196 } |
| 200 } | 197 } |
| 201 | 198 |
| 202 // Animates |window| to identity transform and full opacity over |duration|. | 199 // Animates |window| to identity transform and full opacity over |duration|. |
| 203 void TransformWindowToBaseState(aura::Window* window, | 200 void TransformWindowToBaseState(aura::Window* window, |
| 204 base::TimeDelta duration, | 201 base::TimeDelta duration, |
| 205 ui::LayerAnimationObserver* observer) { | 202 ui::LayerAnimationObserver* observer) { |
| 206 ui::Layer* layer = window->layer(); | 203 ui::Layer* layer = window->layer(); |
| 207 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); | 204 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); |
| 208 | 205 |
| 209 // Animate to target values. | 206 // Animate to target values. |
| 210 settings.SetPreemptionStrategy( | 207 settings.SetPreemptionStrategy( |
| 211 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 208 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 212 settings.SetTransitionDuration(duration); | 209 settings.SetTransitionDuration(duration); |
| 213 | 210 |
| 214 settings.SetTweenType(gfx::Tween::EASE_OUT); | 211 settings.SetTweenType(gfx::Tween::EASE_OUT); |
| 215 layer->SetTransform(gfx::Transform()); | 212 layer->SetTransform(gfx::Transform()); |
| 216 | 213 |
| 217 settings.SetTweenType(gfx::Tween::EASE_IN_OUT); | 214 settings.SetTweenType(gfx::Tween::EASE_IN_OUT); |
| 218 layer->SetOpacity(1.0f); | 215 layer->SetOpacity(1.0f); |
| 219 | 216 |
| 220 // 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 |
| 221 // 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 |
| 222 // target opacity to add "Do nothing" animation sequence. | 219 // target opacity to add "Do nothing" animation sequence. |
| 223 // Unfortunately, we can not just use empty LayerAnimationSequence, because | 220 // Unfortunately, we can not just use empty LayerAnimationSequence, because |
| 224 // it does not call NotifyEnded(). | 221 // it does not call NotifyEnded(). |
| 225 if (observer) { | 222 if (observer) { |
| 226 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( | 223 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( |
| 227 ui::LayerAnimationElement::CreateOpacityElement( | 224 ui::LayerAnimationElement::CreateOpacityElement(1.0, |
| 228 1.0, base::TimeDelta())); | 225 base::TimeDelta())); |
| 229 sequence->AddObserver(observer); | 226 sequence->AddObserver(observer); |
| 230 layer->GetAnimator()->ScheduleAnimation(sequence); | 227 layer->GetAnimator()->ScheduleAnimation(sequence); |
| 231 } | 228 } |
| 232 } | 229 } |
| 233 | 230 |
| 234 void ShowWindow(aura::Window* window, | 231 void ShowWindow(aura::Window* window, |
| 235 base::TimeDelta duration, | 232 base::TimeDelta duration, |
| 236 bool above, | 233 bool above, |
| 237 ui::LayerAnimationObserver* observer) { | 234 ui::LayerAnimationObserver* observer) { |
| 238 ui::Layer* layer = window->layer(); | 235 ui::Layer* layer = window->layer(); |
| 239 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); | 236 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); |
| 240 | 237 |
| 241 // Set initial state of animation | 238 // Set initial state of animation |
| 242 settings.SetPreemptionStrategy( | 239 settings.SetPreemptionStrategy( |
| 243 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 240 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 244 settings.SetTransitionDuration(base::TimeDelta()); | 241 settings.SetTransitionDuration(base::TimeDelta()); |
| 245 SetTransformForScaleAnimation(layer, | 242 SetTransformForScaleAnimation( |
| 246 above ? LAYER_SCALE_ANIMATION_ABOVE : LAYER_SCALE_ANIMATION_BELOW); | 243 layer, above ? LAYER_SCALE_ANIMATION_ABOVE : LAYER_SCALE_ANIMATION_BELOW); |
| 247 | 244 |
| 248 TransformWindowToBaseState(window, duration, observer); | 245 TransformWindowToBaseState(window, duration, observer); |
| 249 } | 246 } |
| 250 | 247 |
| 251 // Starts grayscale/brightness animation for |window| over |duration|. Target | 248 // Starts grayscale/brightness animation for |window| over |duration|. Target |
| 252 // value for both grayscale and brightness are specified by |target|. | 249 // value for both grayscale and brightness are specified by |target|. |
| 253 void StartGrayscaleBrightnessAnimationForWindow( | 250 void StartGrayscaleBrightnessAnimationForWindow( |
| 254 aura::Window* window, | 251 aura::Window* window, |
| 255 float target, | 252 float target, |
| 256 base::TimeDelta duration, | 253 base::TimeDelta duration, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 284 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 281 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 285 | 282 |
| 286 animator->StartTogether(animations); | 283 animator->StartTogether(animations); |
| 287 } | 284 } |
| 288 | 285 |
| 289 // Animation observer that will drop animated foreground once animation is | 286 // Animation observer that will drop animated foreground once animation is |
| 290 // finished. It is used in when undoing shutdown animation. | 287 // finished. It is used in when undoing shutdown animation. |
| 291 class CallbackAnimationObserver : public ui::LayerAnimationObserver { | 288 class CallbackAnimationObserver : public ui::LayerAnimationObserver { |
| 292 public: | 289 public: |
| 293 explicit CallbackAnimationObserver(base::Closure callback) | 290 explicit CallbackAnimationObserver(base::Closure callback) |
| 294 : callback_(callback) { | 291 : callback_(callback) {} |
| 295 } | |
| 296 ~CallbackAnimationObserver() override {} | 292 ~CallbackAnimationObserver() override {} |
| 297 | 293 |
| 298 private: | 294 private: |
| 299 // Overridden from ui::LayerAnimationObserver: | 295 // Overridden from ui::LayerAnimationObserver: |
| 300 void OnLayerAnimationEnded(ui::LayerAnimationSequence* seq) override { | 296 void OnLayerAnimationEnded(ui::LayerAnimationSequence* seq) override { |
| 301 // Drop foreground once animation is over. | 297 // Drop foreground once animation is over. |
| 302 callback_.Run(); | 298 callback_.Run(); |
| 303 delete this; | 299 delete this; |
| 304 } | 300 } |
| 305 | 301 |
| 306 void OnLayerAnimationAborted(ui::LayerAnimationSequence* seq) override { | 302 void OnLayerAnimationAborted(ui::LayerAnimationSequence* seq) override { |
| 307 // Drop foreground once animation is over. | 303 // Drop foreground once animation is over. |
| 308 callback_.Run(); | 304 callback_.Run(); |
| 309 delete this; | 305 delete this; |
| 310 } | 306 } |
| 311 | 307 |
| 312 void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq) override {} | 308 void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq) override {} |
| 313 | 309 |
| 314 base::Closure callback_; | 310 base::Closure callback_; |
| 315 | 311 |
| 316 DISALLOW_COPY_AND_ASSIGN(CallbackAnimationObserver); | 312 DISALLOW_COPY_AND_ASSIGN(CallbackAnimationObserver); |
| 317 }; | 313 }; |
| 318 | 314 |
| 319 | |
| 320 bool IsLayerAnimated(ui::Layer* layer, | 315 bool IsLayerAnimated(ui::Layer* layer, |
| 321 SessionStateAnimator::AnimationType type) { | 316 SessionStateAnimator::AnimationType type) { |
| 322 switch (type) { | 317 switch (type) { |
| 323 case SessionStateAnimator::ANIMATION_PARTIAL_CLOSE: | 318 case SessionStateAnimator::ANIMATION_PARTIAL_CLOSE: |
| 324 if (layer->GetTargetTransform() != GetSlowCloseTransform()) | 319 if (layer->GetTargetTransform() != GetSlowCloseTransform()) |
| 325 return false; | 320 return false; |
| 326 break; | 321 break; |
| 327 case SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE: | 322 case SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE: |
| 328 if (layer->GetTargetTransform() != gfx::Transform()) | 323 if (layer->GetTargetTransform() != gfx::Transform()) |
| 329 return false; | 324 return false; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 354 (layer->GetTargetGrayscale() < 0.9999)) | 349 (layer->GetTargetGrayscale() < 0.9999)) |
| 355 return false; | 350 return false; |
| 356 break; | 351 break; |
| 357 case SessionStateAnimator::ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS: | 352 case SessionStateAnimator::ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS: |
| 358 if ((layer->GetTargetBrightness() > 0.0001) || | 353 if ((layer->GetTargetBrightness() > 0.0001) || |
| 359 (layer->GetTargetGrayscale() > 0.0001)) | 354 (layer->GetTargetGrayscale() > 0.0001)) |
| 360 return false; | 355 return false; |
| 361 break; | 356 break; |
| 362 case SessionStateAnimator::ANIMATION_DROP: | 357 case SessionStateAnimator::ANIMATION_DROP: |
| 363 case SessionStateAnimator::ANIMATION_UNDO_LIFT: | 358 case SessionStateAnimator::ANIMATION_UNDO_LIFT: |
| 364 //ToDo(antim) : check other effects | 359 // ToDo(antim) : check other effects |
| 365 if (layer->GetTargetOpacity() < 0.9999) | 360 if (layer->GetTargetOpacity() < 0.9999) |
| 366 return false; | 361 return false; |
| 367 break; | 362 break; |
| 368 //ToDo(antim) : check other effects | 363 // ToDo(antim) : check other effects |
| 369 case SessionStateAnimator::ANIMATION_LIFT: | 364 case SessionStateAnimator::ANIMATION_LIFT: |
| 370 if (layer->GetTargetOpacity() > 0.0001) | 365 if (layer->GetTargetOpacity() > 0.0001) |
| 371 return false; | 366 return false; |
| 372 break; | 367 break; |
| 373 case SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN: | 368 case SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN: |
| 374 //ToDo(antim) : check other effects | 369 // ToDo(antim) : check other effects |
| 375 if (layer->GetTargetOpacity() < 0.9999) | 370 if (layer->GetTargetOpacity() < 0.9999) |
| 376 return false; | 371 return false; |
| 377 break; | 372 break; |
| 378 //ToDo(antim) : check other effects | 373 // ToDo(antim) : check other effects |
| 379 case SessionStateAnimator::ANIMATION_LOWER_BELOW_SCREEN: | 374 case SessionStateAnimator::ANIMATION_LOWER_BELOW_SCREEN: |
| 380 if (layer->GetTargetOpacity() > 0.0001) | 375 if (layer->GetTargetOpacity() > 0.0001) |
| 381 return false; | 376 return false; |
| 382 break; | 377 break; |
| 383 default: | 378 default: |
| 384 NOTREACHED() << "Unhandled animation type " << type; | 379 NOTREACHED() << "Unhandled animation type " << type; |
| 385 return false; | 380 return false; |
| 386 } | 381 } |
| 387 return true; | 382 return true; |
| 388 } | 383 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 // This observer is intended to use in cases when some action has to be taken | 430 // This observer is intended to use in cases when some action has to be taken |
| 436 // once some animation successfully completes (i.e. it was not aborted). | 431 // once some animation successfully completes (i.e. it was not aborted). |
| 437 // Observer will count a number of sequences it is attached to, and a number of | 432 // Observer will count a number of sequences it is attached to, and a number of |
| 438 // finished sequences (either Ended or Aborted). Once these two numbers are | 433 // finished sequences (either Ended or Aborted). Once these two numbers are |
| 439 // equal, observer will delete itself, calling callback passed to constructor if | 434 // equal, observer will delete itself, calling callback passed to constructor if |
| 440 // there were no aborted animations. | 435 // there were no aborted animations. |
| 441 // This way it can be either used to wait for some animation to be finished in | 436 // This way it can be either used to wait for some animation to be finished in |
| 442 // multiple layers, to wait once a sequence of animations is finished in one | 437 // multiple layers, to wait once a sequence of animations is finished in one |
| 443 // layer or the mixture of both. | 438 // layer or the mixture of both. |
| 444 class SessionStateAnimatorImpl::AnimationSequence | 439 class SessionStateAnimatorImpl::AnimationSequence |
| 445 : public SessionStateAnimator::AnimationSequence, | 440 : public SessionStateAnimator::AnimationSequence, |
| 446 public ui::LayerAnimationObserver { | 441 public ui::LayerAnimationObserver { |
| 447 public: | 442 public: |
| 448 explicit AnimationSequence( | 443 explicit AnimationSequence(SessionStateAnimatorImpl* animator, |
| 449 SessionStateAnimatorImpl* animator, | 444 base::Closure callback) |
| 450 base::Closure callback) | |
| 451 : SessionStateAnimator::AnimationSequence(callback), | 445 : SessionStateAnimator::AnimationSequence(callback), |
| 452 animator_(animator), | 446 animator_(animator), |
| 453 sequences_attached_(0), | 447 sequences_attached_(0), |
| 454 sequences_completed_(0) { | 448 sequences_completed_(0) {} |
| 455 } | |
| 456 | 449 |
| 457 // SessionStateAnimator::AnimationSequence: | 450 // SessionStateAnimator::AnimationSequence: |
| 458 void StartAnimation(int container_mask, | 451 void StartAnimation(int container_mask, |
| 459 SessionStateAnimator::AnimationType type, | 452 SessionStateAnimator::AnimationType type, |
| 460 SessionStateAnimator::AnimationSpeed speed) override { | 453 SessionStateAnimator::AnimationSpeed speed) override { |
| 461 animator_->StartAnimationInSequence(container_mask, type, speed, this); | 454 animator_->StartAnimationInSequence(container_mask, type, speed, this); |
| 462 } | 455 } |
| 463 | 456 |
| 464 private: | 457 private: |
| 465 ~AnimationSequence() override {} | 458 ~AnimationSequence() override {} |
| (...skipping 24 matching lines...) Expand all Loading... |
| 490 // Number of sequences this observer was attached to. | 483 // Number of sequences this observer was attached to. |
| 491 int sequences_attached_; | 484 int sequences_attached_; |
| 492 | 485 |
| 493 // Number of sequences either ended or aborted. | 486 // Number of sequences either ended or aborted. |
| 494 int sequences_completed_; | 487 int sequences_completed_; |
| 495 | 488 |
| 496 DISALLOW_COPY_AND_ASSIGN(AnimationSequence); | 489 DISALLOW_COPY_AND_ASSIGN(AnimationSequence); |
| 497 }; | 490 }; |
| 498 | 491 |
| 499 bool SessionStateAnimatorImpl::TestApi::ContainersAreAnimated( | 492 bool SessionStateAnimatorImpl::TestApi::ContainersAreAnimated( |
| 500 int container_mask, AnimationType type) const { | 493 int container_mask, |
| 494 AnimationType type) const { |
| 501 aura::Window::Windows containers; | 495 aura::Window::Windows containers; |
| 502 animator_->GetContainers(container_mask, &containers); | 496 animator_->GetContainers(container_mask, &containers); |
| 503 for (aura::Window::Windows::const_iterator it = containers.begin(); | 497 for (aura::Window::Windows::const_iterator it = containers.begin(); |
| 504 it != containers.end(); ++it) { | 498 it != containers.end(); ++it) { |
| 505 aura::Window* window = *it; | 499 aura::Window* window = *it; |
| 506 ui::Layer* layer = window->layer(); | 500 ui::Layer* layer = window->layer(); |
| 507 if (!IsLayerAnimated(layer, type)) | 501 if (!IsLayerAnimated(layer, type)) |
| 508 return false; | 502 return false; |
| 509 } | 503 } |
| 510 return true; | 504 return true; |
| 511 } | 505 } |
| 512 | 506 |
| 513 bool SessionStateAnimatorImpl::TestApi::RootWindowIsAnimated(AnimationType type) | 507 bool SessionStateAnimatorImpl::TestApi::RootWindowIsAnimated( |
| 514 const { | 508 AnimationType type) const { |
| 515 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 509 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 516 ui::Layer* layer = root_window->layer(); | 510 ui::Layer* layer = root_window->layer(); |
| 517 return IsLayerAnimated(layer, type); | 511 return IsLayerAnimated(layer, type); |
| 518 } | 512 } |
| 519 | 513 |
| 520 SessionStateAnimatorImpl::SessionStateAnimatorImpl() { | 514 SessionStateAnimatorImpl::SessionStateAnimatorImpl() {} |
| 521 } | |
| 522 | 515 |
| 523 SessionStateAnimatorImpl::~SessionStateAnimatorImpl() { | 516 SessionStateAnimatorImpl::~SessionStateAnimatorImpl() {} |
| 524 } | |
| 525 | 517 |
| 526 // Fills |containers| with the containers described by |container_mask|. | 518 // Fills |containers| with the containers described by |container_mask|. |
| 527 void SessionStateAnimatorImpl::GetContainers( | 519 void SessionStateAnimatorImpl::GetContainers( |
| 528 int container_mask, | 520 int container_mask, |
| 529 aura::Window::Windows* containers) { | 521 aura::Window::Windows* containers) { |
| 530 containers->clear(); | 522 containers->clear(); |
| 531 | 523 |
| 532 for (aura::Window* root_window : Shell::GetAllRootWindows()) | 524 for (aura::Window* root_window : Shell::GetAllRootWindows()) |
| 533 GetContainersInRootWindow(container_mask, root_window, containers); | 525 GetContainersInRootWindow(container_mask, root_window, containers); |
| 534 | 526 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 558 GetContainers(container_mask, &containers); | 550 GetContainers(container_mask, &containers); |
| 559 for (aura::Window::Windows::const_iterator it = containers.begin(); | 551 for (aura::Window::Windows::const_iterator it = containers.begin(); |
| 560 it != containers.end(); ++it) { | 552 it != containers.end(); ++it) { |
| 561 ui::LayerAnimationObserver* observer = | 553 ui::LayerAnimationObserver* observer = |
| 562 new CallbackAnimationObserver(callback); | 554 new CallbackAnimationObserver(callback); |
| 563 RunAnimationForWindow(*it, type, speed, observer); | 555 RunAnimationForWindow(*it, type, speed, observer); |
| 564 } | 556 } |
| 565 } | 557 } |
| 566 | 558 |
| 567 SessionStateAnimator::AnimationSequence* | 559 SessionStateAnimator::AnimationSequence* |
| 568 SessionStateAnimatorImpl::BeginAnimationSequence(base::Closure callback) { | 560 SessionStateAnimatorImpl::BeginAnimationSequence(base::Closure callback) { |
| 569 return new AnimationSequence(this, callback); | 561 return new AnimationSequence(this, callback); |
| 570 } | 562 } |
| 571 | 563 |
| 572 bool SessionStateAnimatorImpl::IsBackgroundHidden() const { | 564 bool SessionStateAnimatorImpl::IsBackgroundHidden() const { |
| 573 return !GetBackground()->IsVisible(); | 565 return !GetBackground()->IsVisible(); |
| 574 } | 566 } |
| 575 | 567 |
| 576 void SessionStateAnimatorImpl::ShowBackground() { | 568 void SessionStateAnimatorImpl::ShowBackground() { |
| 577 ui::ScopedLayerAnimationSettings settings( | 569 ui::ScopedLayerAnimationSettings settings( |
| 578 GetBackground()->layer()->GetAnimator()); | 570 GetBackground()->layer()->GetAnimator()); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 case ANIMATION_UNDO_LIFT: | 632 case ANIMATION_UNDO_LIFT: |
| 641 TransformWindowToBaseState(window, duration, observer); | 633 TransformWindowToBaseState(window, duration, observer); |
| 642 break; | 634 break; |
| 643 case ANIMATION_RAISE_TO_SCREEN: | 635 case ANIMATION_RAISE_TO_SCREEN: |
| 644 ShowWindow(window, duration, false, observer); | 636 ShowWindow(window, duration, false, observer); |
| 645 break; | 637 break; |
| 646 case ANIMATION_LOWER_BELOW_SCREEN: | 638 case ANIMATION_LOWER_BELOW_SCREEN: |
| 647 HideWindow(window, duration, false, observer); | 639 HideWindow(window, duration, false, observer); |
| 648 break; | 640 break; |
| 649 case ANIMATION_PARTIAL_FADE_IN: | 641 case ANIMATION_PARTIAL_FADE_IN: |
| 650 StartPartialFadeAnimation( | 642 StartPartialFadeAnimation(window, kPartialFadeRatio, duration, observer); |
| 651 window, kPartialFadeRatio, duration, observer); | |
| 652 break; | 643 break; |
| 653 case ANIMATION_UNDO_PARTIAL_FADE_IN: | 644 case ANIMATION_UNDO_PARTIAL_FADE_IN: |
| 654 StartPartialFadeAnimation(window, 0.0, duration, observer); | 645 StartPartialFadeAnimation(window, 0.0, duration, observer); |
| 655 break; | 646 break; |
| 656 case ANIMATION_FULL_FADE_IN: | 647 case ANIMATION_FULL_FADE_IN: |
| 657 StartPartialFadeAnimation(window, 1.0, duration, observer); | 648 StartPartialFadeAnimation(window, 1.0, duration, observer); |
| 658 break; | 649 break; |
| 659 case ANIMATION_GRAYSCALE_BRIGHTNESS: | 650 case ANIMATION_GRAYSCALE_BRIGHTNESS: |
| 660 StartGrayscaleBrightnessAnimationForWindow( | 651 StartGrayscaleBrightnessAnimationForWindow(window, 1.0, duration, |
| 661 window, 1.0, duration, gfx::Tween::EASE_IN, observer); | 652 gfx::Tween::EASE_IN, observer); |
| 662 break; | 653 break; |
| 663 case ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS: | 654 case ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS: |
| 664 StartGrayscaleBrightnessAnimationForWindow( | 655 StartGrayscaleBrightnessAnimationForWindow( |
| 665 window, 0.0, duration, gfx::Tween::EASE_IN_OUT, observer); | 656 window, 0.0, duration, gfx::Tween::EASE_IN_OUT, observer); |
| 666 break; | 657 break; |
| 667 } | 658 } |
| 668 } | 659 } |
| 669 | 660 |
| 670 } // namespace ash | 661 } // namespace ash |
| OLD | NEW |