Commit 04a516d0 authored by Avery Musbach's avatar Avery Musbach Committed by Commit Bot

overview: Fade in close icons differently when a window becomes snapped

The overview close icons shall fade in with special animation parameters
when a window gets snapped (either activating split view or taking the
place of a lone snapped window). These parameters are specified here:
https://mccanny.users.x20web.corp.google.com/www/splitscreen-motion/index.html#window-drop

Test: manual
Bug: 934977
Change-Id: Ib678560f5b1be00fa6d69e848d476ad2f88f98fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1570218
Commit-Queue: Avery Musbach <amusbach@chromium.org>
Reviewed-by: default avatarMitsuru Oshima (Slow 4/22-26) <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#653627}
parent 11ccdec1
...@@ -205,6 +205,16 @@ void CaptionContainerView::SetHeaderVisibility(HeaderVisibility visibility) { ...@@ -205,6 +205,16 @@ void CaptionContainerView::SetHeaderVisibility(HeaderVisibility visibility) {
AnimateLayerOpacity(close_button_->layer(), close_button_visible); AnimateLayerOpacity(close_button_->layer(), close_button_visible);
} }
void CaptionContainerView::FadeInCloseIconAfterSnap() {
DCHECK(close_button_->layer());
current_header_visibility_ = HeaderVisibility::kVisible;
close_button_->layer()->SetOpacity(0.f);
ScopedOverviewAnimationSettings settings(
OVERVIEW_ANIMATION_OVERVIEW_CLOSE_ICON_FADE_IN_ON_SNAP,
close_button_->layer()->GetAnimator());
close_button_->layer()->SetOpacity(1.f);
}
void CaptionContainerView::SetBackdropVisibility(bool visible) { void CaptionContainerView::SetBackdropVisibility(bool visible) {
if (!backdrop_view_ && !visible) if (!backdrop_view_ && !visible)
return; return;
......
...@@ -65,8 +65,18 @@ class ASH_EXPORT CaptionContainerView : public views::Button { ...@@ -65,8 +65,18 @@ class ASH_EXPORT CaptionContainerView : public views::Button {
CaptionContainerView(EventDelegate* event_delegate, aura::Window* window); CaptionContainerView(EventDelegate* event_delegate, aura::Window* window);
~CaptionContainerView() override; ~CaptionContainerView() override;
// Fades in and out the app icon, title, and close button, choosing an
// overview animation type based on whether fading in or fading out. When a
// window gets snapped, use |FadeInCloseIconAfterSnap| instead.
void SetHeaderVisibility(HeaderVisibility visibility); void SetHeaderVisibility(HeaderVisibility visibility);
// Fade in the close icon with a special overview animation type (specifically
// |OVERVIEW_ANIMATION_OVERVIEW_CLOSE_ICON_FADE_IN_ON_SNAP|) for when a
// dragged window gets snapped. This function may be called before or after
// the window is snapped. It is called before the snap in case of dragging
// from the top, but after the snap in case of dragging from overview.
void FadeInCloseIconAfterSnap();
// Sets the visiblity of |backdrop_view_|. Creates it if it is null. // Sets the visiblity of |backdrop_view_|. Creates it if it is null.
void SetBackdropVisibility(bool visible); void SetBackdropVisibility(bool visible);
......
...@@ -46,9 +46,13 @@ enum OverviewAnimationType { ...@@ -46,9 +46,13 @@ enum OverviewAnimationType {
// arrow keys. // arrow keys.
OVERVIEW_ANIMATION_SELECTION_WINDOW_SHADOW, OVERVIEW_ANIMATION_SELECTION_WINDOW_SHADOW,
OVERVIEW_ANIMATION_SELECTION_WINDOW, OVERVIEW_ANIMATION_SELECTION_WINDOW,
// Used to animate the overview items header visibility. // Used to fade in and out each overview item's app icon, title, and close
// button, except when a window gets snapped (see the next value).
OVERVIEW_ANIMATION_OVERVIEW_TITLE_FADE_IN, OVERVIEW_ANIMATION_OVERVIEW_TITLE_FADE_IN,
OVERVIEW_ANIMATION_OVERVIEW_TITLE_FADE_OUT, OVERVIEW_ANIMATION_OVERVIEW_TITLE_FADE_OUT,
// Used to fade in the close icons for items remaining in overview on one side
// of the screen when a window gets snapped on the other side.
OVERVIEW_ANIMATION_OVERVIEW_CLOSE_ICON_FADE_IN_ON_SNAP,
}; };
} // namespace ash } // namespace ash
......
...@@ -712,9 +712,9 @@ void OverviewGrid::OnSelectorItemDragStarted(OverviewItem* item) { ...@@ -712,9 +712,9 @@ void OverviewGrid::OnSelectorItemDragStarted(OverviewItem* item) {
overview_mode_item->OnSelectorItemDragStarted(item); overview_mode_item->OnSelectorItemDragStarted(item);
} }
void OverviewGrid::OnSelectorItemDragEnded() { void OverviewGrid::OnSelectorItemDragEnded(bool snap) {
for (auto& overview_mode_item : window_list_) for (auto& overview_mode_item : window_list_)
overview_mode_item->OnSelectorItemDragEnded(); overview_mode_item->OnSelectorItemDragEnded(snap);
} }
void OverviewGrid::OnWindowDragStarted(aura::Window* dragged_window, void OverviewGrid::OnWindowDragStarted(aura::Window* dragged_window,
...@@ -791,7 +791,8 @@ void OverviewGrid::OnWindowDragContinued(aura::Window* dragged_window, ...@@ -791,7 +791,8 @@ void OverviewGrid::OnWindowDragContinued(aura::Window* dragged_window,
void OverviewGrid::OnWindowDragEnded(aura::Window* dragged_window, void OverviewGrid::OnWindowDragEnded(aura::Window* dragged_window,
const gfx::PointF& location_in_screen, const gfx::PointF& location_in_screen,
bool should_drop_window_into_overview) { bool should_drop_window_into_overview,
bool snap) {
DCHECK_EQ(dragged_window->GetRootWindow(), root_window_); DCHECK_EQ(dragged_window->GetRootWindow(), root_window_);
DCHECK(drop_target_widget_.get()); DCHECK(drop_target_widget_.get());
...@@ -810,7 +811,7 @@ void OverviewGrid::OnWindowDragEnded(aura::Window* dragged_window, ...@@ -810,7 +811,7 @@ void OverviewGrid::OnWindowDragEnded(aura::Window* dragged_window,
RemoveDropTarget(); RemoveDropTarget();
// Called to reset caption and title visibility after dragging. // Called to reset caption and title visibility after dragging.
OnSelectorItemDragEnded(); OnSelectorItemDragEnded(snap);
// After drag ends, if the dragged window needs to merge into another window // After drag ends, if the dragged window needs to merge into another window
// |target_window|, and we may need to update |minimized_widget_| that holds // |target_window|, and we may need to update |minimized_widget_| that holds
......
...@@ -147,7 +147,7 @@ class ASH_EXPORT OverviewGrid : public aura::WindowObserver, ...@@ -147,7 +147,7 @@ class ASH_EXPORT OverviewGrid : public aura::WindowObserver,
// Called when any OverviewItem on any OverviewGrid has started/ended being // Called when any OverviewItem on any OverviewGrid has started/ended being
// dragged. // dragged.
void OnSelectorItemDragStarted(OverviewItem* item); void OnSelectorItemDragStarted(OverviewItem* item);
void OnSelectorItemDragEnded(); void OnSelectorItemDragEnded(bool snap);
// Called when a window (either it's browser window or an app window) // Called when a window (either it's browser window or an app window)
// start/continue/end being dragged in tablet mode. // start/continue/end being dragged in tablet mode.
...@@ -157,7 +157,8 @@ class ASH_EXPORT OverviewGrid : public aura::WindowObserver, ...@@ -157,7 +157,8 @@ class ASH_EXPORT OverviewGrid : public aura::WindowObserver,
IndicatorState indicator_state); IndicatorState indicator_state);
void OnWindowDragEnded(aura::Window* dragged_window, void OnWindowDragEnded(aura::Window* dragged_window,
const gfx::PointF& location_in_screen, const gfx::PointF& location_in_screen,
bool should_drop_window_into_overview); bool should_drop_window_into_overview,
bool snap);
// 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;
......
...@@ -445,18 +445,26 @@ void OverviewItem::OnSelectorItemDragStarted(OverviewItem* item) { ...@@ -445,18 +445,26 @@ void OverviewItem::OnSelectorItemDragStarted(OverviewItem* item) {
} }
} }
void OverviewItem::OnSelectorItemDragEnded() { void OverviewItem::OnSelectorItemDragEnded(bool snap) {
// Re-show mask and shadow for the dragged overview item after drag ends. // Stop caching render surface after overview window dragging.
window_surface_cache_observers_.reset();
if (is_being_dragged_) { if (is_being_dragged_) {
is_being_dragged_ = false; is_being_dragged_ = false;
// Do nothing further with the dragged overview item if it is being snapped.
if (snap)
return;
// Re-show mask and shadow for the dragged overview item after drag ends.
UpdateMaskAndShadow(); UpdateMaskAndShadow();
} }
caption_container_view_->SetHeaderVisibility( // Update the header.
CaptionContainerView::HeaderVisibility::kVisible); if (snap) {
caption_container_view_->FadeInCloseIconAfterSnap();
// Stop caching render surface after overview window dragging. } else {
window_surface_cache_observers_.reset(); caption_container_view_->SetHeaderVisibility(
CaptionContainerView::HeaderVisibility::kVisible);
}
} }
ScopedOverviewTransformWindow::GridWindowFillMode ScopedOverviewTransformWindow::GridWindowFillMode
......
...@@ -120,7 +120,7 @@ class ASH_EXPORT OverviewItem : public CaptionContainerView::EventDelegate, ...@@ -120,7 +120,7 @@ class ASH_EXPORT OverviewItem : public CaptionContainerView::EventDelegate,
// when a drag is started, and reshows it when a drag is finished. // when a drag is started, and reshows it when a drag is finished.
// Additionally hides the title and window icon if |item| is this. // Additionally hides the title and window icon if |item| is this.
void OnSelectorItemDragStarted(OverviewItem* item); void OnSelectorItemDragStarted(OverviewItem* item);
void OnSelectorItemDragEnded(); void OnSelectorItemDragEnded(bool snap);
ScopedOverviewTransformWindow::GridWindowFillMode GetWindowDimensionsType() ScopedOverviewTransformWindow::GridWindowFillMode GetWindowDimensionsType()
const; const;
......
...@@ -509,10 +509,11 @@ void OverviewSession::CompleteDrag(OverviewItem* item, ...@@ -509,10 +509,11 @@ void OverviewSession::CompleteDrag(OverviewItem* item,
const gfx::PointF& location_in_screen) { const gfx::PointF& location_in_screen) {
DCHECK(window_drag_controller_); DCHECK(window_drag_controller_);
DCHECK_EQ(item, window_drag_controller_->item()); DCHECK_EQ(item, window_drag_controller_->item());
window_drag_controller_->CompleteDrag(location_in_screen); const bool snap =
window_drag_controller_->CompleteDrag(location_in_screen) ==
OverviewWindowDragController::DragResult::kSuccessfulDragToSnap;
for (std::unique_ptr<OverviewGrid>& grid : grid_list_) for (std::unique_ptr<OverviewGrid>& grid : grid_list_)
grid->OnSelectorItemDragEnded(); grid->OnSelectorItemDragEnded(snap);
} }
void OverviewSession::StartSplitViewDragMode( void OverviewSession::StartSplitViewDragMode(
...@@ -529,9 +530,12 @@ void OverviewSession::Fling(OverviewItem* item, ...@@ -529,9 +530,12 @@ void OverviewSession::Fling(OverviewItem* item,
if (!window_drag_controller_ || item != window_drag_controller_->item()) if (!window_drag_controller_ || item != window_drag_controller_->item())
return; return;
window_drag_controller_->Fling(location_in_screen, velocity_x, velocity_y); const bool snap =
window_drag_controller_->Fling(location_in_screen, velocity_x,
velocity_y) ==
OverviewWindowDragController::DragResult::kSuccessfulDragToSnap;
for (std::unique_ptr<OverviewGrid>& grid : grid_list_) for (std::unique_ptr<OverviewGrid>& grid : grid_list_)
grid->OnSelectorItemDragEnded(); grid->OnSelectorItemDragEnded(snap);
} }
void OverviewSession::ActivateDraggedWindow() { void OverviewSession::ActivateDraggedWindow() {
...@@ -541,7 +545,7 @@ void OverviewSession::ActivateDraggedWindow() { ...@@ -541,7 +545,7 @@ void OverviewSession::ActivateDraggedWindow() {
void OverviewSession::ResetDraggedWindowGesture() { void OverviewSession::ResetDraggedWindowGesture() {
window_drag_controller_->ResetGesture(); window_drag_controller_->ResetGesture();
for (std::unique_ptr<OverviewGrid>& grid : grid_list_) for (std::unique_ptr<OverviewGrid>& grid : grid_list_)
grid->OnSelectorItemDragEnded(); grid->OnSelectorItemDragEnded(/*snap=*/false);
} }
void OverviewSession::OnWindowDragStarted(aura::Window* dragged_window, void OverviewSession::OnWindowDragStarted(aura::Window* dragged_window,
...@@ -566,13 +570,14 @@ void OverviewSession::OnWindowDragContinued( ...@@ -566,13 +570,14 @@ void OverviewSession::OnWindowDragContinued(
} }
void OverviewSession::OnWindowDragEnded(aura::Window* dragged_window, void OverviewSession::OnWindowDragEnded(aura::Window* dragged_window,
const gfx::PointF& location_in_screen, const gfx::PointF& location_in_screen,
bool should_drop_window_into_overview) { bool should_drop_window_into_overview,
bool snap) {
OverviewGrid* target_grid = OverviewGrid* target_grid =
GetGridWithRootWindow(dragged_window->GetRootWindow()); GetGridWithRootWindow(dragged_window->GetRootWindow());
if (!target_grid) if (!target_grid)
return; return;
target_grid->OnWindowDragEnded(dragged_window, location_in_screen, target_grid->OnWindowDragEnded(dragged_window, location_in_screen,
should_drop_window_into_overview); should_drop_window_into_overview, snap);
} }
void OverviewSession::PositionWindows( void OverviewSession::PositionWindows(
...@@ -590,6 +595,17 @@ bool OverviewSession::IsWindowInOverview(const aura::Window* window) { ...@@ -590,6 +595,17 @@ bool OverviewSession::IsWindowInOverview(const aura::Window* window) {
return false; return false;
} }
OverviewItem* OverviewSession::GetOverviewItemForWindow(
const aura::Window* window) {
for (const std::unique_ptr<OverviewGrid>& grid : grid_list_) {
OverviewItem* item = grid->GetOverviewItemContaining(window);
if (item)
return item;
}
NOTREACHED();
return nullptr;
}
void OverviewSession::SetWindowListNotAnimatedWhenExiting( void OverviewSession::SetWindowListNotAnimatedWhenExiting(
aura::Window* root_window) { aura::Window* root_window) {
// Find the grid accociated with |root_window|. // Find the grid accociated with |root_window|.
......
...@@ -181,7 +181,8 @@ class ASH_EXPORT OverviewSession : public display::DisplayObserver, ...@@ -181,7 +181,8 @@ class ASH_EXPORT OverviewSession : public display::DisplayObserver,
IndicatorState indicator_state); IndicatorState indicator_state);
void OnWindowDragEnded(aura::Window* dragged_window, void OnWindowDragEnded(aura::Window* dragged_window,
const gfx::PointF& location_in_screen, const gfx::PointF& location_in_screen,
bool should_drop_window_into_overview); bool should_drop_window_into_overview,
bool snap);
// 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,
...@@ -190,6 +191,9 @@ class ASH_EXPORT OverviewSession : public display::DisplayObserver, ...@@ -190,6 +191,9 @@ class ASH_EXPORT OverviewSession : public display::DisplayObserver,
// Returns true if |window| is currently showing in overview. // Returns true if |window| is currently showing in overview.
bool IsWindowInOverview(const aura::Window* window); bool IsWindowInOverview(const aura::Window* window);
// Returns the overview item for |window|.
OverviewItem* GetOverviewItemForWindow(const aura::Window* window);
// Set the window grid that's displaying in |root_window| not animate when // Set the window grid that's displaying in |root_window| not animate when
// exiting overview mode, i.e., all window items in the grid will not animate // exiting overview mode, i.e., all window items in the grid will not animate
// when exiting overview mode. It may be called in two cases: 1) When a window // when exiting overview mode. It may be called in two cases: 1) When a window
......
...@@ -141,7 +141,8 @@ void OverviewWindowDragController::Drag(const gfx::PointF& location_in_screen) { ...@@ -141,7 +141,8 @@ void OverviewWindowDragController::Drag(const gfx::PointF& location_in_screen) {
item_->SetBounds(bounds, OVERVIEW_ANIMATION_NONE); item_->SetBounds(bounds, OVERVIEW_ANIMATION_NONE);
} }
void OverviewWindowDragController::CompleteDrag( OverviewWindowDragController::DragResult
OverviewWindowDragController::CompleteDrag(
const gfx::PointF& location_in_screen) { const gfx::PointF& location_in_screen) {
// Update the split view divider bar stuatus if necessary. The divider bar // Update the split view divider bar stuatus if necessary. The divider bar
// should be placed above the dragged window after drag ends. Note here the // should be placed above the dragged window after drag ends. Note here the
...@@ -161,38 +162,54 @@ void OverviewWindowDragController::CompleteDrag( ...@@ -161,38 +162,54 @@ void OverviewWindowDragController::CompleteDrag(
IndicatorState::kNone, gfx::Point()); IndicatorState::kNone, gfx::Point());
} }
if (!did_move_) { DragResult result;
ActivateDraggedWindow(); switch (current_drag_behavior_) {
} else if (current_drag_behavior_ == DragBehavior::kDragToClose) { case DragBehavior::kNoDrag:
// If we are in drag to close mode close the window if it has been dragged NOTREACHED();
// enough, otherwise reposition it and set its opacity back to its original result = DragResult::kNeverDisambiguated;
// value. break;
overview_session_->GetGridWithRootWindow(item_->root_window())->EndNudge(); case DragBehavior::kUndefined:
if (std::abs((location_in_screen - initial_event_location_).y()) > ActivateDraggedWindow();
kDragToCloseDistanceThresholdDp) { result = DragResult::kNeverDisambiguated;
item_->AnimateAndCloseWindow( break;
(location_in_screen - initial_event_location_).y() < 0); case DragBehavior::kDragToSnap:
} else { overview_session_->RemoveDropTargetForDraggingFromOverview(item_);
item_->SetOpacity(original_opacity_); // If the window was dragged around but should not be snapped, move it
overview_session_->PositionWindows(/*animate=*/true); // back to overview window grid.
} if (!ShouldUpdateDragIndicatorsOrSnap(location_in_screen) ||
} else if (current_drag_behavior_ == DragBehavior::kDragToSnap) { snap_position_ == SplitViewController::NONE) {
overview_session_->RemoveDropTargetForDraggingFromOverview(item_); item_->set_should_restack_on_animation_end(true);
// If the window was dragged around but should not be snapped, move it back overview_session_->PositionWindows(/*animate=*/true);
// to overview window grid. result = DragResult::kCanceledDragToSnap;
if (!ShouldUpdateDragIndicatorsOrSnap(location_in_screen) || } else {
snap_position_ == SplitViewController::NONE) { SnapWindow(snap_position_);
item_->set_should_restack_on_animation_end(true); result = DragResult::kSuccessfulDragToSnap;
overview_session_->PositionWindows(/*animate=*/true); }
} else { break;
SnapWindow(snap_position_); case DragBehavior::kDragToClose:
} // If we are in drag to close mode close the window if it has been dragged
// enough, otherwise reposition it and set its opacity back to its
// original value.
overview_session_->GetGridWithRootWindow(item_->root_window())
->EndNudge();
if (std::abs((location_in_screen - initial_event_location_).y()) >
kDragToCloseDistanceThresholdDp) {
item_->AnimateAndCloseWindow(
(location_in_screen - initial_event_location_).y() < 0);
result = DragResult::kSuccessfulDragToClose;
} else {
item_->SetOpacity(original_opacity_);
overview_session_->PositionWindows(/*animate=*/true);
result = DragResult::kCanceledDragToClose;
}
break;
} }
did_move_ = false; did_move_ = false;
item_ = nullptr; item_ = nullptr;
current_drag_behavior_ = DragBehavior::kNoDrag; current_drag_behavior_ = DragBehavior::kNoDrag;
UnpauseOcclusionTracker(); UnpauseOcclusionTracker();
presentation_time_recorder_.reset(); presentation_time_recorder_.reset();
return result;
} }
void OverviewWindowDragController::StartSplitViewDragMode( void OverviewWindowDragController::StartSplitViewDragMode(
...@@ -217,9 +234,10 @@ void OverviewWindowDragController::StartSplitViewDragMode( ...@@ -217,9 +234,10 @@ void OverviewWindowDragController::StartSplitViewDragMode(
split_view_controller_->OnWindowDragStarted(item_->GetWindow()); split_view_controller_->OnWindowDragStarted(item_->GetWindow());
} }
void OverviewWindowDragController::Fling(const gfx::PointF& location_in_screen, OverviewWindowDragController::DragResult OverviewWindowDragController::Fling(
float velocity_x, const gfx::PointF& location_in_screen,
float velocity_y) { float velocity_x,
float velocity_y) {
if (current_drag_behavior_ == DragBehavior::kDragToClose || if (current_drag_behavior_ == DragBehavior::kDragToClose ||
current_drag_behavior_ == DragBehavior::kUndefined) { current_drag_behavior_ == DragBehavior::kUndefined) {
if (std::abs(velocity_y) > kFlingToCloseVelocityThreshold) { if (std::abs(velocity_y) > kFlingToCloseVelocityThreshold) {
...@@ -235,13 +253,13 @@ void OverviewWindowDragController::Fling(const gfx::PointF& location_in_screen, ...@@ -235,13 +253,13 @@ void OverviewWindowDragController::Fling(const gfx::PointF& location_in_screen,
item_ = nullptr; item_ = nullptr;
current_drag_behavior_ = DragBehavior::kNoDrag; current_drag_behavior_ = DragBehavior::kNoDrag;
UnpauseOcclusionTracker(); UnpauseOcclusionTracker();
return; return DragResult::kSuccessfulDragToClose;
} }
} }
// If the fling velocity was not high enough, or flings should be ignored, // If the fling velocity was not high enough, or flings should be ignored,
// treat it as a scroll end event. // treat it as a scroll end event.
CompleteDrag(location_in_screen); return CompleteDrag(location_in_screen);
} }
void OverviewWindowDragController::ActivateDraggedWindow() { void OverviewWindowDragController::ActivateDraggedWindow() {
......
...@@ -34,17 +34,27 @@ class ASH_EXPORT OverviewWindowDragController { ...@@ -34,17 +34,27 @@ class ASH_EXPORT OverviewWindowDragController {
kDragToClose, // On drag complete, the window will be closed, if it meets kDragToClose, // On drag complete, the window will be closed, if it meets
// requirements. // requirements.
}; };
enum class DragResult {
kNeverDisambiguated, // The drag ended without ever being disambiguated
// between drag-to-snap and drag-to-close.
kSuccessfulDragToSnap, // The drag resulted in snapping the window.
kCanceledDragToSnap, // The drag was considered as drag-to-snap, but did
// not result in snapping the window.
kSuccessfulDragToClose, // The drag resulted in closing the window.
kCanceledDragToClose, // The drag was considered as drag-to-close, but did
// not result in closing the window.
};
explicit OverviewWindowDragController(OverviewSession* overview_session); explicit OverviewWindowDragController(OverviewSession* overview_session);
~OverviewWindowDragController(); ~OverviewWindowDragController();
void InitiateDrag(OverviewItem* item, const gfx::PointF& location_in_screen); void InitiateDrag(OverviewItem* item, const gfx::PointF& location_in_screen);
void Drag(const gfx::PointF& location_in_screen); void Drag(const gfx::PointF& location_in_screen);
void CompleteDrag(const gfx::PointF& location_in_screen); DragResult CompleteDrag(const gfx::PointF& location_in_screen);
void StartSplitViewDragMode(const gfx::PointF& location_in_screen); void StartSplitViewDragMode(const gfx::PointF& location_in_screen);
void Fling(const gfx::PointF& location_in_screen, DragResult Fling(const gfx::PointF& location_in_screen,
float velocity_x, float velocity_x,
float velocity_y); float velocity_y);
void ActivateDraggedWindow(); void ActivateDraggedWindow();
void ResetGesture(); void ResetGesture();
......
...@@ -56,6 +56,14 @@ constexpr base::TimeDelta kOverviewTitleFade = ...@@ -56,6 +56,14 @@ constexpr base::TimeDelta kOverviewTitleFade =
constexpr base::TimeDelta kOverviewTitleFadeInDelay = constexpr base::TimeDelta kOverviewTitleFadeInDelay =
base::TimeDelta::FromMilliseconds(83); base::TimeDelta::FromMilliseconds(83);
// Duration of the show animation of close icons when a window is snapped.
constexpr base::TimeDelta kOverviewCloseIconFadeInOnSnap =
base::TimeDelta::FromMilliseconds(300);
// Delay before the show animation of close icons when a window is snapped.
constexpr base::TimeDelta kOverviewCloseIconFadeInOnSnapDelay =
base::TimeDelta::FromMilliseconds(750);
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:
...@@ -86,6 +94,8 @@ base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) { ...@@ -86,6 +94,8 @@ base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) {
case OVERVIEW_ANIMATION_OVERVIEW_TITLE_FADE_IN: case OVERVIEW_ANIMATION_OVERVIEW_TITLE_FADE_IN:
case OVERVIEW_ANIMATION_OVERVIEW_TITLE_FADE_OUT: case OVERVIEW_ANIMATION_OVERVIEW_TITLE_FADE_OUT:
return kOverviewTitleFade; return kOverviewTitleFade;
case OVERVIEW_ANIMATION_OVERVIEW_CLOSE_ICON_FADE_IN_ON_SNAP:
return kOverviewCloseIconFadeInOnSnap;
}; };
NOTREACHED(); NOTREACHED();
return base::TimeDelta(); return base::TimeDelta();
...@@ -155,6 +165,7 @@ ui::AnimationMetricsReporter* GetMetricsReporter( ...@@ -155,6 +165,7 @@ ui::AnimationMetricsReporter* GetMetricsReporter(
case OVERVIEW_ANIMATION_SELECTION_WINDOW: case OVERVIEW_ANIMATION_SELECTION_WINDOW:
case OVERVIEW_ANIMATION_OVERVIEW_TITLE_FADE_IN: case OVERVIEW_ANIMATION_OVERVIEW_TITLE_FADE_IN:
case OVERVIEW_ANIMATION_OVERVIEW_TITLE_FADE_OUT: case OVERVIEW_ANIMATION_OVERVIEW_TITLE_FADE_OUT:
case OVERVIEW_ANIMATION_OVERVIEW_CLOSE_ICON_FADE_IN_ON_SNAP:
return nullptr; return nullptr;
case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN:
case OVERVIEW_ANIMATION_LAYOUT_OVERVIEW_ITEMS_ON_ENTER: case OVERVIEW_ANIMATION_LAYOUT_OVERVIEW_ITEMS_ON_ENTER:
...@@ -264,6 +275,13 @@ ScopedOverviewAnimationSettings::ScopedOverviewAnimationSettings( ...@@ -264,6 +275,13 @@ ScopedOverviewAnimationSettings::ScopedOverviewAnimationSettings(
animation_settings_->SetPreemptionStrategy( animation_settings_->SetPreemptionStrategy(
ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
break; break;
case OVERVIEW_ANIMATION_OVERVIEW_CLOSE_ICON_FADE_IN_ON_SNAP:
animation_settings_->SetTweenType(gfx::Tween::FAST_OUT_SLOW_IN);
animation_settings_->SetPreemptionStrategy(
ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
animator->SchedulePauseForProperties(kOverviewCloseIconFadeInOnSnapDelay,
ui::LayerAnimationElement::OPACITY);
break;
} }
animation_settings_->SetTransitionDuration( animation_settings_->SetTransitionDuration(
GetAnimationDuration(animation_type)); GetAnimationDuration(animation_type));
......
...@@ -383,8 +383,19 @@ void SplitViewController::SnapWindow(aura::Window* window, ...@@ -383,8 +383,19 @@ void SplitViewController::SnapWindow(aura::Window* window,
if (split_view_type_ == SplitViewType::kTabletType) { if (split_view_type_ == SplitViewType::kTabletType) {
// Insert the previous snapped window to overview if overview is active. // Insert the previous snapped window to overview if overview is active.
if (previous_snapped_window) if (previous_snapped_window && GetOverviewSession()) {
InsertWindowToOverview(previous_snapped_window); InsertWindowToOverview(previous_snapped_window);
// Ensure that the close icon will fade in. This part is redundant for
// dragging from overview, but necessary for dragging from the top. For
// dragging from overview, |OverviewItem::OnSelectorItemDragEnded| will be
// called on all overview items including the |previous_snapped_window|
// item anyway, whereas for dragging from the top,
// |OverviewItem::OnSelectorItemDragEnded| already was called on all
// overview items and |previous_snapped_window| was not yet among them.
GetOverviewSession()
->GetOverviewItemForWindow(previous_snapped_window)
->OnSelectorItemDragEnded(/*snap=*/true);
}
// Update the divider position and window bounds before snapping a new // Update the divider position and window bounds before snapping a new
// window. Since the minimum size of |window| maybe larger than currently // window. Since the minimum size of |window| maybe larger than currently
......
...@@ -261,7 +261,8 @@ void TabletModeWindowDragDelegate::EndWindowDrag( ...@@ -261,7 +261,8 @@ void TabletModeWindowDragDelegate::EndWindowDrag(
if (overview_session) { if (overview_session) {
GetOverviewSession()->OnWindowDragEnded( GetOverviewSession()->OnWindowDragEnded(
dragged_window_, gfx::PointF(location_in_screen), dragged_window_, gfx::PointF(location_in_screen),
ShouldDropWindowIntoOverview(snap_position, location_in_screen)); ShouldDropWindowIntoOverview(snap_position, location_in_screen),
snap_position != SplitViewController::NONE);
} }
split_view_controller_->OnWindowDragEnded(dragged_window_, snap_position, split_view_controller_->OnWindowDragEnded(dragged_window_, snap_position,
location_in_screen); location_in_screen);
......
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