| 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 base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) { | 23 base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) { |
| 24 switch (animation_type) { | 24 switch (animation_type) { |
| 25 case OVERVIEW_ANIMATION_NONE: | 25 case OVERVIEW_ANIMATION_NONE: |
| 26 case SELECTOR_ITEM_SCROLL: |
| 26 return base::TimeDelta(); | 27 return base::TimeDelta(); |
| 27 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: | 28 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: |
| 28 return base::TimeDelta::FromMilliseconds(kFadeInMilliseconds); | 29 return base::TimeDelta::FromMilliseconds(kFadeInMilliseconds); |
| 29 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: | 30 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: |
| 30 case OVERVIEW_ANIMATION_RESTORE_WINDOW: | 31 case OVERVIEW_ANIMATION_RESTORE_WINDOW: |
| 31 case OVERVIEW_ANIMATION_HIDE_WINDOW: | 32 case OVERVIEW_ANIMATION_HIDE_WINDOW: |
| 32 return base::TimeDelta::FromMilliseconds(kTransitionMilliseconds); | 33 return base::TimeDelta::FromMilliseconds(kTransitionMilliseconds); |
| 34 case SELECTOR_ITEM_SCROLL_CANCEL: |
| 35 return base::TimeDelta::FromMilliseconds(kTransitionMilliseconds); |
| 33 } | 36 } |
| 34 NOTREACHED(); | 37 NOTREACHED(); |
| 35 return base::TimeDelta(); | 38 return base::TimeDelta(); |
| 36 } | 39 } |
| 37 | 40 |
| 38 } // namespace | 41 } // namespace |
| 39 | 42 |
| 40 ScopedOverviewAnimationSettings::ScopedOverviewAnimationSettings( | 43 ScopedOverviewAnimationSettings::ScopedOverviewAnimationSettings( |
| 41 OverviewAnimationType animation_type, | 44 OverviewAnimationType animation_type, |
| 42 aura::Window* window) | 45 aura::Window* window) |
| 43 : animation_settings_(window->layer()->GetAnimator()) { | 46 : animation_settings_(window->layer()->GetAnimator()) { |
| 44 | 47 |
| 45 switch (animation_type) { | 48 switch (animation_type) { |
| 46 case OVERVIEW_ANIMATION_NONE: | 49 case OVERVIEW_ANIMATION_NONE: |
| 50 case SELECTOR_ITEM_SCROLL: |
| 47 animation_settings_.SetPreemptionStrategy( | 51 animation_settings_.SetPreemptionStrategy( |
| 48 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 52 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
| 49 break; | 53 break; |
| 50 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: | 54 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: |
| 51 window->layer()->GetAnimator()->SchedulePauseForProperties( | 55 window->layer()->GetAnimator()->SchedulePauseForProperties( |
| 52 GetAnimationDuration( | 56 GetAnimationDuration( |
| 53 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS), | 57 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS), |
| 54 ui::LayerAnimationElement::OPACITY); | 58 ui::LayerAnimationElement::OPACITY); |
| 55 animation_settings_.SetPreemptionStrategy( | 59 animation_settings_.SetPreemptionStrategy( |
| 56 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 60 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
| 57 break; | 61 break; |
| 58 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: | 62 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: |
| 59 case OVERVIEW_ANIMATION_RESTORE_WINDOW: | 63 case OVERVIEW_ANIMATION_RESTORE_WINDOW: |
| 60 animation_settings_.SetPreemptionStrategy( | 64 animation_settings_.SetPreemptionStrategy( |
| 61 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 65 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 62 animation_settings_.SetTweenType(gfx::Tween::FAST_OUT_SLOW_IN); | 66 animation_settings_.SetTweenType(gfx::Tween::FAST_OUT_SLOW_IN); |
| 63 break; | 67 break; |
| 64 case OVERVIEW_ANIMATION_HIDE_WINDOW: | 68 case OVERVIEW_ANIMATION_HIDE_WINDOW: |
| 65 animation_settings_.SetPreemptionStrategy( | 69 animation_settings_.SetPreemptionStrategy( |
| 66 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 70 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 67 break; | 71 break; |
| 72 case SELECTOR_ITEM_SCROLL_CANCEL: |
| 73 animation_settings_.SetPreemptionStrategy( |
| 74 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 75 animation_settings_.SetTweenType(gfx::Tween::EASE_IN_OUT); |
| 76 break; |
| 68 } | 77 } |
| 69 animation_settings_.SetTransitionDuration( | 78 animation_settings_.SetTransitionDuration( |
| 70 GetAnimationDuration(animation_type)); | 79 GetAnimationDuration(animation_type)); |
| 71 } | 80 } |
| 72 | 81 |
| 73 ScopedOverviewAnimationSettings::~ScopedOverviewAnimationSettings() { | 82 ScopedOverviewAnimationSettings::~ScopedOverviewAnimationSettings() { |
| 74 } | 83 } |
| 75 | 84 |
| 76 } // namespace ash | 85 } // namespace ash |
| OLD | NEW |