Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: ash/wm/overview/scoped_overview_animation_settings_aura.cc

Issue 2101843003: [ash-md] Animates a window closed while in overview mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [ash-md] Animates a window closed while in overview mode (comments) Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/time/time.h" 8 #include "base/time/time.h"
8 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
9 #include "ui/compositor/layer.h" 10 #include "ui/compositor/layer.h"
10 #include "ui/gfx/animation/tween.h" 11 #include "ui/gfx/animation/tween.h"
11 12
12 namespace ash { 13 namespace ash {
13 14
14 namespace { 15 namespace {
15 16
16 // The time duration for transformation animations. 17 // The time duration for transformation animations.
17 const int kTransitionMilliseconds = 200; 18 const int kTransitionMilliseconds = 200;
18 19
20 // The time duration for fading out when closing an item. Only used with
21 // Material Design.
22 const int kCloseFadeOutMillisecondsMd = 50;
23
24 // The time duration for scaling down when an item is closed. Only used with
25 // Material Design.
26 const int kCloseScaleMillisecondsMd = 100;
27
19 // The time duration for widgets to fade in. 28 // The time duration for widgets to fade in.
20 const int kFadeInMilliseconds = 80; 29 const int kFadeInMilliseconds = 80;
21 30
22 base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) { 31 base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) {
23 switch (animation_type) { 32 switch (animation_type) {
24 case OVERVIEW_ANIMATION_NONE: 33 case OVERVIEW_ANIMATION_NONE:
25 return base::TimeDelta(); 34 return base::TimeDelta();
26 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: 35 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN:
27 return base::TimeDelta::FromMilliseconds(kFadeInMilliseconds); 36 return base::TimeDelta::FromMilliseconds(kFadeInMilliseconds);
28 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: 37 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS:
29 case OVERVIEW_ANIMATION_RESTORE_WINDOW: 38 case OVERVIEW_ANIMATION_RESTORE_WINDOW:
30 case OVERVIEW_ANIMATION_HIDE_WINDOW: 39 case OVERVIEW_ANIMATION_HIDE_WINDOW:
31 return base::TimeDelta::FromMilliseconds(kTransitionMilliseconds); 40 return base::TimeDelta::FromMilliseconds(kTransitionMilliseconds);
41 case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM:
42 return base::TimeDelta::FromMilliseconds(kCloseScaleMillisecondsMd);
43 case OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM:
44 return base::TimeDelta::FromMilliseconds(kCloseFadeOutMillisecondsMd);
32 } 45 }
33 NOTREACHED(); 46 NOTREACHED();
34 return base::TimeDelta(); 47 return base::TimeDelta();
35 } 48 }
36 49
37 } // namespace 50 } // namespace
38 51
39 ScopedOverviewAnimationSettingsAura::ScopedOverviewAnimationSettingsAura( 52 ScopedOverviewAnimationSettingsAura::ScopedOverviewAnimationSettingsAura(
40 OverviewAnimationType animation_type, 53 OverviewAnimationType animation_type,
41 aura::Window* window) 54 aura::Window* window)
42 : animation_settings_(window->layer()->GetAnimator()) { 55 : animation_settings_(window->layer()->GetAnimator()) {
43 switch (animation_type) { 56 switch (animation_type) {
44 case OVERVIEW_ANIMATION_NONE: 57 case OVERVIEW_ANIMATION_NONE:
45 animation_settings_.SetPreemptionStrategy( 58 animation_settings_.SetPreemptionStrategy(
46 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); 59 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
47 break; 60 break;
48 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: 61 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN:
49 window->layer()->GetAnimator()->SchedulePauseForProperties( 62 window->layer()->GetAnimator()->SchedulePauseForProperties(
50 GetAnimationDuration( 63 GetAnimationDuration(
51 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS), 64 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS),
52 ui::LayerAnimationElement::OPACITY); 65 ui::LayerAnimationElement::OPACITY);
53 animation_settings_.SetPreemptionStrategy( 66 animation_settings_.SetPreemptionStrategy(
54 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); 67 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
55 break; 68 break;
56 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: 69 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS:
57 case OVERVIEW_ANIMATION_RESTORE_WINDOW: 70 case OVERVIEW_ANIMATION_RESTORE_WINDOW:
58 animation_settings_.SetPreemptionStrategy( 71 animation_settings_.SetPreemptionStrategy(
59 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 72 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
60 animation_settings_.SetTweenType(gfx::Tween::FAST_OUT_SLOW_IN); 73 animation_settings_.SetTweenType(
74 ash::MaterialDesignController::IsOverviewMaterial()
75 ? gfx::Tween::EASE_IN_2
76 : gfx::Tween::FAST_OUT_SLOW_IN);
77 break;
78 case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM:
79 case OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM:
80 animation_settings_.SetPreemptionStrategy(
81 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
82 animation_settings_.SetTweenType(gfx::Tween::EASE_OUT);
61 break; 83 break;
62 case OVERVIEW_ANIMATION_HIDE_WINDOW: 84 case OVERVIEW_ANIMATION_HIDE_WINDOW:
63 animation_settings_.SetPreemptionStrategy( 85 animation_settings_.SetPreemptionStrategy(
64 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 86 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
65 break; 87 break;
66 } 88 }
67 animation_settings_.SetTransitionDuration( 89 animation_settings_.SetTransitionDuration(
68 GetAnimationDuration(animation_type)); 90 GetAnimationDuration(animation_type));
69 } 91 }
70 92
71 ScopedOverviewAnimationSettingsAura::~ScopedOverviewAnimationSettingsAura() {} 93 ScopedOverviewAnimationSettingsAura::~ScopedOverviewAnimationSettingsAura() {}
72 94
73 } // namespace ash 95 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698