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_aura.h" | 5 #include "ash/wm/overview/scoped_overview_animation_settings_aura.h" |
6 | 6 |
7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.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 = 300; |
19 | 19 |
20 // The time duration for fading out when closing an item. Only used with | 20 // The time duration for fading out when closing an item. Only used with |
21 // Material Design. | 21 // Material Design. |
22 const int kCloseFadeOutMillisecondsMd = 50; | 22 const int kCloseFadeOutMillisecondsMd = 50; |
23 | 23 |
24 // The time duration for scaling down when an item is closed. Only used with | 24 // The time duration for scaling down when an item is closed. Only used with |
25 // Material Design. | 25 // Material Design. |
26 const int kCloseScaleMillisecondsMd = 100; | 26 const int kCloseScaleMillisecondsMd = 100; |
27 | 27 |
28 // The time duration for widgets to fade in. | 28 // The time duration for widgets to fade in. |
29 const int kFadeInMilliseconds = 80; | 29 const int kFadeInMilliseconds = 160; |
30 | 30 |
31 base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) { | 31 base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) { |
32 switch (animation_type) { | 32 switch (animation_type) { |
33 case OVERVIEW_ANIMATION_NONE: | 33 case OVERVIEW_ANIMATION_NONE: |
34 return base::TimeDelta(); | 34 return base::TimeDelta(); |
35 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: | 35 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: |
36 return base::TimeDelta::FromMilliseconds(kTransitionMilliseconds); | |
37 case OVERVIEW_ANIMATION_FADE_IN_HEADER: | |
36 return base::TimeDelta::FromMilliseconds(kFadeInMilliseconds); | 38 return base::TimeDelta::FromMilliseconds(kFadeInMilliseconds); |
37 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: | 39 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: |
38 case OVERVIEW_ANIMATION_RESTORE_WINDOW: | 40 case OVERVIEW_ANIMATION_RESTORE_WINDOW: |
39 case OVERVIEW_ANIMATION_HIDE_WINDOW: | 41 case OVERVIEW_ANIMATION_HIDE_WINDOW: |
40 return base::TimeDelta::FromMilliseconds(kTransitionMilliseconds); | 42 return base::TimeDelta::FromMilliseconds(kTransitionMilliseconds); |
41 case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM: | 43 case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM: |
42 return base::TimeDelta::FromMilliseconds(kCloseScaleMillisecondsMd); | 44 return base::TimeDelta::FromMilliseconds(kCloseScaleMillisecondsMd); |
43 case OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM: | 45 case OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM: |
44 return base::TimeDelta::FromMilliseconds(kCloseFadeOutMillisecondsMd); | 46 return base::TimeDelta::FromMilliseconds(kCloseFadeOutMillisecondsMd); |
45 } | 47 } |
46 NOTREACHED(); | 48 NOTREACHED(); |
47 return base::TimeDelta(); | 49 return base::TimeDelta(); |
48 } | 50 } |
49 | 51 |
50 } // namespace | 52 } // namespace |
51 | 53 |
52 ScopedOverviewAnimationSettingsAura::ScopedOverviewAnimationSettingsAura( | 54 ScopedOverviewAnimationSettingsAura::ScopedOverviewAnimationSettingsAura( |
53 OverviewAnimationType animation_type, | 55 OverviewAnimationType animation_type, |
54 aura::Window* window) | 56 aura::Window* window) |
55 : animation_settings_(window->layer()->GetAnimator()) { | 57 : animation_settings_(window->layer()->GetAnimator()) { |
58 const bool material = ash::MaterialDesignController::IsOverviewMaterial(); | |
56 switch (animation_type) { | 59 switch (animation_type) { |
57 case OVERVIEW_ANIMATION_NONE: | 60 case OVERVIEW_ANIMATION_NONE: |
58 animation_settings_.SetPreemptionStrategy( | 61 animation_settings_.SetPreemptionStrategy( |
59 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 62 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
60 break; | 63 break; |
61 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: | 64 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: |
62 window->layer()->GetAnimator()->SchedulePauseForProperties( | 65 if (!material) { |
63 GetAnimationDuration( | 66 window->layer()->GetAnimator()->SchedulePauseForProperties( |
64 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS), | 67 GetAnimationDuration(OverviewAnimationType:: |
65 ui::LayerAnimationElement::OPACITY); | 68 OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS), |
69 ui::LayerAnimationElement::OPACITY); | |
70 } | |
66 animation_settings_.SetPreemptionStrategy( | 71 animation_settings_.SetPreemptionStrategy( |
67 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 72 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
73 if (material) | |
bruthig
2016/08/30 17:57:33
nit: Can this be an else block from the block star
varkha
2016/09/02 11:22:51
Done.
| |
74 animation_settings_.SetTweenType(gfx::Tween::EASE_OUT); | |
75 break; | |
76 case OVERVIEW_ANIMATION_FADE_IN_HEADER: | |
77 animation_settings_.SetPreemptionStrategy( | |
78 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); | |
79 animation_settings_.SetTweenType(gfx::Tween::EASE_OUT); | |
68 break; | 80 break; |
69 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: | 81 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: |
70 case OVERVIEW_ANIMATION_RESTORE_WINDOW: | 82 case OVERVIEW_ANIMATION_RESTORE_WINDOW: |
71 animation_settings_.SetPreemptionStrategy( | 83 animation_settings_.SetPreemptionStrategy( |
72 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 84 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
73 animation_settings_.SetTweenType( | 85 animation_settings_.SetTweenType(material ? gfx::Tween::EASE_IN_OUT |
74 ash::MaterialDesignController::IsOverviewMaterial() | 86 : gfx::Tween::FAST_OUT_SLOW_IN); |
75 ? gfx::Tween::EASE_IN_2 | |
76 : gfx::Tween::FAST_OUT_SLOW_IN); | |
77 break; | 87 break; |
78 case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM: | 88 case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM: |
79 case OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM: | 89 case OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM: |
80 animation_settings_.SetPreemptionStrategy( | 90 animation_settings_.SetPreemptionStrategy( |
81 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); | 91 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); |
82 animation_settings_.SetTweenType(gfx::Tween::EASE_OUT); | 92 animation_settings_.SetTweenType(gfx::Tween::EASE_OUT); |
83 break; | 93 break; |
84 case OVERVIEW_ANIMATION_HIDE_WINDOW: | 94 case OVERVIEW_ANIMATION_HIDE_WINDOW: |
85 animation_settings_.SetPreemptionStrategy( | 95 animation_settings_.SetPreemptionStrategy( |
86 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 96 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
87 break; | 97 break; |
88 } | 98 } |
89 animation_settings_.SetTransitionDuration( | 99 animation_settings_.SetTransitionDuration( |
90 GetAnimationDuration(animation_type)); | 100 GetAnimationDuration(animation_type)); |
91 } | 101 } |
92 | 102 |
93 ScopedOverviewAnimationSettingsAura::~ScopedOverviewAnimationSettingsAura() {} | 103 ScopedOverviewAnimationSettingsAura::~ScopedOverviewAnimationSettingsAura() {} |
94 | 104 |
95 } // namespace ash | 105 } // namespace ash |
OLD | NEW |