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,
DCHECK(!in_splitview);
if (in_overview) {
overview_controller->EndOverview(
OverviewSession::EnterExitOverviewType::kImmediateExit);
OverviewSession::EnterExitOverviewType::kFadeOutExit);
}
ScaleDownWindowAfterDrag();
window_drag_result = ShelfWindowDragResult::kGoToHomeScreen;
......@@ -229,7 +229,6 @@ DragWindowFromShelfController::EndDrag(const gfx::Point& location_in_screen,
// dragged window to go to home screen.
ScaleDownWindowAfterDrag();
window_drag_result = ShelfWindowDragResult::kGoToHomeScreen;
} else {
window_drag_result = ShelfWindowDragResult::kGoToOverviewMode;
}
......@@ -350,7 +349,9 @@ void DragWindowFromShelfController::OnDragEnded(
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.
// If in overview, the dim and blur will be cleared after overview ends.
......
......@@ -241,9 +241,13 @@ void HomeScreenController::OnWindowDragStarted() {
UpdateVisibility();
}
void HomeScreenController::OnWindowDragEnded() {
void HomeScreenController::OnWindowDragEnded(bool animate) {
in_window_dragging_ = false;
UpdateVisibility();
if (ShouldShowHomeScreen()) {
home_screen_presenter_.ScheduleOverviewModeAnimation(
HomeScreenPresenter::TransitionType::kScaleHomeIn, animate);
}
}
bool HomeScreenController::IsHomeScreenVisible() const {
......@@ -359,12 +363,19 @@ void HomeScreenController::UpdateVisibility() {
if (!window)
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 =
Shell::Get()->overview_controller()->InOverviewSession();
if (in_overview || in_wallpaper_preview_ || in_window_dragging_)
window->Hide();
else
window->Show();
return in_tablet_mode && !in_overview && !in_wallpaper_preview_ &&
!in_window_dragging_;
}
} // namespace ash
......@@ -45,7 +45,9 @@ class ASH_EXPORT HomeScreenController : public OverviewObserver,
// 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.
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.
bool IsHomeScreenVisible() const;
......@@ -79,6 +81,10 @@ class ASH_EXPORT HomeScreenController : public OverviewObserver,
// |display_id| - the home screen 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
// during wallpaper preview.
bool in_wallpaper_preview_ = false;
......
......@@ -75,7 +75,8 @@ void FadeInWidgetAndMaybeSlideOnEnter(views::Widget* widget,
}
window->SetTransform(new_transform);
}
window->layer()->SetOpacity(0.0f);
// Fade in the widget from its current opacity.
ScopedOverviewAnimationSettings scoped_overview_animation_settings(
animation_type, window);
window->layer()->SetOpacity(1.0f);
......@@ -100,9 +101,8 @@ void FadeOutWidgetAndMaybeSlideOnExit(std::unique_ptr<views::Widget> widget,
return;
}
widget->SetOpacity(1.f);
// Fade out the widget. This animation continues past the lifetime of overview
// mode items.
// Fade out the widget from its current opacity. This animation continues past
// the lifetime of overview mode items.
ScopedOverviewAnimationSettings animation_settings(animation_type,
widget->GetNativeWindow());
// CleanupAnimationObserver will delete itself (and the widget) when the
......
......@@ -180,7 +180,8 @@ class TabletModeBrowserWindowDragDelegate::WindowsHider
DCHECK(!Shell::Get()->overview_controller()->InOverviewSession());
// 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.
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