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

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

Issue 2329433003: Revert of [ash-md] Fades overview header in and out (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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 "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/compositor/layer_animation_observer.h"
12 #include "ui/compositor/scoped_layer_animation_settings.h"
13 #include "ui/gfx/animation/tween.h" 11 #include "ui/gfx/animation/tween.h"
14 12
15 namespace ash { 13 namespace ash {
16 14
17 namespace { 15 namespace {
18 16
19 // The time duration for transformation animations. 17 // The time duration for transformation animations.
20 const int kTransitionMilliseconds = 300; 18 const int kTransitionMilliseconds = 200;
21 19
22 // 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
23 // Material Design. 21 // Material Design.
24 const int kCloseFadeOutMillisecondsMd = 50; 22 const int kCloseFadeOutMillisecondsMd = 50;
25 23
26 // 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
27 // Material Design. 25 // Material Design.
28 const int kCloseScaleMillisecondsMd = 100; 26 const int kCloseScaleMillisecondsMd = 100;
29 27
30 // The time duration for widgets to fade in. 28 // The time duration for widgets to fade in.
31 const int kFadeInMilliseconds = 60; 29 const int kFadeInMilliseconds = 80;
32
33 // The time duration for widgets to fade out.
34 const int kFadeOutDelayMilliseconds = kTransitionMilliseconds * 1 / 5;
35 const int kFadeOutMilliseconds = kTransitionMilliseconds * 3 / 5;
36 30
37 base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) { 31 base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) {
38 const bool material = ash::MaterialDesignController::IsOverviewMaterial();
39 switch (animation_type) { 32 switch (animation_type) {
40 case OVERVIEW_ANIMATION_NONE: 33 case OVERVIEW_ANIMATION_NONE:
41 return base::TimeDelta(); 34 return base::TimeDelta();
42 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: 35 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN:
43 return base::TimeDelta::FromMilliseconds( 36 return base::TimeDelta::FromMilliseconds(kFadeInMilliseconds);
44 material ? kFadeInMilliseconds : kTransitionMilliseconds);
45 case OVERVIEW_ANIMATION_EXIT_OVERVIEW_MODE_FADE_OUT:
46 return base::TimeDelta::FromMilliseconds(kFadeOutMilliseconds);
47 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: 37 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS:
48 case OVERVIEW_ANIMATION_RESTORE_WINDOW: 38 case OVERVIEW_ANIMATION_RESTORE_WINDOW:
39 case OVERVIEW_ANIMATION_HIDE_WINDOW:
49 return base::TimeDelta::FromMilliseconds(kTransitionMilliseconds); 40 return base::TimeDelta::FromMilliseconds(kTransitionMilliseconds);
50 case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM: 41 case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM:
51 return base::TimeDelta::FromMilliseconds(kCloseScaleMillisecondsMd); 42 return base::TimeDelta::FromMilliseconds(kCloseScaleMillisecondsMd);
52 case OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM: 43 case OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM:
53 return base::TimeDelta::FromMilliseconds(kCloseFadeOutMillisecondsMd); 44 return base::TimeDelta::FromMilliseconds(kCloseFadeOutMillisecondsMd);
54 } 45 }
55 NOTREACHED(); 46 NOTREACHED();
56 return base::TimeDelta(); 47 return base::TimeDelta();
57 } 48 }
58 49
59 } // namespace 50 } // namespace
60 51
61 ScopedOverviewAnimationSettingsAura::ScopedOverviewAnimationSettingsAura( 52 ScopedOverviewAnimationSettingsAura::ScopedOverviewAnimationSettingsAura(
62 OverviewAnimationType animation_type, 53 OverviewAnimationType animation_type,
63 aura::Window* window) 54 aura::Window* window)
64 : animation_settings_(new ui::ScopedLayerAnimationSettings( 55 : animation_settings_(window->layer()->GetAnimator()) {
65 window->layer()->GetAnimator())) {
66 const bool material = ash::MaterialDesignController::IsOverviewMaterial();
67 switch (animation_type) { 56 switch (animation_type) {
68 case OVERVIEW_ANIMATION_NONE: 57 case OVERVIEW_ANIMATION_NONE:
69 animation_settings_->SetPreemptionStrategy( 58 animation_settings_.SetPreemptionStrategy(
70 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); 59 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
71 break; 60 break;
72 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: 61 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN:
73 if (material) {
74 animation_settings_->SetTweenType(gfx::Tween::EASE_IN);
75 } else {
76 window->layer()->GetAnimator()->SchedulePauseForProperties(
77 GetAnimationDuration(OverviewAnimationType::
78 OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS),
79 ui::LayerAnimationElement::OPACITY);
80 }
81 animation_settings_->SetPreemptionStrategy(
82 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
83 break;
84 case OVERVIEW_ANIMATION_EXIT_OVERVIEW_MODE_FADE_OUT:
85 window->layer()->GetAnimator()->SchedulePauseForProperties( 62 window->layer()->GetAnimator()->SchedulePauseForProperties(
86 base::TimeDelta::FromMilliseconds(kFadeOutDelayMilliseconds), 63 GetAnimationDuration(
64 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS),
87 ui::LayerAnimationElement::OPACITY); 65 ui::LayerAnimationElement::OPACITY);
88 animation_settings_->SetTweenType(gfx::Tween::EASE_OUT); 66 animation_settings_.SetPreemptionStrategy(
89 animation_settings_->SetPreemptionStrategy(
90 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); 67 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
91 break; 68 break;
92 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: 69 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS:
93 case OVERVIEW_ANIMATION_RESTORE_WINDOW: 70 case OVERVIEW_ANIMATION_RESTORE_WINDOW:
94 animation_settings_->SetPreemptionStrategy( 71 animation_settings_.SetPreemptionStrategy(
95 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 72 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
96 animation_settings_->SetTweenType( 73 animation_settings_.SetTweenType(
97 material ? gfx::Tween::EASE_OUT : gfx::Tween::FAST_OUT_SLOW_IN); 74 ash::MaterialDesignController::IsOverviewMaterial()
75 ? gfx::Tween::EASE_IN_2
76 : gfx::Tween::FAST_OUT_SLOW_IN);
98 break; 77 break;
99 case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM: 78 case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM:
100 case OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM: 79 case OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM:
101 animation_settings_->SetPreemptionStrategy( 80 animation_settings_.SetPreemptionStrategy(
102 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); 81 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
103 animation_settings_->SetTweenType(gfx::Tween::EASE_OUT); 82 animation_settings_.SetTweenType(gfx::Tween::EASE_OUT);
83 break;
84 case OVERVIEW_ANIMATION_HIDE_WINDOW:
85 animation_settings_.SetPreemptionStrategy(
86 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
104 break; 87 break;
105 } 88 }
106 animation_settings_->SetTransitionDuration( 89 animation_settings_.SetTransitionDuration(
107 GetAnimationDuration(animation_type)); 90 GetAnimationDuration(animation_type));
108 } 91 }
109 92
110 ScopedOverviewAnimationSettingsAura::~ScopedOverviewAnimationSettingsAura() {} 93 ScopedOverviewAnimationSettingsAura::~ScopedOverviewAnimationSettingsAura() {}
111 94
112 void ScopedOverviewAnimationSettingsAura::AddObserver(
113 ui::ImplicitAnimationObserver* observer) {
114 animation_settings_->AddObserver(observer);
115 }
116
117 } // namespace ash 95 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/overview/scoped_overview_animation_settings_aura.h ('k') | ash/wm/overview/window_selector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698