Commit cce7708f authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

overview: Do not animate overview header on enter exit.

This was already happening on tablet mode. Ux said it is ok to match
the two now. Also change some values for the header fade in animation.

Test: manual
Bug: 829292
Change-Id: I428081f0d19d1b8508e8576f5ea8a36e75843e6b
Reviewed-on: https://chromium-review.googlesource.com/1164534Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581613}
parent da2004a0
...@@ -14,8 +14,6 @@ enum OverviewAnimationType { ...@@ -14,8 +14,6 @@ enum OverviewAnimationType {
OVERVIEW_ANIMATION_NONE, OVERVIEW_ANIMATION_NONE,
// Used to fade in the close button and label. // Used to fade in the close button and label.
OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN, OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN,
// Used to fade in the close button and label, in tablet mode.
OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_TABLET_FADE_IN,
// Used to fade out the label. // Used to fade out the label.
OVERVIEW_ANIMATION_EXIT_OVERVIEW_MODE_FADE_OUT, OVERVIEW_ANIMATION_EXIT_OVERVIEW_MODE_FADE_OUT,
// Used to position windows when entering/exiting overview mode and when a // Used to position windows when entering/exiting overview mode and when a
......
...@@ -102,6 +102,17 @@ bool IsOverviewSwipeToCloseEnabled() { ...@@ -102,6 +102,17 @@ bool IsOverviewSwipeToCloseEnabled() {
return base::FeatureList::IsEnabled(features::kOverviewSwipeToClose); return base::FeatureList::IsEnabled(features::kOverviewSwipeToClose);
} }
void FadeInWidgetOnEnter(views::Widget* widget) {
aura::Window* window = widget->GetNativeWindow();
if (window->layer()->GetTargetOpacity() == 1.f)
return;
window->layer()->SetOpacity(0.0f);
ScopedOverviewAnimationSettings scoped_overview_animation_settings(
OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN, window);
window->layer()->SetOpacity(1.0f);
}
void FadeOutWidgetOnExit(std::unique_ptr<views::Widget> widget, void FadeOutWidgetOnExit(std::unique_ptr<views::Widget> widget,
OverviewAnimationType animation_type) { OverviewAnimationType animation_type) {
// The window selector controller may be nullptr on shutdown. // The window selector controller may be nullptr on shutdown.
......
...@@ -27,6 +27,9 @@ bool CanCoverAvailableWorkspace(aura::Window* window); ...@@ -27,6 +27,9 @@ bool CanCoverAvailableWorkspace(aura::Window* window);
bool IsOverviewSwipeToCloseEnabled(); bool IsOverviewSwipeToCloseEnabled();
// Fades |widget| to opacity one with the enter overview settings.
void FadeInWidgetOnEnter(views::Widget* widget);
// Fades |widget| to opacity zero with animation settings depending on // Fades |widget| to opacity zero with animation settings depending on
// |animation_type|. Used by several classes which need to be destroyed on // |animation_type|. Used by several classes which need to be destroyed on
// exiting overview, but have some widgets which need to continue animating. // exiting overview, but have some widgets which need to continue animating.
......
...@@ -18,42 +18,37 @@ namespace ash { ...@@ -18,42 +18,37 @@ namespace ash {
namespace { namespace {
// The time duration for transformation animations. // The time duration for transformation animations.
constexpr int kTransitionMilliseconds = 300; constexpr int kTransitionMs = 300;
// The time duration for fading out when closing an item. // The time duration for fading out when closing an item.
constexpr int kCloseFadeOutMilliseconds = 50; constexpr int kCloseFadeOutMs = 100;
// The time duration for scaling down when an item is closed. // The time duration for scaling down when an item is closed.
constexpr int kCloseScaleMilliseconds = 100; constexpr int kCloseScaleMs = 100;
// The time duration for widgets to fade in. // The time duration for widgets to fade in.
constexpr int kFadeInMilliseconds = 60; constexpr int kFadeInDelayMs = 83;
constexpr int kFadeInMs = 167;
// The time duration for widgets to fade in in tablet mode.
constexpr int kFadeInTabletMs = 300;
// The time duration for widgets to fade out. // The time duration for widgets to fade out.
constexpr int kFadeOutDelayMilliseconds = kTransitionMilliseconds * 1 / 5; constexpr int kFadeOutMs = 100;
constexpr int kFadeOutMilliseconds = kTransitionMilliseconds * 3 / 5;
base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) { base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) {
switch (animation_type) { switch (animation_type) {
case OVERVIEW_ANIMATION_NONE: case OVERVIEW_ANIMATION_NONE:
return base::TimeDelta(); return base::TimeDelta();
case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN:
return base::TimeDelta::FromMilliseconds(kFadeInMilliseconds); return base::TimeDelta::FromMilliseconds(kFadeInMs);
case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_TABLET_FADE_IN:
return base::TimeDelta::FromMilliseconds(kFadeInTabletMs);
case OVERVIEW_ANIMATION_EXIT_OVERVIEW_MODE_FADE_OUT: case OVERVIEW_ANIMATION_EXIT_OVERVIEW_MODE_FADE_OUT:
return base::TimeDelta::FromMilliseconds(kFadeOutMilliseconds); return base::TimeDelta::FromMilliseconds(kFadeOutMs);
case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS:
case OVERVIEW_ANIMATION_RESTORE_WINDOW: case OVERVIEW_ANIMATION_RESTORE_WINDOW:
case OVERVIEW_ANIMATION_RESTORE_WINDOW_ZERO: case OVERVIEW_ANIMATION_RESTORE_WINDOW_ZERO:
return base::TimeDelta::FromMilliseconds(kTransitionMilliseconds); return base::TimeDelta::FromMilliseconds(kTransitionMs);
case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM: case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM:
return base::TimeDelta::FromMilliseconds(kCloseScaleMilliseconds); return base::TimeDelta::FromMilliseconds(kCloseScaleMs);
case OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM: case OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM:
return base::TimeDelta::FromMilliseconds(kCloseFadeOutMilliseconds); return base::TimeDelta::FromMilliseconds(kCloseFadeOutMs);
} }
NOTREACHED(); NOTREACHED();
return base::TimeDelta(); return base::TimeDelta();
...@@ -114,7 +109,6 @@ ui::AnimationMetricsReporter* GetMetricsReporter( ...@@ -114,7 +109,6 @@ ui::AnimationMetricsReporter* GetMetricsReporter(
case OVERVIEW_ANIMATION_NONE: case OVERVIEW_ANIMATION_NONE:
return nullptr; return nullptr;
case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN:
case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_TABLET_FADE_IN:
case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS:
return g_reporter_enter.Pointer(); return g_reporter_enter.Pointer();
case OVERVIEW_ANIMATION_EXIT_OVERVIEW_MODE_FADE_OUT: case OVERVIEW_ANIMATION_EXIT_OVERVIEW_MODE_FADE_OUT:
...@@ -142,16 +136,15 @@ ScopedOverviewAnimationSettings::ScopedOverviewAnimationSettings( ...@@ -142,16 +136,15 @@ ScopedOverviewAnimationSettings::ScopedOverviewAnimationSettings(
ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
break; break;
case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN:
case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_TABLET_FADE_IN: window->layer()->GetAnimator()->SchedulePauseForProperties(
animation_settings_->SetTweenType(gfx::Tween::EASE_IN); base::TimeDelta::FromMilliseconds(kFadeInDelayMs),
ui::LayerAnimationElement::OPACITY);
animation_settings_->SetTweenType(gfx::Tween::FAST_OUT_SLOW_IN);
animation_settings_->SetPreemptionStrategy( animation_settings_->SetPreemptionStrategy(
ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
break; break;
case OVERVIEW_ANIMATION_EXIT_OVERVIEW_MODE_FADE_OUT: case OVERVIEW_ANIMATION_EXIT_OVERVIEW_MODE_FADE_OUT:
window->layer()->GetAnimator()->SchedulePauseForProperties( animation_settings_->SetTweenType(gfx::Tween::FAST_OUT_SLOW_IN);
base::TimeDelta::FromMilliseconds(kFadeOutDelayMilliseconds),
ui::LayerAnimationElement::OPACITY);
animation_settings_->SetTweenType(gfx::Tween::EASE_OUT);
animation_settings_->SetPreemptionStrategy( animation_settings_->SetPreemptionStrategy(
ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
break; break;
......
...@@ -225,7 +225,7 @@ void ScopedTransformOverviewWindow::RestoreWindow(bool reset_transform) { ...@@ -225,7 +225,7 @@ void ScopedTransformOverviewWindow::RestoreWindow(bool reset_transform) {
void ScopedTransformOverviewWindow::BeginScopedAnimation( void ScopedTransformOverviewWindow::BeginScopedAnimation(
OverviewAnimationType animation_type, OverviewAnimationType animation_type,
ScopedAnimationSettings* animation_settings) { ScopedAnimationSettings* animation_settings) {
if (animation_type == OverviewAnimationType::OVERVIEW_ANIMATION_NONE) if (animation_type == OVERVIEW_ANIMATION_NONE)
return; return;
// Remove the mask before animating because masks affect animation // Remove the mask before animating because masks affect animation
...@@ -584,11 +584,7 @@ void ScopedTransformOverviewWindow::CreateMirrorWindowForMinimizedState() { ...@@ -584,11 +584,7 @@ void ScopedTransformOverviewWindow::CreateMirrorWindowForMinimizedState() {
minimized_widget_->SetBounds(bounds); minimized_widget_->SetBounds(bounds);
minimized_widget_->Show(); minimized_widget_->Show();
minimized_widget_->SetOpacity(0.f); FadeInWidgetOnEnter(minimized_widget_.get());
ScopedOverviewAnimationSettings animation_settings(
OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_TABLET_FADE_IN,
minimized_widget_->GetNativeWindow());
minimized_widget_->SetOpacity(1.f);
} }
void ScopedTransformOverviewWindow::CreateAndApplyMaskAndShadow() { void ScopedTransformOverviewWindow::CreateAndApplyMaskAndShadow() {
......
...@@ -121,33 +121,6 @@ constexpr SkColor kBackdropColor = SkColorSetARGB(0x24, 0xFF, 0xFF, 0xFF); ...@@ -121,33 +121,6 @@ constexpr SkColor kBackdropColor = SkColorSetARGB(0x24, 0xFF, 0xFF, 0xFF);
// swipe to close. // swipe to close.
constexpr int kSwipeToCloseCloseTranslationDp = 96; constexpr int kSwipeToCloseCloseTranslationDp = 96;
// Windows in tablet have different animations. Overview headers do not
// translate when entering or exiting overview mode. Title bars also do not
// animate in, as tablet mode windows have no title bars. Exceptions are windows
// that are not maximized, minimized or snapped.
bool UseTabletModeAnimations(aura::Window* original_window) {
wm::WindowState* state = wm::GetWindowState(original_window);
return Shell::Get()
->tablet_mode_controller()
->IsTabletModeWindowManagerEnabled() &&
(state->IsMaximized() || state->IsMinimized() || state->IsSnapped());
}
// Convenience method to fade in a Window with predefined animation settings.
void SetupFadeInAfterLayout(views::Widget* widget,
aura::Window* original_window) {
aura::Window* window = widget->GetNativeWindow();
window->layer()->SetOpacity(0.0f);
ScopedOverviewAnimationSettings scoped_overview_animation_settings(
UseTabletModeAnimations(original_window)
? OverviewAnimationType::
OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_TABLET_FADE_IN
: OverviewAnimationType::
OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN,
window);
window->layer()->SetOpacity(1.0f);
}
std::unique_ptr<views::Widget> CreateBackdropWidget(aura::Window* parent) { std::unique_ptr<views::Widget> CreateBackdropWidget(aura::Window* parent) {
auto widget = CreateBackgroundWidget( auto widget = CreateBackgroundWidget(
/*root_window=*/nullptr, ui::LAYER_TEXTURED, kBackdropColor, /*root_window=*/nullptr, ui::LAYER_TEXTURED, kBackdropColor,
...@@ -519,7 +492,6 @@ void WindowSelectorItem::RestoreWindow(bool reset_transform) { ...@@ -519,7 +492,6 @@ void WindowSelectorItem::RestoreWindow(bool reset_transform) {
caption_container_view_->listener_button()->ResetListener(); caption_container_view_->listener_button()->ResetListener();
close_button_->ResetListener(); close_button_->ResetListener();
transform_window_.RestoreWindow(reset_transform); transform_window_.RestoreWindow(reset_transform);
UpdateHeaderLayout(HeaderFadeInMode::kExit, GetExitOverviewAnimationType());
} }
void WindowSelectorItem::EnsureVisible() { void WindowSelectorItem::EnsureVisible() {
...@@ -552,8 +524,7 @@ void WindowSelectorItem::Shutdown() { ...@@ -552,8 +524,7 @@ void WindowSelectorItem::Shutdown() {
void WindowSelectorItem::PrepareForOverview() { void WindowSelectorItem::PrepareForOverview() {
transform_window_.PrepareForOverview(); transform_window_.PrepareForOverview();
RestackItemWidget(); RestackItemWidget();
UpdateHeaderLayout(HeaderFadeInMode::kEnter, UpdateHeaderLayout(HeaderFadeInMode::kEnter, OVERVIEW_ANIMATION_NONE);
OverviewAnimationType::OVERVIEW_ANIMATION_NONE);
} }
float WindowSelectorItem::GetItemScale(const gfx::Size& size) { float WindowSelectorItem::GetItemScale(const gfx::Size& size) {
...@@ -581,13 +552,12 @@ void WindowSelectorItem::SetBounds(const gfx::Rect& target_bounds, ...@@ -581,13 +552,12 @@ void WindowSelectorItem::SetBounds(const gfx::Rect& target_bounds,
new_animation_type = OVERVIEW_ANIMATION_NONE; new_animation_type = OVERVIEW_ANIMATION_NONE;
base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true);
// If |target_bounds_| is empty, this is the first update. For tablet mode, // If |target_bounds_| is empty, this is the first update. Let
// let UpdateHeaderLayout know, as we do not want |item_widget_| to be // UpdateHeaderLayout know, as we do not want |item_widget_| to be animated
// animated with the window. // with the window.
HeaderFadeInMode mode = HeaderFadeInMode mode = target_bounds_.IsEmpty()
target_bounds_.IsEmpty() && UseTabletModeAnimations(GetWindow()) ? HeaderFadeInMode::kFirstUpdate
? HeaderFadeInMode::kFirstUpdate : HeaderFadeInMode::kUpdate;
: HeaderFadeInMode::kUpdate;
target_bounds_ = target_bounds; target_bounds_ = target_bounds;
gfx::Rect inset_bounds(target_bounds); gfx::Rect inset_bounds(target_bounds);
...@@ -641,7 +611,7 @@ void WindowSelectorItem::AnimateAndCloseWindow(bool up) { ...@@ -641,7 +611,7 @@ void WindowSelectorItem::AnimateAndCloseWindow(bool up) {
settings.AddObserver(this); settings.AddObserver(this);
}; };
AnimateOpacity(0.0, OverviewAnimationType::OVERVIEW_ANIMATION_RESTORE_WINDOW); AnimateOpacity(0.0, OVERVIEW_ANIMATION_RESTORE_WINDOW);
animate_window(item_widget_->GetNativeWindow(), transform, false); animate_window(item_widget_->GetNativeWindow(), transform, false);
animate_window(GetWindowForStacking(), transform, true); animate_window(GetWindowForStacking(), transform, true);
} }
...@@ -651,7 +621,7 @@ void WindowSelectorItem::CloseWindow() { ...@@ -651,7 +621,7 @@ void WindowSelectorItem::CloseWindow() {
inset_bounds.Inset(target_bounds_.width() * kPreCloseScale, inset_bounds.Inset(target_bounds_.width() * kPreCloseScale,
target_bounds_.height() * kPreCloseScale); target_bounds_.height() * kPreCloseScale);
OverviewAnimationType animation_type = OverviewAnimationType animation_type =
OverviewAnimationType::OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM; OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM;
// Scale down both the window and label. // Scale down both the window and label.
SetBounds(inset_bounds, animation_type); SetBounds(inset_bounds, animation_type);
// First animate opacity to an intermediate value concurrently with the // First animate opacity to an intermediate value concurrently with the
...@@ -659,8 +629,7 @@ void WindowSelectorItem::CloseWindow() { ...@@ -659,8 +629,7 @@ void WindowSelectorItem::CloseWindow() {
AnimateOpacity(kClosingItemOpacity, animation_type); AnimateOpacity(kClosingItemOpacity, animation_type);
// Fade out the window and the label, effectively hiding them. // Fade out the window and the label, effectively hiding them.
AnimateOpacity(0.0, AnimateOpacity(0.0, OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM);
OverviewAnimationType::OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM);
transform_window_.Close(); transform_window_.Close();
} }
...@@ -939,14 +908,13 @@ float WindowSelectorItem::GetOpacity() { ...@@ -939,14 +908,13 @@ float WindowSelectorItem::GetOpacity() {
OverviewAnimationType WindowSelectorItem::GetExitOverviewAnimationType() { OverviewAnimationType WindowSelectorItem::GetExitOverviewAnimationType() {
return should_animate_when_exiting_ return should_animate_when_exiting_
? OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS ? OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS
: OverviewAnimationType::OVERVIEW_ANIMATION_NONE; : OVERVIEW_ANIMATION_NONE;
} }
OverviewAnimationType WindowSelectorItem::GetExitTransformAnimationType() { OverviewAnimationType WindowSelectorItem::GetExitTransformAnimationType() {
return should_animate_when_exiting_ return should_animate_when_exiting_ ? OVERVIEW_ANIMATION_RESTORE_WINDOW
? OverviewAnimationType::OVERVIEW_ANIMATION_RESTORE_WINDOW : OVERVIEW_ANIMATION_RESTORE_WINDOW_ZERO;
: OverviewAnimationType::OVERVIEW_ANIMATION_RESTORE_WINDOW_ZERO;
} }
bool WindowSelectorItem::GetCloseButtonVisibilityForTesting() const { bool WindowSelectorItem::GetCloseButtonVisibilityForTesting() const {
...@@ -1053,14 +1021,6 @@ void WindowSelectorItem::CreateWindowLabel(const base::string16& title) { ...@@ -1053,14 +1021,6 @@ void WindowSelectorItem::CreateWindowLabel(const base::string16& title) {
void WindowSelectorItem::UpdateHeaderLayout( void WindowSelectorItem::UpdateHeaderLayout(
HeaderFadeInMode mode, HeaderFadeInMode mode,
OverviewAnimationType animation_type) { OverviewAnimationType animation_type) {
// Do not move the header on exit if the window is originally minimized
// or in tablet mode.
if (mode == HeaderFadeInMode::kExit &&
(UseTabletModeAnimations(GetWindow()) ||
wm::GetWindowState(GetWindow())->IsMinimized())) {
return;
}
gfx::Rect transformed_window_bounds = gfx::Rect transformed_window_bounds =
transform_window_.window_selector_bounds().value_or( transform_window_.window_selector_bounds().value_or(
transform_window_.GetTransformedBounds()); transform_window_.GetTransformedBounds());
...@@ -1077,15 +1037,14 @@ void WindowSelectorItem::UpdateHeaderLayout( ...@@ -1077,15 +1037,14 @@ void WindowSelectorItem::UpdateHeaderLayout(
if (!label_view_->visible()) { if (!label_view_->visible()) {
label_view_->SetVisible(true); label_view_->SetVisible(true);
SetupFadeInAfterLayout(item_widget_.get(), GetWindow()); FadeInWidgetOnEnter(item_widget_.get());
} }
aura::Window* widget_window = item_widget_->GetNativeWindow(); aura::Window* widget_window = item_widget_->GetNativeWindow();
// For the first update, place the widget at its destination. // For the first update, place the widget at its destination.
ScopedOverviewAnimationSettings animation_settings( ScopedOverviewAnimationSettings animation_settings(
mode == HeaderFadeInMode::kFirstUpdate mode == HeaderFadeInMode::kFirstUpdate ? OVERVIEW_ANIMATION_NONE
? OverviewAnimationType::OVERVIEW_ANIMATION_NONE : animation_type,
: animation_type,
widget_window); widget_window);
// |widget_window| covers both the transformed window and the header // |widget_window| covers both the transformed window and the header
// as well as the gap between the windows to prevent events from reaching // as well as the gap between the windows to prevent events from reaching
......
...@@ -255,15 +255,12 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener, ...@@ -255,15 +255,12 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
enum class HeaderFadeInMode { enum class HeaderFadeInMode {
// Used when entering overview mode, to fade in the header background color. // Used when entering overview mode, to fade in the header background color.
kEnter, kEnter,
// Used when the overview header bounds change for the first time, to // Used when the overview header bounds change for the first time to
// skip animating when in tablet mode. // skip animating.
kFirstUpdate, kFirstUpdate,
// Used when the overview header bounds change, to animate or move the // Used when the overview header bounds change, to animate or move the
// header // header to the desired bounds.
// to the desired bounds.
kUpdate, kUpdate,
// Used when exiting overview mode, to fade out the header background color.
kExit,
}; };
// Sets the bounds of this selector's items to |target_bounds| in // Sets the bounds of this selector's items to |target_bounds| in
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment