Commit f92ba8d5 authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

overview gesture: Fade in overview when drag starts or during dragging.

When the window drag starts or slows down, fade in overview windows.

Bug: 997885
Change-Id: Ica9e256df32babeb6dab3d7d027447217a577c65
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900127
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712785}
parent 33999528
...@@ -149,6 +149,10 @@ void DragWindowFromShelfController::Drag(const gfx::Point& location_in_screen, ...@@ -149,6 +149,10 @@ void DragWindowFromShelfController::Drag(const gfx::Point& location_in_screen,
overview_session->OnWindowDragStarted(window_, /*animate=*/false); overview_session->OnWindowDragStarted(window_, /*animate=*/false);
if (ShouldAllowSplitView()) if (ShouldAllowSplitView())
overview_session->SetSplitViewDragIndicatorsDraggedWindow(window_); overview_session->SetSplitViewDragIndicatorsDraggedWindow(window_);
// Hide overview windows first and fade in the windows after delaying
// kShowOverviewTimeWhenDragSuspend.
overview_session->SetVisibleDuringWindowDragging(/*visible=*/false,
/*animate=*/false);
} }
// If overview is active, update its splitview indicator during dragging if // If overview is active, update its splitview indicator during dragging if
...@@ -178,7 +182,8 @@ void DragWindowFromShelfController::Drag(const gfx::Point& location_in_screen, ...@@ -178,7 +182,8 @@ void DragWindowFromShelfController::Drag(const gfx::Point& location_in_screen,
std::abs(scroll_y) > kShowOverviewThreshold) { std::abs(scroll_y) > kShowOverviewThreshold) {
// If the dragging velocity is large enough, hide overview windows. // If the dragging velocity is large enough, hide overview windows.
show_overview_timer_.Stop(); show_overview_timer_.Stop();
overview_session->SetVisibleDuringWindowDragging(/*visible=*/false); overview_session->SetVisibleDuringWindowDragging(/*visible=*/false,
/*animate=*/false);
} else { } else {
// Otherwise start the |show_overview_timer_| to show and update overview // Otherwise start the |show_overview_timer_| to show and update overview
// when the dragging slows down or stops. // when the dragging slows down or stops.
...@@ -488,7 +493,7 @@ void DragWindowFromShelfController::ShowOverviewDuringOrAfterDrag() { ...@@ -488,7 +493,7 @@ void DragWindowFromShelfController::ShowOverviewDuringOrAfterDrag() {
return; return;
overview_controller->overview_session()->SetVisibleDuringWindowDragging( overview_controller->overview_session()->SetVisibleDuringWindowDragging(
/*visible=*/true); /*visible=*/true, /*animate=*/true);
} }
void DragWindowFromShelfController::ScaleDownWindowAfterDrag() { void DragWindowFromShelfController::ScaleDownWindowAfterDrag() {
......
...@@ -47,6 +47,8 @@ enum OverviewAnimationType { ...@@ -47,6 +47,8 @@ enum OverviewAnimationType {
OVERVIEW_ANIMATION_SELECTION_WINDOW, OVERVIEW_ANIMATION_SELECTION_WINDOW,
// Used to animate the clipping of the windows frame header. // Used to animate the clipping of the windows frame header.
OVERVIEW_ANIMATION_FRAME_HEADER_CLIP, OVERVIEW_ANIMATION_FRAME_HEADER_CLIP,
// Used to fade in all windows when window drag starts or during window drag.
OVERVIEW_ANIMATION_OPACITY_ON_WINDOW_DRAG,
}; };
} // namespace ash } // namespace ash
......
...@@ -893,13 +893,26 @@ void OverviewGrid::OnWindowDragEnded(aura::Window* dragged_window, ...@@ -893,13 +893,26 @@ void OverviewGrid::OnWindowDragEnded(aura::Window* dragged_window,
/*animate=*/true); /*animate=*/true);
} }
void OverviewGrid::SetVisibleDuringWindowDragging(bool visible) { void OverviewGrid::SetVisibleDuringWindowDragging(bool visible, bool animate) {
for (const auto& window_item : window_list_) for (const auto& window_item : window_list_)
window_item->SetVisibleDuringWindowDragging(visible); window_item->SetVisibleDuringWindowDragging(visible, animate);
// Update |desks_widget_|. // Update |desks_widget_|.
if (desks_widget_) if (desks_widget_) {
desks_widget_->GetNativeWindow()->layer()->SetOpacity(visible ? 1.f : 0.f); ui::Layer* layer = desks_widget_->GetNativeWindow()->layer();
float new_opacity = visible ? 1.f : 0.f;
if (layer->GetTargetOpacity() == new_opacity)
return;
if (animate) {
ScopedOverviewAnimationSettings settings(
OVERVIEW_ANIMATION_OPACITY_ON_WINDOW_DRAG,
desks_widget_->GetNativeWindow());
layer->SetOpacity(new_opacity);
} else {
layer->SetOpacity(new_opacity);
}
}
} }
bool OverviewGrid::IsDropTargetWindow(aura::Window* window) const { bool OverviewGrid::IsDropTargetWindow(aura::Window* window) const {
......
...@@ -177,7 +177,7 @@ class ASH_EXPORT OverviewGrid : public SplitViewObserver, ...@@ -177,7 +177,7 @@ class ASH_EXPORT OverviewGrid : public SplitViewObserver,
bool snap); bool snap);
// Shows/Hides windows during window dragging. Used when swiping up a window // Shows/Hides windows during window dragging. Used when swiping up a window
// from shelf. // from shelf.
void SetVisibleDuringWindowDragging(bool visible); void SetVisibleDuringWindowDragging(bool visible, bool animate);
// Returns true if |window| is the placeholder window from the drop target. // Returns true if |window| is the placeholder window from the drop target.
bool IsDropTargetWindow(aura::Window* window) const; bool IsDropTargetWindow(aura::Window* window) const;
......
...@@ -563,11 +563,21 @@ void OverviewItem::OnSelectorItemDragEnded(bool snap) { ...@@ -563,11 +563,21 @@ void OverviewItem::OnSelectorItemDragEnded(bool snap) {
is_being_dragged_ = false; is_being_dragged_ = false;
} }
void OverviewItem::SetVisibleDuringWindowDragging(bool visible) { void OverviewItem::SetVisibleDuringWindowDragging(bool visible, bool animate) {
aura::Window::Windows windows = GetWindowsForHomeGesture(); aura::Window::Windows windows = GetWindowsForHomeGesture();
float new_opacity = visible ? 1.f : 0.f;
for (auto* window : windows) { for (auto* window : windows) {
ui::Layer* layer = window->layer(); ui::Layer* layer = window->layer();
layer->SetOpacity(visible ? 1.f : 0.f); if (layer->GetTargetOpacity() == new_opacity)
continue;
if (animate) {
ScopedOverviewAnimationSettings settings(
OVERVIEW_ANIMATION_OPACITY_ON_WINDOW_DRAG, window);
layer->SetOpacity(new_opacity);
} else {
layer->SetOpacity(new_opacity);
}
} }
} }
......
...@@ -120,7 +120,7 @@ class ASH_EXPORT OverviewItem : public views::ButtonListener, ...@@ -120,7 +120,7 @@ class ASH_EXPORT OverviewItem : public views::ButtonListener,
// Shows/Hides window item during window dragging. Used when swiping up a // Shows/Hides window item during window dragging. Used when swiping up a
// window from shelf. // window from shelf.
void SetVisibleDuringWindowDragging(bool visible); void SetVisibleDuringWindowDragging(bool visible, bool animate);
ScopedOverviewTransformWindow::GridWindowFillMode GetWindowDimensionsType() ScopedOverviewTransformWindow::GridWindowFillMode GetWindowDimensionsType()
const; const;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/resources/vector_icons/vector_icons.h"
#include "ash/strings/grit/ash_strings.h" #include "ash/strings/grit/ash_strings.h"
#include "ash/wm/overview/overview_constants.h" #include "ash/wm/overview/overview_constants.h"
#include "ash/wm/overview/overview_grid.h"
#include "ash/wm/overview/overview_item.h" #include "ash/wm/overview/overview_item.h"
#include "ash/wm/overview/rounded_rect_view.h" #include "ash/wm/overview/rounded_rect_view.h"
#include "ash/wm/window_preview_view.h" #include "ash/wm/window_preview_view.h"
...@@ -161,7 +162,9 @@ OverviewItemView::OverviewItemView(OverviewItem* overview_item, ...@@ -161,7 +162,9 @@ OverviewItemView::OverviewItemView(OverviewItem* overview_item,
// Call this last as it calls |Layout()| which relies on the some of the other // Call this last as it calls |Layout()| which relies on the some of the other
// elements existing. // elements existing.
SetShowPreview(show_preview); SetShowPreview(show_preview);
if (show_preview) { // Do not show header if the current overview item is the drop target widget.
if (show_preview || overview_item_->overview_grid()->IsDropTargetWindow(
overview_item_->GetWindow())) {
header_view()->layer()->SetOpacity(0.f); header_view()->layer()->SetOpacity(0.f);
current_header_visibility_ = HeaderVisibility::kInvisible; current_header_visibility_ = HeaderVisibility::kInvisible;
} }
......
...@@ -502,9 +502,10 @@ void OverviewSession::OnWindowDragEnded(aura::Window* dragged_window, ...@@ -502,9 +502,10 @@ void OverviewSession::OnWindowDragEnded(aura::Window* dragged_window,
should_drop_window_into_overview, snap); should_drop_window_into_overview, snap);
} }
void OverviewSession::SetVisibleDuringWindowDragging(bool visible) { void OverviewSession::SetVisibleDuringWindowDragging(bool visible,
bool animate) {
for (auto& grid : grid_list_) for (auto& grid : grid_list_)
grid->SetVisibleDuringWindowDragging(visible); grid->SetVisibleDuringWindowDragging(visible, animate);
} }
void OverviewSession::PositionWindows( void OverviewSession::PositionWindows(
......
...@@ -196,7 +196,7 @@ class ASH_EXPORT OverviewSession : public display::DisplayObserver, ...@@ -196,7 +196,7 @@ class ASH_EXPORT OverviewSession : public display::DisplayObserver,
// overview. It's used when dragging a window from bottom, when the user slows // overview. It's used when dragging a window from bottom, when the user slows
// down or stops dragging the window, shows overview windows and when the user // down or stops dragging the window, shows overview windows and when the user
// resumes dragging, hides overview windows. // resumes dragging, hides overview windows.
void SetVisibleDuringWindowDragging(bool visible); void SetVisibleDuringWindowDragging(bool visible, bool animate);
// Positions all overview items except those in |ignored_items|. // Positions all overview items except those in |ignored_items|.
void PositionWindows(bool animate, void PositionWindows(bool animate,
......
...@@ -50,6 +50,11 @@ constexpr base::TimeDelta kOverviewHighlightTransition = ...@@ -50,6 +50,11 @@ constexpr base::TimeDelta kOverviewHighlightTransition =
constexpr base::TimeDelta kDropTargetFade = constexpr base::TimeDelta kDropTargetFade =
base::TimeDelta::FromMilliseconds(250); base::TimeDelta::FromMilliseconds(250);
// Time duration to fade in overview windows when a window drag slows down or
// stops.
constexpr base::TimeDelta kFadeInOnWindowDrag =
base::TimeDelta::FromMilliseconds(350);
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:
...@@ -80,6 +85,8 @@ base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) { ...@@ -80,6 +85,8 @@ base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) {
case OVERVIEW_ANIMATION_SELECTION_WINDOW: case OVERVIEW_ANIMATION_SELECTION_WINDOW:
case OVERVIEW_ANIMATION_FRAME_HEADER_CLIP: case OVERVIEW_ANIMATION_FRAME_HEADER_CLIP:
return kOverviewHighlightTransition; return kOverviewHighlightTransition;
case OVERVIEW_ANIMATION_OPACITY_ON_WINDOW_DRAG:
return kFadeInOnWindowDrag;
} }
NOTREACHED(); NOTREACHED();
return base::TimeDelta(); return base::TimeDelta();
...@@ -192,6 +199,11 @@ ScopedOverviewAnimationSettings::ScopedOverviewAnimationSettings( ...@@ -192,6 +199,11 @@ ScopedOverviewAnimationSettings::ScopedOverviewAnimationSettings(
animation_settings_->SetPreemptionStrategy( animation_settings_->SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
break; break;
case OVERVIEW_ANIMATION_OPACITY_ON_WINDOW_DRAG:
animation_settings_->SetTweenType(gfx::Tween::FAST_OUT_SLOW_IN);
animation_settings_->SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
break;
} }
animation_settings_->SetTransitionDuration( animation_settings_->SetTransitionDuration(
GetAnimationDuration(animation_type)); GetAnimationDuration(animation_type));
......
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