Commit 3dfd5992 authored by Alex Newcomer's avatar Alex Newcomer Committed by Commit Bot

cros: Add layers to bring the launcher open/close animation back

This animation was removed unintentionally, this CL brings it back.
Also added better comments so the animation's importance is more
obvious.

Bug: 910496
Change-Id: If505bea1683d7ae456dcedbdb0a9e97ea58e02de
Reviewed-on: https://chromium-review.googlesource.com/c/1368604Reviewed-by: default avatarJenny Zhang <jennyz@chromium.org>
Reviewed-by: default avatarMitsuru Oshima (gardener - slow) <oshima@chromium.org>
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616080}
parent a8acf2db
......@@ -311,8 +311,9 @@ void AppListPresenterImpl::ScheduleAnimation() {
aura::Window* root_window = widget->GetNativeView()->GetRootWindow();
const gfx::Vector2d offset =
delegate_->GetVisibilityAnimationOffset(root_window);
base::TimeDelta animation_duration =
delegate_->GetVisibilityAnimationDuration(root_window, is_visible_);
const base::TimeDelta animation_duration =
delegate_->GetVisibilityAnimationDuration(root_window,
view_->is_fullscreen());
gfx::Rect target_bounds = widget->GetNativeView()->bounds();
target_bounds.Offset(offset);
widget->GetNativeView()->SetBounds(target_bounds);
......
......@@ -74,6 +74,8 @@ void AppListMainView::AddContentsViews() {
DCHECK(search_box_view_);
contents_view_ = new ContentsView(app_list_view_);
contents_view_->Init(model_);
contents_view_->SetPaintToLayer(ui::LAYER_NOT_DRAWN);
contents_view_->layer()->SetMasksToBounds(true);
AddChildView(contents_view_);
search_box_view_->set_contents_view(contents_view_);
......
......@@ -1231,6 +1231,15 @@ void AppListView::StartAnimationForState(AppListViewState target_state) {
animation_duration = kAppListAnimationDurationMs;
}
if (fullscreen_widget_->GetNativeView()->bounds().y() ==
display.work_area().bottom()) {
// If the animation start position is the bottom of the screen, activate the
// fade in animation. This prevents the search box from flashing at the
// bottom of the screen as it goes behind the shelf.
app_list_main_view_->contents_view()->FadeInOnOpen(
base::TimeDelta::FromMilliseconds(animation_duration));
}
ui::Layer* layer = fullscreen_widget_->GetLayer();
layer->SetBounds(target_bounds);
gfx::Transform transform;
......@@ -1260,7 +1269,15 @@ void AppListView::StartCloseAnimation(base::TimeDelta animation_duration) {
if (is_side_shelf_)
return;
// If animating from PEEKING, animate the opacity twice as fast so the
// SearchBoxView does not flash behind the shelf.
if (app_list_state_ == AppListViewState::PEEKING ||
app_list_state_ == AppListViewState::CLOSED) {
animation_duration /= 2;
}
SetState(AppListViewState::CLOSED);
app_list_main_view_->contents_view()->FadeOutOnClose(animation_duration);
}
void AppListView::SetStateFromSearchBoxView(bool search_box_is_empty,
......
......@@ -42,6 +42,17 @@ namespace {
constexpr float kExpandArrowOpacityStartProgress = 0.61;
constexpr float kExpandArrowOpacityEndProgress = 1;
void DoAnimation(base::TimeDelta animation_duration,
ui::Layer* layer,
float target_opacity) {
ui::ScopedLayerAnimationSettings animation(layer->GetAnimator());
animation.SetTransitionDuration(animation_duration);
animation.SetTweenType(gfx::Tween::EASE_IN);
animation.SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
layer->SetOpacity(target_opacity);
}
} // namespace
ContentsView::ContentsView(AppListView* app_list_view)
......@@ -507,6 +518,18 @@ void ContentsView::TransitionChanged() {
void ContentsView::TransitionEnded() {}
void ContentsView::FadeOutOnClose(base::TimeDelta animation_duration) {
DoAnimation(animation_duration, layer(), 0.0f);
DoAnimation(animation_duration, GetSearchBoxView()->layer(), 0.0f);
}
void ContentsView::FadeInOnOpen(base::TimeDelta animation_duration) {
GetSearchBoxView()->layer()->SetOpacity(0.0f);
layer()->SetOpacity(0.0f);
DoAnimation(animation_duration, layer(), 1.0f);
DoAnimation(animation_duration, GetSearchBoxView()->layer(), 1.0f);
}
views::View* ContentsView::GetSelectedView() const {
return app_list_pages_[GetActivePageIndex()]->GetSelectedView();
}
......
......@@ -150,6 +150,14 @@ class APP_LIST_EXPORT ContentsView : public views::View,
void Layout() override;
const char* GetClassName() const override;
// Starts the fade out animation when the app list is closed. This
// prevents the contents from being visible behind the shelf.
void FadeOutOnClose(base::TimeDelta animation_duration);
// Starts the fade in animation when the app list is opened. This prevents the
// contents from being visible behind the shelf.
void FadeInOnOpen(base::TimeDelta animation_duration);
// Overridden from PaginationModelObserver:
void TotalPagesChanged() override;
void SelectedPageChanged(int old_selected, int new_selected) override;
......
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