| 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/window_animations.h" | 5 #include "ash/wm/window_animations.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 225 |
| 226 ui::Layer* layer_; | 226 ui::Layer* layer_; |
| 227 | 227 |
| 228 DISALLOW_COPY_AND_ASSIGN(WorkspaceHidingWindowAnimationObserver); | 228 DISALLOW_COPY_AND_ASSIGN(WorkspaceHidingWindowAnimationObserver); |
| 229 }; | 229 }; |
| 230 | 230 |
| 231 // Shows a window using an animation, animating its opacity from 0.f to 1.f, | 231 // Shows a window using an animation, animating its opacity from 0.f to 1.f, |
| 232 // its visibility to true, and its transform from |start_transform| to | 232 // its visibility to true, and its transform from |start_transform| to |
| 233 // |end_transform|. | 233 // |end_transform|. |
| 234 void AnimateShowWindowCommon(aura::Window* window, | 234 void AnimateShowWindowCommon(aura::Window* window, |
| 235 const ui::Transform& start_transform, | 235 const gfx::Transform& start_transform, |
| 236 const ui::Transform& end_transform) { | 236 const gfx::Transform& end_transform) { |
| 237 window->layer()->set_delegate(window); | 237 window->layer()->set_delegate(window); |
| 238 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); | 238 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); |
| 239 window->layer()->SetTransform(start_transform); | 239 window->layer()->SetTransform(start_transform); |
| 240 | 240 |
| 241 { | 241 { |
| 242 // Property sets within this scope will be implicitly animated. | 242 // Property sets within this scope will be implicitly animated. |
| 243 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); | 243 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); |
| 244 base::TimeDelta duration = GetWindowVisibilityAnimationDuration(window); | 244 base::TimeDelta duration = GetWindowVisibilityAnimationDuration(window); |
| 245 if (duration.ToInternalValue() > 0) | 245 if (duration.ToInternalValue() > 0) |
| 246 settings.SetTransitionDuration(duration); | 246 settings.SetTransitionDuration(duration); |
| 247 | 247 |
| 248 window->layer()->SetVisible(true); | 248 window->layer()->SetVisible(true); |
| 249 window->layer()->SetTransform(end_transform); | 249 window->layer()->SetTransform(end_transform); |
| 250 window->layer()->SetOpacity(kWindowAnimation_ShowOpacity); | 250 window->layer()->SetOpacity(kWindowAnimation_ShowOpacity); |
| 251 } | 251 } |
| 252 } | 252 } |
| 253 | 253 |
| 254 // Hides a window using an animation, animating its opacity from 1.f to 0.f, | 254 // Hides a window using an animation, animating its opacity from 1.f to 0.f, |
| 255 // its visibility to false, and its transform to |end_transform|. | 255 // its visibility to false, and its transform to |end_transform|. |
| 256 void AnimateHideWindowCommon(aura::Window* window, | 256 void AnimateHideWindowCommon(aura::Window* window, |
| 257 const ui::Transform& end_transform) { | 257 const gfx::Transform& end_transform) { |
| 258 window->layer()->set_delegate(NULL); | 258 window->layer()->set_delegate(NULL); |
| 259 | 259 |
| 260 // Property sets within this scope will be implicitly animated. | 260 // Property sets within this scope will be implicitly animated. |
| 261 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); | 261 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); |
| 262 settings.AddObserver(new HidingWindowAnimationObserver(window)); | 262 settings.AddObserver(new HidingWindowAnimationObserver(window)); |
| 263 | 263 |
| 264 base::TimeDelta duration = GetWindowVisibilityAnimationDuration(window); | 264 base::TimeDelta duration = GetWindowVisibilityAnimationDuration(window); |
| 265 if (duration.ToInternalValue() > 0) | 265 if (duration.ToInternalValue() > 0) |
| 266 settings.SetTransitionDuration(duration); | 266 settings.SetTransitionDuration(duration); |
| 267 | 267 |
| 268 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); | 268 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); |
| 269 window->layer()->SetTransform(end_transform); | 269 window->layer()->SetTransform(end_transform); |
| 270 window->layer()->SetVisible(false); | 270 window->layer()->SetVisible(false); |
| 271 } | 271 } |
| 272 | 272 |
| 273 // Show/Hide windows using a shrink animation. | 273 // Show/Hide windows using a shrink animation. |
| 274 void AnimateShowWindow_Drop(aura::Window* window) { | 274 void AnimateShowWindow_Drop(aura::Window* window) { |
| 275 ui::Transform transform; | 275 gfx::Transform transform; |
| 276 transform.ConcatScale(kWindowAnimation_ScaleFactor, | 276 transform.ConcatScale(kWindowAnimation_ScaleFactor, |
| 277 kWindowAnimation_ScaleFactor); | 277 kWindowAnimation_ScaleFactor); |
| 278 gfx::Rect bounds = window->bounds(); | 278 gfx::Rect bounds = window->bounds(); |
| 279 transform.ConcatTranslate( | 279 transform.ConcatTranslate( |
| 280 kWindowAnimation_TranslateFactor * bounds.width(), | 280 kWindowAnimation_TranslateFactor * bounds.width(), |
| 281 kWindowAnimation_TranslateFactor * bounds.height()); | 281 kWindowAnimation_TranslateFactor * bounds.height()); |
| 282 AnimateShowWindowCommon(window, transform, ui::Transform()); | 282 AnimateShowWindowCommon(window, transform, gfx::Transform()); |
| 283 } | 283 } |
| 284 | 284 |
| 285 void AnimateHideWindow_Drop(aura::Window* window) { | 285 void AnimateHideWindow_Drop(aura::Window* window) { |
| 286 ui::Transform transform; | 286 gfx::Transform transform; |
| 287 transform.ConcatScale(kWindowAnimation_ScaleFactor, | 287 transform.ConcatScale(kWindowAnimation_ScaleFactor, |
| 288 kWindowAnimation_ScaleFactor); | 288 kWindowAnimation_ScaleFactor); |
| 289 gfx::Rect bounds = window->bounds(); | 289 gfx::Rect bounds = window->bounds(); |
| 290 transform.ConcatTranslate( | 290 transform.ConcatTranslate( |
| 291 kWindowAnimation_TranslateFactor * bounds.width(), | 291 kWindowAnimation_TranslateFactor * bounds.width(), |
| 292 kWindowAnimation_TranslateFactor * bounds.height()); | 292 kWindowAnimation_TranslateFactor * bounds.height()); |
| 293 AnimateHideWindowCommon(window, transform); | 293 AnimateHideWindowCommon(window, transform); |
| 294 } | 294 } |
| 295 | 295 |
| 296 // Show/Hide windows using a vertical Glenimation. | 296 // Show/Hide windows using a vertical Glenimation. |
| 297 void AnimateShowWindow_Vertical(aura::Window* window) { | 297 void AnimateShowWindow_Vertical(aura::Window* window) { |
| 298 ui::Transform transform; | 298 gfx::Transform transform; |
| 299 transform.ConcatTranslate(0, window->GetProperty( | 299 transform.ConcatTranslate(0, window->GetProperty( |
| 300 kWindowVisibilityAnimationVerticalPositionKey)); | 300 kWindowVisibilityAnimationVerticalPositionKey)); |
| 301 AnimateShowWindowCommon(window, transform, ui::Transform()); | 301 AnimateShowWindowCommon(window, transform, gfx::Transform()); |
| 302 } | 302 } |
| 303 | 303 |
| 304 void AnimateHideWindow_Vertical(aura::Window* window) { | 304 void AnimateHideWindow_Vertical(aura::Window* window) { |
| 305 ui::Transform transform; | 305 gfx::Transform transform; |
| 306 transform.ConcatTranslate(0, window->GetProperty( | 306 transform.ConcatTranslate(0, window->GetProperty( |
| 307 kWindowVisibilityAnimationVerticalPositionKey)); | 307 kWindowVisibilityAnimationVerticalPositionKey)); |
| 308 AnimateHideWindowCommon(window, transform); | 308 AnimateHideWindowCommon(window, transform); |
| 309 } | 309 } |
| 310 | 310 |
| 311 // Show/Hide windows using a fade. | 311 // Show/Hide windows using a fade. |
| 312 void AnimateShowWindow_Fade(aura::Window* window) { | 312 void AnimateShowWindow_Fade(aura::Window* window) { |
| 313 AnimateShowWindowCommon(window, ui::Transform(), ui::Transform()); | 313 AnimateShowWindowCommon(window, gfx::Transform(), gfx::Transform()); |
| 314 } | 314 } |
| 315 | 315 |
| 316 void AnimateHideWindow_Fade(aura::Window* window) { | 316 void AnimateHideWindow_Fade(aura::Window* window) { |
| 317 AnimateHideWindowCommon(window, ui::Transform()); | 317 AnimateHideWindowCommon(window, gfx::Transform()); |
| 318 } | 318 } |
| 319 | 319 |
| 320 // Builds the transform used when switching workspaces for the specified | 320 // Builds the transform used when switching workspaces for the specified |
| 321 // window. | 321 // window. |
| 322 ui::Transform BuildWorkspaceSwitchTransform(aura::Window* window, float scale) { | 322 gfx::Transform BuildWorkspaceSwitchTransform(aura::Window* window, |
| 323 float scale) { |
| 323 // Animations for transitioning workspaces scale all windows. To give the | 324 // Animations for transitioning workspaces scale all windows. To give the |
| 324 // effect of scaling from the center of the screen the windows are translated. | 325 // effect of scaling from the center of the screen the windows are translated. |
| 325 gfx::Rect bounds = window->bounds(); | 326 gfx::Rect bounds = window->bounds(); |
| 326 gfx::Rect parent_bounds(window->parent()->bounds()); | 327 gfx::Rect parent_bounds(window->parent()->bounds()); |
| 327 | 328 |
| 328 float mid_x = static_cast<float>(parent_bounds.width()) / 2.0f; | 329 float mid_x = static_cast<float>(parent_bounds.width()) / 2.0f; |
| 329 float initial_x = | 330 float initial_x = |
| 330 (static_cast<float>(bounds.x()) - mid_x) * scale + mid_x; | 331 (static_cast<float>(bounds.x()) - mid_x) * scale + mid_x; |
| 331 float mid_y = static_cast<float>(parent_bounds.height()) / 2.0f; | 332 float mid_y = static_cast<float>(parent_bounds.height()) / 2.0f; |
| 332 float initial_y = | 333 float initial_y = |
| 333 (static_cast<float>(bounds.y()) - mid_y) * scale + mid_y; | 334 (static_cast<float>(bounds.y()) - mid_y) * scale + mid_y; |
| 334 | 335 |
| 335 ui::Transform transform; | 336 gfx::Transform transform; |
| 336 transform.ConcatTranslate( | 337 transform.ConcatTranslate( |
| 337 initial_x - static_cast<float>(bounds.x()), | 338 initial_x - static_cast<float>(bounds.x()), |
| 338 initial_y - static_cast<float>(bounds.y())); | 339 initial_y - static_cast<float>(bounds.y())); |
| 339 transform.ConcatScale(scale, scale); | 340 transform.ConcatScale(scale, scale); |
| 340 return transform; | 341 return transform; |
| 341 } | 342 } |
| 342 | 343 |
| 343 void AnimateShowWindow_Workspace(aura::Window* window) { | 344 void AnimateShowWindow_Workspace(aura::Window* window) { |
| 344 ui::Transform transform( | 345 gfx::Transform transform( |
| 345 BuildWorkspaceSwitchTransform(window, kWorkspaceScale)); | 346 BuildWorkspaceSwitchTransform(window, kWorkspaceScale)); |
| 346 // When we call SetOpacity here, if a hide sequence is already running, | 347 // When we call SetOpacity here, if a hide sequence is already running, |
| 347 // the default animation preemption strategy fast forwards the hide sequence | 348 // the default animation preemption strategy fast forwards the hide sequence |
| 348 // to completion and notifies the WorkspaceHidingWindowAnimationObserver to | 349 // to completion and notifies the WorkspaceHidingWindowAnimationObserver to |
| 349 // set the layer to be invisible. We should call SetVisible after SetOpacity | 350 // set the layer to be invisible. We should call SetVisible after SetOpacity |
| 350 // to ensure our layer is visible again. | 351 // to ensure our layer is visible again. |
| 351 window->layer()->SetOpacity(0.0f); | 352 window->layer()->SetOpacity(0.0f); |
| 352 window->layer()->SetTransform(transform); | 353 window->layer()->SetTransform(transform); |
| 353 window->layer()->SetVisible(true); | 354 window->layer()->SetVisible(true); |
| 354 | 355 |
| 355 { | 356 { |
| 356 // Property sets within this scope will be implicitly animated. | 357 // Property sets within this scope will be implicitly animated. |
| 357 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); | 358 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); |
| 358 | 359 |
| 359 window->layer()->SetTransform(ui::Transform()); | 360 window->layer()->SetTransform(gfx::Transform()); |
| 360 // Opacity animates only during the first half of the animation. | 361 // Opacity animates only during the first half of the animation. |
| 361 settings.SetTransitionDuration(settings.GetTransitionDuration() / 2); | 362 settings.SetTransitionDuration(settings.GetTransitionDuration() / 2); |
| 362 window->layer()->SetOpacity(1.0f); | 363 window->layer()->SetOpacity(1.0f); |
| 363 } | 364 } |
| 364 } | 365 } |
| 365 | 366 |
| 366 void AnimateHideWindow_Workspace(aura::Window* window) { | 367 void AnimateHideWindow_Workspace(aura::Window* window) { |
| 367 ui::Transform transform( | 368 gfx::Transform transform( |
| 368 BuildWorkspaceSwitchTransform(window, kWorkspaceScale)); | 369 BuildWorkspaceSwitchTransform(window, kWorkspaceScale)); |
| 369 window->layer()->SetOpacity(1.0f); | 370 window->layer()->SetOpacity(1.0f); |
| 370 window->layer()->SetTransform(ui::Transform()); | 371 window->layer()->SetTransform(gfx::Transform()); |
| 371 | 372 |
| 372 // Opacity animates from 1 to 0 only over the second half of the animation. To | 373 // Opacity animates from 1 to 0 only over the second half of the animation. To |
| 373 // get this functionality two animations are schedule for opacity, the first | 374 // get this functionality two animations are schedule for opacity, the first |
| 374 // from 1 to 1 (which effectively does nothing) the second from 1 to 0. | 375 // from 1 to 1 (which effectively does nothing) the second from 1 to 0. |
| 375 // Because we're scheduling two animations of the same property we need to | 376 // Because we're scheduling two animations of the same property we need to |
| 376 // change the preemption strategy. | 377 // change the preemption strategy. |
| 377 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 378 ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| 378 animator->set_preemption_strategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); | 379 animator->set_preemption_strategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); |
| 379 { | 380 { |
| 380 // Property sets within this scope will be implicitly animated. | 381 // Property sets within this scope will be implicitly animated. |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 | 714 |
| 714 // Used to identify what should animate in AnimateWorkspaceIn/Out. | 715 // Used to identify what should animate in AnimateWorkspaceIn/Out. |
| 715 enum WorkspaceAnimateTypes { | 716 enum WorkspaceAnimateTypes { |
| 716 WORKSPACE_ANIMATE_OPACITY = 1 << 0, | 717 WORKSPACE_ANIMATE_OPACITY = 1 << 0, |
| 717 WORKSPACE_ANIMATE_BRIGHTNESS = 1 << 1, | 718 WORKSPACE_ANIMATE_BRIGHTNESS = 1 << 1, |
| 718 }; | 719 }; |
| 719 | 720 |
| 720 void ApplyWorkspaceScale(ui::Layer* layer, WorkspaceScaleType type) { | 721 void ApplyWorkspaceScale(ui::Layer* layer, WorkspaceScaleType type) { |
| 721 const float scale = type == WORKSPACE_SCALE_ABOVE ? kWorkspaceScaleAbove : | 722 const float scale = type == WORKSPACE_SCALE_ABOVE ? kWorkspaceScaleAbove : |
| 722 kWorkspaceScaleBelow; | 723 kWorkspaceScaleBelow; |
| 723 ui::Transform transform; | 724 gfx::Transform transform; |
| 724 transform.ConcatScale(scale, scale); | 725 transform.ConcatScale(scale, scale); |
| 725 transform.ConcatTranslate( | 726 transform.ConcatTranslate( |
| 726 -layer->bounds().width() * (scale - 1.0f) / 2, | 727 -layer->bounds().width() * (scale - 1.0f) / 2, |
| 727 -layer->bounds().height() * (scale - 1.0f) / 2); | 728 -layer->bounds().height() * (scale - 1.0f) / 2); |
| 728 layer->SetTransform(transform); | 729 layer->SetTransform(transform); |
| 729 } | 730 } |
| 730 | 731 |
| 731 // Implementation of cross fading. Window is the window being cross faded. It | 732 // Implementation of cross fading. Window is the window being cross faded. It |
| 732 // should be at the target bounds. |old_layer| the previous layer from |window|. | 733 // should be at the target bounds. |old_layer| the previous layer from |window|. |
| 733 // This takes ownership of |old_layer| and deletes when the animation is done. | 734 // This takes ownership of |old_layer| and deletes when the animation is done. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 750 ui::ScopedLayerAnimationSettings settings(old_layer->GetAnimator()); | 751 ui::ScopedLayerAnimationSettings settings(old_layer->GetAnimator()); |
| 751 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); | 752 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); |
| 752 old_layer->GetAnimator()->SchedulePauseForProperties( | 753 old_layer->GetAnimator()->SchedulePauseForProperties( |
| 753 pause_duration, ui::LayerAnimationElement::TRANSFORM, | 754 pause_duration, ui::LayerAnimationElement::TRANSFORM, |
| 754 ui::LayerAnimationElement::OPACITY, -1); | 755 ui::LayerAnimationElement::OPACITY, -1); |
| 755 | 756 |
| 756 // Animation observer owns the old layer and deletes itself. | 757 // Animation observer owns the old layer and deletes itself. |
| 757 settings.AddObserver(new internal::CrossFadeObserver(window, old_layer)); | 758 settings.AddObserver(new internal::CrossFadeObserver(window, old_layer)); |
| 758 settings.SetTransitionDuration(duration); | 759 settings.SetTransitionDuration(duration); |
| 759 settings.SetTweenType(tween_type); | 760 settings.SetTweenType(tween_type); |
| 760 ui::Transform out_transform; | 761 gfx::Transform out_transform; |
| 761 float scale_x = static_cast<float>(new_bounds.width()) / | 762 float scale_x = static_cast<float>(new_bounds.width()) / |
| 762 static_cast<float>(old_bounds.width()); | 763 static_cast<float>(old_bounds.width()); |
| 763 float scale_y = static_cast<float>(new_bounds.height()) / | 764 float scale_y = static_cast<float>(new_bounds.height()) / |
| 764 static_cast<float>(old_bounds.height()); | 765 static_cast<float>(old_bounds.height()); |
| 765 out_transform.ConcatScale(scale_x, scale_y); | 766 out_transform.ConcatScale(scale_x, scale_y); |
| 766 out_transform.ConcatTranslate(new_bounds.x() - old_bounds.x(), | 767 out_transform.ConcatTranslate(new_bounds.x() - old_bounds.x(), |
| 767 new_bounds.y() - old_bounds.y()); | 768 new_bounds.y() - old_bounds.y()); |
| 768 old_layer->SetTransform(out_transform); | 769 old_layer->SetTransform(out_transform); |
| 769 if (old_on_top) { | 770 if (old_on_top) { |
| 770 // The old layer is on top, and should fade out. The new layer below will | 771 // The old layer is on top, and should fade out. The new layer below will |
| 771 // stay opaque to block the desktop. | 772 // stay opaque to block the desktop. |
| 772 old_layer->SetOpacity(0.f); | 773 old_layer->SetOpacity(0.f); |
| 773 } | 774 } |
| 774 // In tests |old_layer| is deleted here, as animations have zero duration. | 775 // In tests |old_layer| is deleted here, as animations have zero duration. |
| 775 old_layer = NULL; | 776 old_layer = NULL; |
| 776 } | 777 } |
| 777 | 778 |
| 778 // Set the new layer's current transform, such that the user sees a scaled | 779 // Set the new layer's current transform, such that the user sees a scaled |
| 779 // version of the window with the original bounds at the original position. | 780 // version of the window with the original bounds at the original position. |
| 780 ui::Transform in_transform; | 781 gfx::Transform in_transform; |
| 781 const float scale_x = static_cast<float>(old_bounds.width()) / | 782 const float scale_x = static_cast<float>(old_bounds.width()) / |
| 782 static_cast<float>(new_bounds.width()); | 783 static_cast<float>(new_bounds.width()); |
| 783 const float scale_y = static_cast<float>(old_bounds.height()) / | 784 const float scale_y = static_cast<float>(old_bounds.height()) / |
| 784 static_cast<float>(new_bounds.height()); | 785 static_cast<float>(new_bounds.height()); |
| 785 in_transform.ConcatScale(scale_x, scale_y); | 786 in_transform.ConcatScale(scale_x, scale_y); |
| 786 in_transform.ConcatTranslate(old_bounds.x() - new_bounds.x(), | 787 in_transform.ConcatTranslate(old_bounds.x() - new_bounds.x(), |
| 787 old_bounds.y() - new_bounds.y()); | 788 old_bounds.y() - new_bounds.y()); |
| 788 window->layer()->SetTransform(in_transform); | 789 window->layer()->SetTransform(in_transform); |
| 789 if (!old_on_top) { | 790 if (!old_on_top) { |
| 790 // The new layer is on top and should fade in. The old layer below will | 791 // The new layer is on top and should fade in. The old layer below will |
| 791 // stay opaque and block the desktop. | 792 // stay opaque and block the desktop. |
| 792 window->layer()->SetOpacity(0.f); | 793 window->layer()->SetOpacity(0.f); |
| 793 } | 794 } |
| 794 { | 795 { |
| 795 // Animate the new layer to the identity transform, so the window goes to | 796 // Animate the new layer to the identity transform, so the window goes to |
| 796 // its newly set bounds. | 797 // its newly set bounds. |
| 797 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); | 798 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); |
| 798 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); | 799 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); |
| 799 window->layer()->GetAnimator()->SchedulePauseForProperties( | 800 window->layer()->GetAnimator()->SchedulePauseForProperties( |
| 800 pause_duration, ui::LayerAnimationElement::TRANSFORM, | 801 pause_duration, ui::LayerAnimationElement::TRANSFORM, |
| 801 ui::LayerAnimationElement::OPACITY, -1); | 802 ui::LayerAnimationElement::OPACITY, -1); |
| 802 settings.SetTransitionDuration(duration); | 803 settings.SetTransitionDuration(duration); |
| 803 settings.SetTweenType(tween_type); | 804 settings.SetTweenType(tween_type); |
| 804 window->layer()->SetTransform(ui::Transform()); | 805 window->layer()->SetTransform(gfx::Transform()); |
| 805 if (!old_on_top) { | 806 if (!old_on_top) { |
| 806 // New layer is on top, fade it in. | 807 // New layer is on top, fade it in. |
| 807 window->layer()->SetOpacity(1.f); | 808 window->layer()->SetOpacity(1.f); |
| 808 } | 809 } |
| 809 } | 810 } |
| 810 return duration; | 811 return duration; |
| 811 } | 812 } |
| 812 | 813 |
| 813 // Returns a TimeDelta from |time_ms|. If animations are disabled this returns | 814 // Returns a TimeDelta from |time_ms|. If animations are disabled this returns |
| 814 // a TimeDelta of 0 (so the animation completes immediately). | 815 // a TimeDelta of 0 (so the animation completes immediately). |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 AdjustAnimationTime(pause_time_ms), | 858 AdjustAnimationTime(pause_time_ms), |
| 858 ui::LayerAnimationElement::TRANSFORM, | 859 ui::LayerAnimationElement::TRANSFORM, |
| 859 ui::LayerAnimationElement::OPACITY, | 860 ui::LayerAnimationElement::OPACITY, |
| 860 ui::LayerAnimationElement::BRIGHTNESS, | 861 ui::LayerAnimationElement::BRIGHTNESS, |
| 861 ui::LayerAnimationElement::VISIBILITY, | 862 ui::LayerAnimationElement::VISIBILITY, |
| 862 -1); | 863 -1); |
| 863 } | 864 } |
| 864 | 865 |
| 865 settings.SetTweenType(tween_type); | 866 settings.SetTweenType(tween_type); |
| 866 settings.SetTransitionDuration(duration); | 867 settings.SetTransitionDuration(duration); |
| 867 window->layer()->SetTransform(ui::Transform()); | 868 window->layer()->SetTransform(gfx::Transform()); |
| 868 window->layer()->SetOpacity(1.0f); | 869 window->layer()->SetOpacity(1.0f); |
| 869 window->layer()->SetLayerBrightness(0.0f); | 870 window->layer()->SetLayerBrightness(0.0f); |
| 870 } | 871 } |
| 871 } | 872 } |
| 872 | 873 |
| 873 void AnimateWorkspaceOutImpl(aura::Window* window, | 874 void AnimateWorkspaceOutImpl(aura::Window* window, |
| 874 WorkspaceAnimationDirection direction, | 875 WorkspaceAnimationDirection direction, |
| 875 uint32 animate_types, | 876 uint32 animate_types, |
| 876 int pause_time_ms, | 877 int pause_time_ms, |
| 877 ui::Tween::Type tween_type, | 878 ui::Tween::Type tween_type, |
| 878 TimeDelta duration) { | 879 TimeDelta duration) { |
| 879 window->Show(); | 880 window->Show(); |
| 880 window->layer()->SetTransform(ui::Transform()); | 881 window->layer()->SetTransform(gfx::Transform()); |
| 881 window->layer()->SetLayerBrightness(0.0f); | 882 window->layer()->SetLayerBrightness(0.0f); |
| 882 window->layer()->SetOpacity(1.0f); | 883 window->layer()->SetOpacity(1.0f); |
| 883 window->layer()->GetAnimator()->StopAnimating(); | 884 window->layer()->GetAnimator()->StopAnimating(); |
| 884 | 885 |
| 885 { | 886 { |
| 886 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); | 887 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); |
| 887 | 888 |
| 888 if (pause_time_ms > 0) { | 889 if (pause_time_ms > 0) { |
| 889 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); | 890 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); |
| 890 window->layer()->GetAnimator()->SchedulePauseForProperties( | 891 window->layer()->GetAnimator()->SchedulePauseForProperties( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 908 if (animate_types & WORKSPACE_ANIMATE_OPACITY) | 909 if (animate_types & WORKSPACE_ANIMATE_OPACITY) |
| 909 window->layer()->SetOpacity(0.0f); | 910 window->layer()->SetOpacity(0.0f); |
| 910 if (animate_types & WORKSPACE_ANIMATE_BRIGHTNESS) | 911 if (animate_types & WORKSPACE_ANIMATE_BRIGHTNESS) |
| 911 window->layer()->SetLayerBrightness(kWorkspaceBrightness); | 912 window->layer()->SetLayerBrightness(kWorkspaceBrightness); |
| 912 | 913 |
| 913 // After the animation completes snap the transform back to the identity, | 914 // After the animation completes snap the transform back to the identity, |
| 914 // otherwise any one that asks for screen bounds gets a slightly scaled | 915 // otherwise any one that asks for screen bounds gets a slightly scaled |
| 915 // version. | 916 // version. |
| 916 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); | 917 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); |
| 917 settings.SetTransitionDuration(base::TimeDelta()); | 918 settings.SetTransitionDuration(base::TimeDelta()); |
| 918 window->layer()->SetTransform(ui::Transform()); | 919 window->layer()->SetTransform(gfx::Transform()); |
| 919 } | 920 } |
| 920 } | 921 } |
| 921 | 922 |
| 922 ui::Tween::Type TweenTypeForWorskpaceOut(WorkspaceType type) { | 923 ui::Tween::Type TweenTypeForWorskpaceOut(WorkspaceType type) { |
| 923 return WORKSPACE_DESKTOP ? ui::Tween::LINEAR : ui::Tween::EASE_OUT; | 924 return WORKSPACE_DESKTOP ? ui::Tween::LINEAR : ui::Tween::EASE_OUT; |
| 924 } | 925 } |
| 925 | 926 |
| 926 } // namespace | 927 } // namespace |
| 927 | 928 |
| 928 //////////////////////////////////////////////////////////////////////////////// | 929 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1012 if (old_workspace) | 1013 if (old_workspace) |
| 1013 AnimateWorkspaceOutImpl(old_workspace, WORKSPACE_ANIMATE_UP, | 1014 AnimateWorkspaceOutImpl(old_workspace, WORKSPACE_ANIMATE_UP, |
| 1014 WORKSPACE_ANIMATE_BRIGHTNESS, | 1015 WORKSPACE_ANIMATE_BRIGHTNESS, |
| 1015 0, workspace_tween_type, duration); | 1016 0, workspace_tween_type, duration); |
| 1016 | 1017 |
| 1017 // Ideally we would use AnimateWorkspaceIn() for |new_workspace|, but that | 1018 // Ideally we would use AnimateWorkspaceIn() for |new_workspace|, but that |
| 1018 // results in |window| animating with the workspace scale. We don't want | 1019 // results in |window| animating with the workspace scale. We don't want |
| 1019 // that, so we explicitly animate each of the children to give the effect of | 1020 // that, so we explicitly animate each of the children to give the effect of |
| 1020 // the workspace scaling. | 1021 // the workspace scaling. |
| 1021 new_workspace->Show(); | 1022 new_workspace->Show(); |
| 1022 new_workspace->SetTransform(ui::Transform()); | 1023 new_workspace->SetTransform(gfx::Transform()); |
| 1023 new_workspace->layer()->SetOpacity(1.0f); | 1024 new_workspace->layer()->SetOpacity(1.0f); |
| 1024 new_workspace->layer()->SetLayerBrightness(0.0f); | 1025 new_workspace->layer()->SetLayerBrightness(0.0f); |
| 1025 const Windows& children(new_workspace->children()); | 1026 const Windows& children(new_workspace->children()); |
| 1026 for (Windows::const_iterator i = children.begin(); i != children.end(); | 1027 for (Windows::const_iterator i = children.begin(); i != children.end(); |
| 1027 ++i) { | 1028 ++i) { |
| 1028 aura::Window* child = *i; | 1029 aura::Window* child = *i; |
| 1029 if (child == window) | 1030 if (child == window) |
| 1030 continue; | 1031 continue; |
| 1031 child->SetTransform(ash::internal::BuildWorkspaceSwitchTransform( | 1032 child->SetTransform(ash::internal::BuildWorkspaceSwitchTransform( |
| 1032 child, kWorkspaceScaleBelow)); | 1033 child, kWorkspaceScaleBelow)); |
| 1033 child->layer()->SetLayerBrightness(kWorkspaceBrightness); | 1034 child->layer()->SetLayerBrightness(kWorkspaceBrightness); |
| 1034 ui::ScopedLayerAnimationSettings settings(child->layer()->GetAnimator()); | 1035 ui::ScopedLayerAnimationSettings settings(child->layer()->GetAnimator()); |
| 1035 settings.SetTweenType(ui::Tween::EASE_OUT); | 1036 settings.SetTweenType(ui::Tween::EASE_OUT); |
| 1036 settings.SetTransitionDuration(duration); | 1037 settings.SetTransitionDuration(duration); |
| 1037 child->SetTransform(ui::Transform()); | 1038 child->SetTransform(gfx::Transform()); |
| 1038 child->layer()->SetLayerBrightness(0.0f); | 1039 child->layer()->SetLayerBrightness(0.0f); |
| 1039 } | 1040 } |
| 1040 } else { | 1041 } else { |
| 1041 if (old_workspace) { | 1042 if (old_workspace) { |
| 1042 AnimateWorkspaceOutImpl(old_workspace, WORKSPACE_ANIMATE_DOWN, | 1043 AnimateWorkspaceOutImpl(old_workspace, WORKSPACE_ANIMATE_DOWN, |
| 1043 WORKSPACE_ANIMATE_BRIGHTNESS, | 1044 WORKSPACE_ANIMATE_BRIGHTNESS, |
| 1044 0, workspace_tween_type, duration); | 1045 0, workspace_tween_type, duration); |
| 1045 } | 1046 } |
| 1046 | 1047 |
| 1047 new_workspace->Show(); | 1048 new_workspace->Show(); |
| 1048 new_workspace->layer()->SetOpacity(1.f); | 1049 new_workspace->layer()->SetOpacity(1.f); |
| 1049 new_workspace->layer()->SetTransform(ui::Transform()); | 1050 new_workspace->layer()->SetTransform(gfx::Transform()); |
| 1050 new_workspace->layer()->SetLayerBrightness(0.0f); | 1051 new_workspace->layer()->SetLayerBrightness(0.0f); |
| 1051 } | 1052 } |
| 1052 } | 1053 } |
| 1053 | 1054 |
| 1054 void AnimateBetweenWorkspaces(aura::Window* old_window, | 1055 void AnimateBetweenWorkspaces(aura::Window* old_window, |
| 1055 WorkspaceType old_type, | 1056 WorkspaceType old_type, |
| 1056 bool animate_old, | 1057 bool animate_old, |
| 1057 aura::Window* new_window, | 1058 aura::Window* new_window, |
| 1058 WorkspaceType new_type, | 1059 WorkspaceType new_type, |
| 1059 bool is_restoring_maximized_window) { | 1060 bool is_restoring_maximized_window) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1164 return AnimateShowWindow(window); | 1165 return AnimateShowWindow(window); |
| 1165 } else { | 1166 } else { |
| 1166 // Don't start hiding the window again if it's already being hidden. | 1167 // Don't start hiding the window again if it's already being hidden. |
| 1167 return window->layer()->GetTargetOpacity() != 0.0f && | 1168 return window->layer()->GetTargetOpacity() != 0.0f && |
| 1168 AnimateHideWindow(window); | 1169 AnimateHideWindow(window); |
| 1169 } | 1170 } |
| 1170 } | 1171 } |
| 1171 | 1172 |
| 1172 } // namespace internal | 1173 } // namespace internal |
| 1173 } // namespace ash | 1174 } // namespace ash |
| OLD | NEW |