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

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

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