Commit 97f4956a authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

overview gesture: use scale-in-to-show home screen animation when go home.

When dragging a window from shelf, if the window should be taken to home
screen after the drag ends, use scale-in animation to show home screen.
If overview is active, then fade out overview windows.

Bug: 997885, 1026944
Change-Id: I11b92e152679fe32efc2fae0b30b71dcba4ccc74
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1949276
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721694}
parent 108b8758
...@@ -217,7 +217,7 @@ DragWindowFromShelfController::EndDrag(const gfx::Point& location_in_screen, ...@@ -217,7 +217,7 @@ DragWindowFromShelfController::EndDrag(const gfx::Point& location_in_screen,
DCHECK(!in_splitview); DCHECK(!in_splitview);
if (in_overview) { if (in_overview) {
overview_controller->EndOverview( overview_controller->EndOverview(
OverviewSession::EnterExitOverviewType::kImmediateExit); OverviewSession::EnterExitOverviewType::kFadeOutExit);
} }
ScaleDownWindowAfterDrag(); ScaleDownWindowAfterDrag();
window_drag_result = ShelfWindowDragResult::kGoToHomeScreen; window_drag_result = ShelfWindowDragResult::kGoToHomeScreen;
...@@ -229,7 +229,6 @@ DragWindowFromShelfController::EndDrag(const gfx::Point& location_in_screen, ...@@ -229,7 +229,6 @@ DragWindowFromShelfController::EndDrag(const gfx::Point& location_in_screen,
// dragged window to go to home screen. // dragged window to go to home screen.
ScaleDownWindowAfterDrag(); ScaleDownWindowAfterDrag();
window_drag_result = ShelfWindowDragResult::kGoToHomeScreen; window_drag_result = ShelfWindowDragResult::kGoToHomeScreen;
} else { } else {
window_drag_result = ShelfWindowDragResult::kGoToOverviewMode; window_drag_result = ShelfWindowDragResult::kGoToOverviewMode;
} }
...@@ -350,7 +349,9 @@ void DragWindowFromShelfController::OnDragEnded( ...@@ -350,7 +349,9 @@ void DragWindowFromShelfController::OnDragEnded(
location_in_screen); location_in_screen);
} }
Shell::Get()->home_screen_controller()->OnWindowDragEnded(); // Scale-in-to-show home screen if home screen should be shown after drag
// ends.
Shell::Get()->home_screen_controller()->OnWindowDragEnded(/*animate=*/true);
// Clear the wallpaper dim and blur if not in overview after drag ends. // Clear the wallpaper dim and blur if not in overview after drag ends.
// If in overview, the dim and blur will be cleared after overview ends. // If in overview, the dim and blur will be cleared after overview ends.
......
...@@ -241,9 +241,13 @@ void HomeScreenController::OnWindowDragStarted() { ...@@ -241,9 +241,13 @@ void HomeScreenController::OnWindowDragStarted() {
UpdateVisibility(); UpdateVisibility();
} }
void HomeScreenController::OnWindowDragEnded() { void HomeScreenController::OnWindowDragEnded(bool animate) {
in_window_dragging_ = false; in_window_dragging_ = false;
UpdateVisibility(); UpdateVisibility();
if (ShouldShowHomeScreen()) {
home_screen_presenter_.ScheduleOverviewModeAnimation(
HomeScreenPresenter::TransitionType::kScaleHomeIn, animate);
}
} }
bool HomeScreenController::IsHomeScreenVisible() const { bool HomeScreenController::IsHomeScreenVisible() const {
...@@ -359,12 +363,19 @@ void HomeScreenController::UpdateVisibility() { ...@@ -359,12 +363,19 @@ void HomeScreenController::UpdateVisibility() {
if (!window) if (!window)
return; return;
if (ShouldShowHomeScreen())
window->Show();
else
window->Hide();
}
bool HomeScreenController::ShouldShowHomeScreen() const {
const bool in_tablet_mode =
Shell::Get()->tablet_mode_controller()->InTabletMode();
const bool in_overview = const bool in_overview =
Shell::Get()->overview_controller()->InOverviewSession(); Shell::Get()->overview_controller()->InOverviewSession();
if (in_overview || in_wallpaper_preview_ || in_window_dragging_) return in_tablet_mode && !in_overview && !in_wallpaper_preview_ &&
window->Hide(); !in_window_dragging_;
else
window->Show();
} }
} // namespace ash } // namespace ash
...@@ -45,7 +45,9 @@ class ASH_EXPORT HomeScreenController : public OverviewObserver, ...@@ -45,7 +45,9 @@ class ASH_EXPORT HomeScreenController : public OverviewObserver,
// Called when a window starts/ends dragging. If the home screen is shown, we // Called when a window starts/ends dragging. If the home screen is shown, we
// should hide it during dragging a window and reshow it when the drag ends. // should hide it during dragging a window and reshow it when the drag ends.
void OnWindowDragStarted(); void OnWindowDragStarted();
void OnWindowDragEnded(); // If |animate| is true, scale-in-to-show home screen if home screen should
// be shown after drag ends.
void OnWindowDragEnded(bool animate);
// True if home screen is visible. // True if home screen is visible.
bool IsHomeScreenVisible() const; bool IsHomeScreenVisible() const;
...@@ -79,6 +81,10 @@ class ASH_EXPORT HomeScreenController : public OverviewObserver, ...@@ -79,6 +81,10 @@ class ASH_EXPORT HomeScreenController : public OverviewObserver,
// |display_id| - the home screen display ID. // |display_id| - the home screen display ID.
void NotifyHomeLauncherTransitionEnded(bool shown, int64_t display_id); void NotifyHomeLauncherTransitionEnded(bool shown, int64_t display_id);
// Returns true if home screen should be shown based on the current
// configuration.
bool ShouldShowHomeScreen() const;
// Whether the wallpaper is being previewed. The home screen should be hidden // Whether the wallpaper is being previewed. The home screen should be hidden
// during wallpaper preview. // during wallpaper preview.
bool in_wallpaper_preview_ = false; bool in_wallpaper_preview_ = false;
......
...@@ -75,7 +75,8 @@ void FadeInWidgetAndMaybeSlideOnEnter(views::Widget* widget, ...@@ -75,7 +75,8 @@ void FadeInWidgetAndMaybeSlideOnEnter(views::Widget* widget,
} }
window->SetTransform(new_transform); window->SetTransform(new_transform);
} }
window->layer()->SetOpacity(0.0f);
// Fade in the widget from its current opacity.
ScopedOverviewAnimationSettings scoped_overview_animation_settings( ScopedOverviewAnimationSettings scoped_overview_animation_settings(
animation_type, window); animation_type, window);
window->layer()->SetOpacity(1.0f); window->layer()->SetOpacity(1.0f);
...@@ -100,9 +101,8 @@ void FadeOutWidgetAndMaybeSlideOnExit(std::unique_ptr<views::Widget> widget, ...@@ -100,9 +101,8 @@ void FadeOutWidgetAndMaybeSlideOnExit(std::unique_ptr<views::Widget> widget,
return; return;
} }
widget->SetOpacity(1.f); // Fade out the widget from its current opacity. This animation continues past
// Fade out the widget. This animation continues past the lifetime of overview // the lifetime of overview mode items.
// mode items.
ScopedOverviewAnimationSettings animation_settings(animation_type, ScopedOverviewAnimationSettings animation_settings(animation_type,
widget->GetNativeWindow()); widget->GetNativeWindow());
// CleanupAnimationObserver will delete itself (and the widget) when the // CleanupAnimationObserver will delete itself (and the widget) when the
......
...@@ -180,7 +180,8 @@ class TabletModeBrowserWindowDragDelegate::WindowsHider ...@@ -180,7 +180,8 @@ class TabletModeBrowserWindowDragDelegate::WindowsHider
DCHECK(!Shell::Get()->overview_controller()->InOverviewSession()); DCHECK(!Shell::Get()->overview_controller()->InOverviewSession());
// May reshow the home launcher after dragging. // May reshow the home launcher after dragging.
Shell::Get()->home_screen_controller()->OnWindowDragEnded(); Shell::Get()->home_screen_controller()->OnWindowDragEnded(
/*animate=*/false);
// Clears the background wallpaper blur. // Clears the background wallpaper blur.
auto* wallpaper_view = auto* wallpaper_view =
......
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