Commit 31628dc5 authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

overview: The animation types use the correct metrics reporters.

I dont think this fixes the bug, but its nice to have the correct
information.

Test: manual
Bug: 863304
Change-Id: I60198f34e624ef2faae9734faee17441d44d002f
Reviewed-on: https://chromium-review.googlesource.com/1182521
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584829}
parent 61e450a2
......@@ -18,7 +18,9 @@ enum OverviewAnimationType {
OVERVIEW_ANIMATION_EXIT_OVERVIEW_MODE_FADE_OUT,
// Used to position windows when entering/exiting overview mode and when a
// window is closed while overview mode is active.
OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS,
OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS_ON_ENTER,
OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS_IN_OVERVIEW,
OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS_ON_EXIT,
// Used to restore windows to their original position when exiting overview
// mode.
OVERVIEW_ANIMATION_RESTORE_WINDOW,
......
......@@ -106,9 +106,9 @@ bool IsOverviewSwipeToCloseEnabled() {
return base::FeatureList::IsEnabled(features::kOverviewSwipeToClose);
}
void FadeOutWidgetAndMaybeSlideOnEnter(views::Widget* widget,
OverviewAnimationType animation_type,
bool slide) {
void FadeInWidgetAndMaybeSlideOnEnter(views::Widget* widget,
OverviewAnimationType animation_type,
bool slide) {
aura::Window* window = widget->GetNativeWindow();
if (window->layer()->GetTargetOpacity() == 1.f && !slide)
return;
......
......@@ -30,9 +30,9 @@ bool IsOverviewSwipeToCloseEnabled();
// Fades |widget| to opacity one with the enter overview settings. Additionally
// place |widget| closer to the top of screen and slide it down if |slide| is
// true.
void FadeOutWidgetAndMaybeSlideOnEnter(views::Widget* widget,
OverviewAnimationType animation_type,
bool slide);
void FadeInWidgetAndMaybeSlideOnEnter(views::Widget* widget,
OverviewAnimationType animation_type,
bool slide);
// Fades |widget| to opacity zero with animation settings depending on
// |animation_type|. Used by several classes which need to be destroyed on
......
......@@ -169,7 +169,8 @@ void OverviewWindowDragController::CompleteDrag(
void OverviewWindowDragController::StartSplitViewDragMode(
const gfx::Point& location_in_screen) {
item_->ScaleUpSelectedItem(OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS);
item_->ScaleUpSelectedItem(
OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS_IN_OVERVIEW);
did_move_ = true;
current_drag_behavior_ = DragBehavior::kDragToSnap;
......
......@@ -43,7 +43,9 @@ base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) {
return base::TimeDelta::FromMilliseconds(kFadeInMs);
case OVERVIEW_ANIMATION_EXIT_OVERVIEW_MODE_FADE_OUT:
return base::TimeDelta::FromMilliseconds(kFadeOutMs);
case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS:
case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS_ON_ENTER:
case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS_IN_OVERVIEW:
case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS_ON_EXIT:
case OVERVIEW_ANIMATION_RESTORE_WINDOW:
case OVERVIEW_ANIMATION_RESTORE_WINDOW_ZERO:
return base::TimeDelta::FromMilliseconds(kTransitionMs);
......@@ -112,14 +114,16 @@ ui::AnimationMetricsReporter* GetMetricsReporter(
OverviewAnimationType animation_type) {
switch (animation_type) {
case OVERVIEW_ANIMATION_NONE:
case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS_IN_OVERVIEW:
return nullptr;
case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN:
case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS:
case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS_ON_ENTER:
case OVERVIEW_ANIMATION_ENTER_FROM_HOME_LAUNCHER:
return g_reporter_enter.Pointer();
case OVERVIEW_ANIMATION_EXIT_OVERVIEW_MODE_FADE_OUT:
case OVERVIEW_ANIMATION_RESTORE_WINDOW:
case OVERVIEW_ANIMATION_RESTORE_WINDOW_ZERO:
case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS_ON_EXIT:
case OVERVIEW_ANIMATION_EXIT_TO_HOME_LAUNCHER:
return g_reporter_exit.Pointer();
case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM:
......@@ -155,7 +159,9 @@ ScopedOverviewAnimationSettings::ScopedOverviewAnimationSettings(
animation_settings_->SetPreemptionStrategy(
ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
break;
case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS:
case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS_ON_ENTER:
case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS_IN_OVERVIEW:
case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS_ON_EXIT:
case OVERVIEW_ANIMATION_RESTORE_WINDOW:
animation_settings_->SetTweenType(gfx::Tween::EASE_OUT);
animation_settings_->SetPreemptionStrategy(
......
......@@ -253,10 +253,12 @@ void ScopedTransformOverviewWindow::BeginScopedAnimation(
animation_settings->push_back(std::move(settings));
}
if (animation_type == OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS &&
animation_settings->size() > 0u) {
const bool is_layout_animation =
animation_type == OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS_ON_ENTER ||
animation_type == OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS_IN_OVERVIEW ||
animation_type == OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS_ON_EXIT;
if (is_layout_animation && animation_settings->size() > 0u)
animation_settings->front()->AddObserver(this);
}
}
bool ScopedTransformOverviewWindow::Contains(const aura::Window* target) const {
......@@ -590,7 +592,7 @@ void ScopedTransformOverviewWindow::CreateMirrorWindowForMinimizedState() {
minimized_widget_->SetBounds(bounds);
minimized_widget_->Show();
FadeOutWidgetAndMaybeSlideOnEnter(
FadeInWidgetAndMaybeSlideOnEnter(
minimized_widget_.get(), OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN,
/*slide=*/false);
}
......
......@@ -392,6 +392,10 @@ void WindowGrid::PositionWindows(
// Position the windows centering the left-aligned rows vertically. Do not
// position |ignored_item| if it is not nullptr and matches a item in
// |window_list_|.
OverviewAnimationType animation_type =
transition == WindowSelector::OverviewTransition::kEnter
? OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS_ON_ENTER
: OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS_IN_OVERVIEW;
for (size_t i = 0; i < window_list_.size(); ++i) {
WindowSelectorItem* window_item = window_list_[i].get();
if (window_item->animating_to_close() ||
......@@ -410,10 +414,9 @@ void WindowGrid::PositionWindows(
if (IsNewSelectorItemWindow(window_item->GetWindow()))
should_animate_item = false;
window_item->SetBounds(rects[i],
should_animate_item
? OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS
: OVERVIEW_ANIMATION_NONE);
window_item->SetBounds(rects[i], should_animate_item
? animation_type
: OVERVIEW_ANIMATION_NONE);
}
// If the selection widget is active, reposition it without any animation.
......
......@@ -545,12 +545,12 @@ void WindowSelectorItem::SlideWindowIn() {
DCHECK(item_widget_);
DCHECK(transform_window_.minimized_widget());
FadeOutWidgetAndMaybeSlideOnEnter(item_widget_.get(),
OVERVIEW_ANIMATION_ENTER_FROM_HOME_LAUNCHER,
/*slide=*/true);
FadeOutWidgetAndMaybeSlideOnEnter(transform_window_.minimized_widget(),
OVERVIEW_ANIMATION_ENTER_FROM_HOME_LAUNCHER,
/*slide=*/true);
FadeInWidgetAndMaybeSlideOnEnter(item_widget_.get(),
OVERVIEW_ANIMATION_ENTER_FROM_HOME_LAUNCHER,
/*slide=*/true);
FadeInWidgetAndMaybeSlideOnEnter(transform_window_.minimized_widget(),
OVERVIEW_ANIMATION_ENTER_FROM_HOME_LAUNCHER,
/*slide=*/true);
}
float WindowSelectorItem::GetItemScale(const gfx::Size& size) {
......@@ -628,8 +628,8 @@ void WindowSelectorItem::AnimateAndCloseWindow(bool up) {
auto animate_window = [this](aura::Window* window,
const gfx::Transform& transform, bool observe) {
ScopedOverviewAnimationSettings settings(OVERVIEW_ANIMATION_RESTORE_WINDOW,
window);
ScopedOverviewAnimationSettings settings(
OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM, window);
gfx::Transform original_transform = window->transform();
original_transform.ConcatTransform(transform);
window->SetTransform(original_transform);
......@@ -637,7 +637,7 @@ void WindowSelectorItem::AnimateAndCloseWindow(bool up) {
settings.AddObserver(this);
};
AnimateOpacity(0.0, OVERVIEW_ANIMATION_RESTORE_WINDOW);
AnimateOpacity(0.0, OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM);
animate_window(item_widget_->GetNativeWindow(), transform, false);
animate_window(GetWindowForStacking(), transform, true);
}
......@@ -646,13 +646,11 @@ void WindowSelectorItem::CloseWindow() {
gfx::Rect inset_bounds(target_bounds_);
inset_bounds.Inset(target_bounds_.width() * kPreCloseScale,
target_bounds_.height() * kPreCloseScale);
OverviewAnimationType animation_type =
OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM;
// Scale down both the window and label.
SetBounds(inset_bounds, animation_type);
SetBounds(inset_bounds, OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM);
// First animate opacity to an intermediate value concurrently with the
// scaling animation.
AnimateOpacity(kClosingItemOpacity, animation_type);
AnimateOpacity(kClosingItemOpacity, OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM);
// Fade out the window and the label, effectively hiding them.
AnimateOpacity(0.0, OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM);
......@@ -947,7 +945,7 @@ float WindowSelectorItem::GetOpacity() {
OverviewAnimationType WindowSelectorItem::GetExitOverviewAnimationType() {
return should_animate_when_exiting_
? OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS
? OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS_ON_EXIT
: OVERVIEW_ANIMATION_NONE;
}
......@@ -1051,10 +1049,12 @@ void WindowSelectorItem::CreateWindowLabel(const base::string16& title) {
UpdateCannotSnapWarningVisibility();
item_widget_->SetContentsView(caption_container_view_);
label_view_->SetVisible(false);
item_widget_->SetOpacity(0);
item_widget_->Show();
item_widget_->SetOpacity(0);
item_widget_->GetLayer()->SetMasksToBounds(false);
FadeInWidgetAndMaybeSlideOnEnter(
item_widget_.get(), OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN,
/*slide=*/false);
}
void WindowSelectorItem::UpdateHeaderLayout(
......@@ -1074,13 +1074,6 @@ void WindowSelectorItem::UpdateHeaderLayout(
? -label_rect.height()
: 0);
if (!label_view_->visible()) {
label_view_->SetVisible(true);
FadeOutWidgetAndMaybeSlideOnEnter(
item_widget_.get(), OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN,
false);
}
aura::Window* widget_window = item_widget_->GetNativeWindow();
// For the first update, place the widget at its destination.
ScopedOverviewAnimationSettings animation_settings(
......
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