Commit f244166c authored by Avery Musbach's avatar Avery Musbach Committed by Commit Bot

splitview: Fix animation parameters for fading out the preview area.

According to the specification, when you drag a window to snap it, the
preview area (referred to as "Indicator") should fade out over 67 ms,
fast out, linear in:
https://mccanny.users.x20web.corp.google.com/www/splitscreen-motion/index.html#window-drop

Currently, it fades out over 250 ms, fast out, slow in.

BEFORE:
https://photos.app.goo.gl/MQa3rZ4jKX4hZLba7

AFTER:
https://photos.app.goo.gl/iLFHyvqxFZsfreEC6

Test: manual
Bug: 934977
Change-Id: I27d3e4d758097f2a87207880b2bc5ca9622dad7e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1504037
Commit-Queue: Avery Musbach <amusbach@chromium.org>
Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638300}
parent 786a2312
......@@ -298,8 +298,10 @@ class SplitViewDragIndicators::SplitViewDragIndicatorsView
previous_indicator_state_);
right_rotated_view_->OnIndicatorTypeChanged(indicator_state,
previous_indicator_state_);
left_highlight_view_->OnIndicatorTypeChanged(indicator_state);
right_highlight_view_->OnIndicatorTypeChanged(indicator_state);
left_highlight_view_->OnIndicatorTypeChanged(indicator_state,
previous_indicator_state_);
right_highlight_view_->OnIndicatorTypeChanged(indicator_state,
previous_indicator_state_);
if (indicator_state != IndicatorState::kNone)
Layout(previous_indicator_state_ != IndicatorState::kNone);
......
......@@ -171,22 +171,46 @@ void SplitViewHighlightView::SetColor(SkColor color) {
}
void SplitViewHighlightView::OnIndicatorTypeChanged(
IndicatorState indicator_state) {
IndicatorState indicator_state,
IndicatorState previous_indicator_state) {
if (indicator_state == IndicatorState::kNone) {
DoSplitviewOpacityAnimation(layer(),
SPLITVIEW_ANIMATION_HIGHLIGHT_FADE_OUT);
if (!SplitViewDragIndicators::IsPreviewAreaState(
previous_indicator_state)) {
DoSplitviewOpacityAnimation(layer(),
SPLITVIEW_ANIMATION_HIGHLIGHT_FADE_OUT);
return;
}
// There are two SplitViewHighlightView objects,
// |SplitViewDragIndicatorsView::left_highlight_view_| and
// |SplitViewDragIndicatorsView::right_highlight_view_|.
// |was_this_the_preview| indicates that this (in the sense of the keyword
// this) is the one that represented the preview area.
const bool was_this_the_preview =
is_right_or_bottom_ !=
SplitViewDragIndicators::IsPreviewAreaOnLeftTopOfScreen(
previous_indicator_state);
if (was_this_the_preview) {
DoSplitviewOpacityAnimation(layer(),
SPLITVIEW_ANIMATION_PREVIEW_AREA_FADE_OUT);
}
return;
}
if (SplitViewDragIndicators::IsPreviewAreaState(indicator_state)) {
const bool is_preview_on_left_or_top =
// There are two SplitViewHighlightView objects,
// |SplitViewDragIndicatorsView::left_highlight_view_| and
// |SplitViewDragIndicatorsView::right_highlight_view_|.
// |is_this_the_preview| indicates that this (in the sense of the keyword
// this) is the one that represents the preview area.
const bool is_this_the_preview =
is_right_or_bottom_ !=
SplitViewDragIndicators::IsPreviewAreaOnLeftTopOfScreen(
indicator_state);
const bool should_fade_in = is_right_or_bottom_ ? !is_preview_on_left_or_top
: is_preview_on_left_or_top;
DoSplitviewOpacityAnimation(
layer(), should_fade_in ? SPLITVIEW_ANIMATION_PREVIEW_AREA_FADE_IN
: SPLITVIEW_ANIMATION_OTHER_HIGHLIGHT_FADE_OUT);
layer(), is_this_the_preview
? SPLITVIEW_ANIMATION_PREVIEW_AREA_FADE_IN
: SPLITVIEW_ANIMATION_OTHER_HIGHLIGHT_FADE_OUT);
return;
}
......
......@@ -31,8 +31,10 @@ class ASH_EXPORT SplitViewHighlightView : public views::View {
void SetColor(SkColor color);
// Called to update the opacity of the highlights view on |indicator_state|.
void OnIndicatorTypeChanged(IndicatorState indicator_state);
// Called to update the opacity of the highlights view on transition from
// |previous_indicator_state| to |indicator_state|.
void OnIndicatorTypeChanged(IndicatorState indicator_state,
IndicatorState previous_indicator_state);
private:
friend class SplitViewHighlightViewTestApi;
......
......@@ -42,6 +42,8 @@ constexpr base::TimeDelta kLabelAnimationDelayMs =
// The time duration for the window transformation animations.
constexpr base::TimeDelta kWindowTransformMs =
base::TimeDelta::FromMilliseconds(250);
constexpr base::TimeDelta kPreviewAreaFadeOutMs =
base::TimeDelta::FromMilliseconds(67);
constexpr float kHighlightOpacity = 0.3f;
constexpr float kPreviewAreaHighlightOpacity = 0.18f;
......@@ -91,6 +93,10 @@ void GetAnimationValuesForType(
*out_preemption_strategy =
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET;
return;
case SPLITVIEW_ANIMATION_PREVIEW_AREA_FADE_OUT:
*out_duration = kPreviewAreaFadeOutMs;
*out_tween_type = gfx::Tween::FAST_OUT_LINEAR_IN;
return;
}
NOTREACHED();
......@@ -125,6 +131,7 @@ void DoSplitviewOpacityAnimation(ui::Layer* layer,
switch (type) {
case SPLITVIEW_ANIMATION_HIGHLIGHT_FADE_OUT:
case SPLITVIEW_ANIMATION_OTHER_HIGHLIGHT_FADE_OUT:
case SPLITVIEW_ANIMATION_PREVIEW_AREA_FADE_OUT:
case SPLITVIEW_ANIMATION_OVERVIEW_ITEM_FADE_OUT:
case SPLITVIEW_ANIMATION_TEXT_FADE_OUT:
case SPLITVIEW_ANIMATION_TEXT_FADE_OUT_WITH_HIGHLIGHT:
......
......@@ -32,9 +32,10 @@ enum SplitviewAnimationType {
// highlight is the preview highlight, and the other highlight is the other
// highlight.
SPLITVIEW_ANIMATION_OTHER_HIGHLIGHT_FADE_OUT,
// Used to fade in the preview area highlight which indicates the bounds of
// the window that is about to get snapped.
// Used to fade in and out the preview area highlight which indicates the
// bounds of the window that is about to get snapped.
SPLITVIEW_ANIMATION_PREVIEW_AREA_FADE_IN,
SPLITVIEW_ANIMATION_PREVIEW_AREA_FADE_OUT,
// Used to fade in and out the label on the overview item which warns users
// the item cannot be snapped. The label appears on the overview item after
// another window has been snapped.
......
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