Commit 54d566e6 authored by Eliot Courtney's avatar Eliot Courtney Committed by Commit Bot

Apply slide out animation type to PIP window on show.

    applied both times.

Bug: 908337
Test: Open and close a Chrome PIP window twice. Slide out animation is
Change-Id: I617e008070f733184d635486ea3c14b260838c8b
Reviewed-on: https://chromium-review.googlesource.com/c/1350026
Commit-Queue: Eliot Courtney <edcourtney@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611995}
parent 3ed559be
...@@ -21,9 +21,9 @@ enum WindowVisibilityAnimationType { ...@@ -21,9 +21,9 @@ enum WindowVisibilityAnimationType {
// Window slides down from above screen to show and, meanwhile, home launcher // Window slides down from above screen to show and, meanwhile, home launcher
// slides down off screen. // slides down off screen.
WINDOW_VISIBILITY_ANIMATION_TYPE_SLIDE_DOWN, WINDOW_VISIBILITY_ANIMATION_TYPE_SLIDE_DOWN,
// Animate a window out of the closest side of the screen. // Animate a window out of the closest side of the screen. Fade in if it
// This is for hiding only, and does not do anything for showing. // re-appears.
WINDOW_VISIBILITY_ANIMATION_TYPE_SLIDE_OUT, WINDOW_VISIBILITY_ANIMATION_TYPE_FADE_IN_SLIDE_OUT,
}; };
} // namespace wm } // namespace wm
......
...@@ -157,7 +157,7 @@ void BaseState::UpdateMinimizedState( ...@@ -157,7 +157,7 @@ void BaseState::UpdateMinimizedState(
// app, but minimized. // app, but minimized.
::wm::SetWindowVisibilityAnimationType( ::wm::SetWindowVisibilityAnimationType(
window, previous_state_type == mojom::WindowStateType::PIP window, previous_state_type == mojom::WindowStateType::PIP
? WINDOW_VISIBILITY_ANIMATION_TYPE_SLIDE_OUT ? WINDOW_VISIBILITY_ANIMATION_TYPE_FADE_IN_SLIDE_OUT
: WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); : WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
window->Hide(); window->Hide();
......
...@@ -54,6 +54,9 @@ const float kCrossFadeDurationMaxMs = 400.f; ...@@ -54,6 +54,9 @@ const float kCrossFadeDurationMaxMs = 400.f;
// Durations for the brightness/grayscale fade animation, in milliseconds. // Durations for the brightness/grayscale fade animation, in milliseconds.
const int kBrightnessGrayscaleFadeDurationMs = 1000; const int kBrightnessGrayscaleFadeDurationMs = 1000;
// Duration for fade in animation, in milliseconds.
const int kFadeInAnimationMs = 200;
// Brightness/grayscale values for hide/show window animations. // Brightness/grayscale values for hide/show window animations.
const float kWindowAnimation_HideBrightnessGrayscale = 1.f; const float kWindowAnimation_HideBrightnessGrayscale = 1.f;
const float kWindowAnimation_ShowBrightnessGrayscale = 0.f; const float kWindowAnimation_ShowBrightnessGrayscale = 0.f;
...@@ -228,6 +231,16 @@ void AnimateShowWindow_BrightnessGrayscale(aura::Window* window) { ...@@ -228,6 +231,16 @@ void AnimateShowWindow_BrightnessGrayscale(aura::Window* window) {
AnimateShowHideWindowCommon_BrightnessGrayscale(window, true); AnimateShowHideWindowCommon_BrightnessGrayscale(window, true);
} }
// TODO(edcourtney): Consolidate with AnimateShowWindow_Fade in ui/wm/core.
void AnimateShowWindow_FadeIn(aura::Window* window) {
window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
settings.SetTransitionDuration(
base::TimeDelta::FromMilliseconds(kFadeInAnimationMs));
window->layer()->SetVisible(true);
window->layer()->SetOpacity(kWindowAnimation_ShowOpacity);
}
void AnimateHideWindow_BrightnessGrayscale(aura::Window* window) { void AnimateHideWindow_BrightnessGrayscale(aura::Window* window) {
AnimateShowHideWindowCommon_BrightnessGrayscale(window, false); AnimateShowHideWindowCommon_BrightnessGrayscale(window, false);
} }
...@@ -281,12 +294,6 @@ void AnimateHideWindow_SlideOut(aura::Window* window) { ...@@ -281,12 +294,6 @@ void AnimateHideWindow_SlideOut(aura::Window* window) {
gfx::Rect dismissed_bounds = gfx::Rect dismissed_bounds =
PipPositioner::GetDismissedPosition(display, bounds); PipPositioner::GetDismissedPosition(display, bounds);
window->layer()->SetBounds(dismissed_bounds); window->layer()->SetBounds(dismissed_bounds);
// For Android PIP windows, they become minimized app windows after
// dismissal, so make sure to reset their animation type back to
// default.
::wm::SetWindowVisibilityAnimationType(
window, ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT);
} }
bool AnimateShowWindow(aura::Window* window) { bool AnimateShowWindow(aura::Window* window) {
...@@ -305,9 +312,9 @@ bool AnimateShowWindow(aura::Window* window) { ...@@ -305,9 +312,9 @@ bool AnimateShowWindow(aura::Window* window) {
case wm::WINDOW_VISIBILITY_ANIMATION_TYPE_SLIDE_DOWN: case wm::WINDOW_VISIBILITY_ANIMATION_TYPE_SLIDE_DOWN:
return AnimateShowWindow_SlideDown(window); return AnimateShowWindow_SlideDown(window);
return true; return true;
case wm::WINDOW_VISIBILITY_ANIMATION_TYPE_SLIDE_OUT: case wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE_IN_SLIDE_OUT:
// Slide out is exclusively a hide animation. AnimateShowWindow_FadeIn(window);
return false; return true;
default: default:
NOTREACHED(); NOTREACHED();
return false; return false;
...@@ -329,7 +336,7 @@ bool AnimateHideWindow(aura::Window* window) { ...@@ -329,7 +336,7 @@ bool AnimateHideWindow(aura::Window* window) {
return true; return true;
case wm::WINDOW_VISIBILITY_ANIMATION_TYPE_SLIDE_DOWN: case wm::WINDOW_VISIBILITY_ANIMATION_TYPE_SLIDE_DOWN:
return AnimateHideWindow_SlideDown(window); return AnimateHideWindow_SlideDown(window);
case wm::WINDOW_VISIBILITY_ANIMATION_TYPE_SLIDE_OUT: case wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE_IN_SLIDE_OUT:
AnimateHideWindow_SlideOut(window); AnimateHideWindow_SlideOut(window);
return true; return true;
default: default:
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "ash/wm/window_state.h" #include "ash/wm/window_state.h"
#include "ash/wm/wm_event.h"
#include "ash/wm/workspace_controller.h" #include "ash/wm/workspace_controller.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/time/time.h" #include "base/time/time.h"
...@@ -291,9 +292,62 @@ TEST_F(WindowAnimationsTest, SlideOutAnimation) { ...@@ -291,9 +292,62 @@ TEST_F(WindowAnimationsTest, SlideOutAnimation) {
EXPECT_TRUE(window->layer()->visible()); EXPECT_TRUE(window->layer()->visible());
::wm::SetWindowVisibilityAnimationType( ::wm::SetWindowVisibilityAnimationType(
window.get(), wm::WINDOW_VISIBILITY_ANIMATION_TYPE_SLIDE_OUT); window.get(), wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE_IN_SLIDE_OUT);
AnimateOnChildWindowVisibilityChanged(window.get(), false); AnimateOnChildWindowVisibilityChanged(window.get(), false);
EXPECT_EQ(0.0f, window->layer()->GetTargetOpacity());
EXPECT_FALSE(window->layer()->GetTargetVisibility());
EXPECT_FALSE(window->layer()->visible());
EXPECT_EQ(gfx::Rect(-150, 0, 100, 100), window->layer()->GetTargetBounds());
}
// Test that a fade in slide out animation fades in.
TEST_F(WindowAnimationsTest, FadeInAnimation) {
ui::ScopedAnimationDurationScaleMode test_duration_mode(
ui::ScopedAnimationDurationScaleMode::ZERO_DURATION);
std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
window->SetBounds(gfx::Rect(0, 0, 100, 100));
window->Hide();
EXPECT_FALSE(window->layer()->visible());
::wm::SetWindowVisibilityAnimationType(
window.get(), wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE_IN_SLIDE_OUT);
AnimateOnChildWindowVisibilityChanged(window.get(), true);
EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity());
EXPECT_TRUE(window->layer()->GetTargetVisibility());
EXPECT_TRUE(window->layer()->visible());
EXPECT_EQ(gfx::Rect(0, 0, 100, 100), window->layer()->GetTargetBounds());
}
TEST_F(WindowAnimationsTest, SlideOutAnimationPlaysTwiceForPipWindow) {
ui::ScopedAnimationDurationScaleMode test_duration_mode(
ui::ScopedAnimationDurationScaleMode::ZERO_DURATION);
std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
window->SetBounds(gfx::Rect(0, 0, 100, 100));
wm::WindowState* window_state = wm::GetWindowState(window.get());
const wm::WMEvent enter_pip(wm::WM_EVENT_PIP);
window_state->OnWMEvent(&enter_pip);
EXPECT_TRUE(window_state->IsPip());
window->Show();
EXPECT_TRUE(window->layer()->visible());
window->Hide();
EXPECT_EQ(0.0f, window->layer()->GetTargetOpacity());
EXPECT_FALSE(window->layer()->GetTargetVisibility());
EXPECT_FALSE(window->layer()->visible());
EXPECT_EQ("-150,0 100x100", window->layer()->GetTargetBounds().ToString());
// Reset the position and try again.
window->Show();
window->SetBounds(gfx::Rect(0, 0, 100, 100));
EXPECT_TRUE(window->layer()->visible());
window->Hide();
EXPECT_EQ(0.0f, window->layer()->GetTargetOpacity()); EXPECT_EQ(0.0f, window->layer()->GetTargetOpacity());
EXPECT_FALSE(window->layer()->GetTargetVisibility()); EXPECT_FALSE(window->layer()->GetTargetVisibility());
EXPECT_FALSE(window->layer()->visible()); EXPECT_FALSE(window->layer()->visible());
......
...@@ -669,7 +669,7 @@ void WindowState::SetBoundsDirectCrossFade(const gfx::Rect& new_bounds, ...@@ -669,7 +669,7 @@ void WindowState::SetBoundsDirectCrossFade(const gfx::Rect& new_bounds,
void WindowState::UpdatePipState(bool was_pip) { void WindowState::UpdatePipState(bool was_pip) {
if (IsPip()) { if (IsPip()) {
::wm::SetWindowVisibilityAnimationType( ::wm::SetWindowVisibilityAnimationType(
window(), WINDOW_VISIBILITY_ANIMATION_TYPE_SLIDE_OUT); window(), WINDOW_VISIBILITY_ANIMATION_TYPE_FADE_IN_SLIDE_OUT);
} else if (was_pip) { } else if (was_pip) {
::wm::SetWindowVisibilityAnimationType( ::wm::SetWindowVisibilityAnimationType(
window(), ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT); window(), ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT);
......
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