| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ash/wm/overview/scoped_overview_animation_settings.h" | |
| 6 | |
| 7 #include "ash/wm/overview/overview_animation_type.h" | |
| 8 #include "base/time/time.h" | |
| 9 #include "ui/aura/window.h" | |
| 10 #include "ui/compositor/layer.h" | |
| 11 #include "ui/gfx/animation/tween.h" | |
| 12 | |
| 13 namespace ash { | |
| 14 | |
| 15 namespace { | |
| 16 | |
| 17 // The time duration for transformation animations. | |
| 18 const int kTransitionMilliseconds = 200; | |
| 19 | |
| 20 // The time duration for widgets to fade in. | |
| 21 const int kFadeInMilliseconds = 80; | |
| 22 | |
| 23 base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) { | |
| 24 switch (animation_type) { | |
| 25 case OVERVIEW_ANIMATION_NONE: | |
| 26 return base::TimeDelta(); | |
| 27 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: | |
| 28 return base::TimeDelta::FromMilliseconds(kFadeInMilliseconds); | |
| 29 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: | |
| 30 case OVERVIEW_ANIMATION_RESTORE_WINDOW: | |
| 31 case OVERVIEW_ANIMATION_HIDE_WINDOW: | |
| 32 return base::TimeDelta::FromMilliseconds(kTransitionMilliseconds); | |
| 33 } | |
| 34 NOTREACHED(); | |
| 35 return base::TimeDelta(); | |
| 36 } | |
| 37 | |
| 38 } // namespace | |
| 39 | |
| 40 ScopedOverviewAnimationSettings::ScopedOverviewAnimationSettings( | |
| 41 OverviewAnimationType animation_type, | |
| 42 aura::Window* window) | |
| 43 : animation_settings_(window->layer()->GetAnimator()) { | |
| 44 | |
| 45 switch (animation_type) { | |
| 46 case OVERVIEW_ANIMATION_NONE: | |
| 47 animation_settings_.SetPreemptionStrategy( | |
| 48 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | |
| 49 break; | |
| 50 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: | |
| 51 window->layer()->GetAnimator()->SchedulePauseForProperties( | |
| 52 GetAnimationDuration( | |
| 53 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS), | |
| 54 ui::LayerAnimationElement::OPACITY); | |
| 55 animation_settings_.SetPreemptionStrategy( | |
| 56 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | |
| 57 break; | |
| 58 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: | |
| 59 case OVERVIEW_ANIMATION_RESTORE_WINDOW: | |
| 60 animation_settings_.SetPreemptionStrategy( | |
| 61 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | |
| 62 animation_settings_.SetTweenType(gfx::Tween::FAST_OUT_SLOW_IN); | |
| 63 break; | |
| 64 case OVERVIEW_ANIMATION_HIDE_WINDOW: | |
| 65 animation_settings_.SetPreemptionStrategy( | |
| 66 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | |
| 67 break; | |
| 68 } | |
| 69 animation_settings_.SetTransitionDuration( | |
| 70 GetAnimationDuration(animation_type)); | |
| 71 } | |
| 72 | |
| 73 ScopedOverviewAnimationSettings::~ScopedOverviewAnimationSettings() { | |
| 74 } | |
| 75 | |
| 76 } // namespace ash | |
| OLD | NEW |