| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/overview/scoped_overview_animation_settings.h" | 5 #include "ash/wm/overview/scoped_overview_animation_settings.h" |
| 6 | 6 |
| 7 #include "ash/wm/overview/overview_animation_type.h" | 7 #include "ash/wm/overview/overview_animation_type.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
| 10 #include "ui/compositor/layer.h" | 10 #include "ui/compositor/layer.h" |
| 11 #include "ui/gfx/animation/tween.h" | 11 #include "ui/gfx/animation/tween.h" |
| 12 | 12 |
| 13 namespace ash { | 13 namespace ash { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 // The time duration for transformation animations. | 17 // The time duration for transformation animations. |
| 18 const int kTransitionMilliseconds = 200; | 18 const int kTransitionMilliseconds = 200; |
| 19 | 19 |
| 20 // The time duration for widgets to fade in. | 20 // The time duration for widgets to fade in. |
| 21 const int kFadeInMilliseconds = 80; | 21 const int kFadeInMilliseconds = 80; |
| 22 | 22 |
| 23 // The time duration for widgets to fade out. |
| 24 const int kFadeOutMilliseconds = 100; |
| 25 |
| 23 base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) { | 26 base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) { |
| 24 switch (animation_type) { | 27 switch (animation_type) { |
| 25 case OVERVIEW_ANIMATION_NONE: | 28 case OVERVIEW_ANIMATION_NONE: |
| 29 case OVERVIEW_ANIMATION_SCROLL_SELECTOR_ITEM: |
| 26 return base::TimeDelta(); | 30 return base::TimeDelta(); |
| 27 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: | 31 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: |
| 28 return base::TimeDelta::FromMilliseconds(kFadeInMilliseconds); | 32 return base::TimeDelta::FromMilliseconds(kFadeInMilliseconds); |
| 33 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_OUT: |
| 34 return base::TimeDelta::FromMilliseconds(kFadeOutMilliseconds); |
| 29 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: | 35 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: |
| 30 case OVERVIEW_ANIMATION_RESTORE_WINDOW: | 36 case OVERVIEW_ANIMATION_RESTORE_WINDOW: |
| 31 case OVERVIEW_ANIMATION_HIDE_WINDOW: | 37 case OVERVIEW_ANIMATION_HIDE_WINDOW: |
| 38 case OVERVIEW_ANIMATION_CANCEL_SELECTOR_ITEM_SCROLL: |
| 32 return base::TimeDelta::FromMilliseconds(kTransitionMilliseconds); | 39 return base::TimeDelta::FromMilliseconds(kTransitionMilliseconds); |
| 33 } | 40 } |
| 34 NOTREACHED(); | 41 NOTREACHED(); |
| 35 return base::TimeDelta(); | 42 return base::TimeDelta(); |
| 36 } | 43 } |
| 37 | 44 |
| 38 } // namespace | 45 } // namespace |
| 39 | 46 |
| 40 ScopedOverviewAnimationSettings::ScopedOverviewAnimationSettings( | 47 ScopedOverviewAnimationSettings::ScopedOverviewAnimationSettings( |
| 41 OverviewAnimationType animation_type, | 48 OverviewAnimationType animation_type, |
| 42 aura::Window* window) | 49 aura::Window* window) |
| 43 : animation_settings_(window->layer()->GetAnimator()) { | 50 : animation_settings_(window->layer()->GetAnimator()) { |
| 44 | 51 |
| 45 switch (animation_type) { | 52 switch (animation_type) { |
| 46 case OVERVIEW_ANIMATION_NONE: | 53 case OVERVIEW_ANIMATION_NONE: |
| 54 case OVERVIEW_ANIMATION_SCROLL_SELECTOR_ITEM: |
| 47 animation_settings_.SetPreemptionStrategy( | 55 animation_settings_.SetPreemptionStrategy( |
| 48 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 56 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
| 49 break; | 57 break; |
| 50 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: | 58 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: |
| 51 window->layer()->GetAnimator()->SchedulePauseForProperties( | 59 window->layer()->GetAnimator()->SchedulePauseForProperties( |
| 52 GetAnimationDuration( | 60 GetAnimationDuration( |
| 53 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS), | 61 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS), |
| 54 ui::LayerAnimationElement::OPACITY); | 62 ui::LayerAnimationElement::OPACITY); |
| 55 animation_settings_.SetPreemptionStrategy( | 63 animation_settings_.SetPreemptionStrategy( |
| 56 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 64 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
| 57 break; | 65 break; |
| 66 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_OUT: |
| 67 animation_settings_.SetPreemptionStrategy( |
| 68 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
| 69 break; |
| 58 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: | 70 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: |
| 59 case OVERVIEW_ANIMATION_RESTORE_WINDOW: | 71 case OVERVIEW_ANIMATION_RESTORE_WINDOW: |
| 60 animation_settings_.SetPreemptionStrategy( | 72 animation_settings_.SetPreemptionStrategy( |
| 61 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 73 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 62 animation_settings_.SetTweenType(gfx::Tween::FAST_OUT_SLOW_IN); | 74 animation_settings_.SetTweenType(gfx::Tween::FAST_OUT_SLOW_IN); |
| 63 break; | 75 break; |
| 64 case OVERVIEW_ANIMATION_HIDE_WINDOW: | 76 case OVERVIEW_ANIMATION_HIDE_WINDOW: |
| 65 animation_settings_.SetPreemptionStrategy( | 77 animation_settings_.SetPreemptionStrategy( |
| 66 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 78 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 67 break; | 79 break; |
| 80 case OVERVIEW_ANIMATION_CANCEL_SELECTOR_ITEM_SCROLL: |
| 81 animation_settings_.SetPreemptionStrategy( |
| 82 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 83 animation_settings_.SetTweenType(gfx::Tween::EASE_IN_OUT); |
| 84 break; |
| 68 } | 85 } |
| 69 animation_settings_.SetTransitionDuration( | 86 animation_settings_.SetTransitionDuration( |
| 70 GetAnimationDuration(animation_type)); | 87 GetAnimationDuration(animation_type)); |
| 71 } | 88 } |
| 72 | 89 |
| 73 ScopedOverviewAnimationSettings::~ScopedOverviewAnimationSettings() { | 90 ScopedOverviewAnimationSettings::~ScopedOverviewAnimationSettings() { |
| 74 } | 91 } |
| 75 | 92 |
| 76 // static: | |
| 77 void ScopedOverviewAnimationSettings::SetupFadeInAfterLayout( | |
| 78 aura::Window* window) { | |
| 79 ui::Layer* layer = window->layer(); | |
| 80 layer->SetOpacity(0.0f); | |
| 81 ScopedOverviewAnimationSettings animation_settings( | |
| 82 OverviewAnimationType::OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN, | |
| 83 window); | |
| 84 layer->SetOpacity(1.0f); | |
| 85 } | |
| 86 | |
| 87 } // namespace ash | 93 } // namespace ash |
| OLD | NEW |