Commit f23631fd authored by Alex Newcomer's avatar Alex Newcomer Committed by Commit Bot

cros: Launcher close animation.

On close the launcher should animate to the shelf height and the
contents of the launcher should shift their opacity to 0.

In side shelf mode the launcher has a different animation, the whole app
list shifts in opacity to 0 with no movement.

Bug: 754072
Change-Id: I245b4fa8b5dd26644d87b5f5717df73fc7dc3742
Reviewed-on: https://chromium-review.googlesource.com/619596Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#496527}
parent b9f8dc9d
......@@ -166,16 +166,18 @@ gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset(
aura::Window* root_window) {
DCHECK(Shell::HasInstance());
Shelf* shelf = Shelf::ForWindow(root_window);
// App list needs to know the new shelf layout in order to calculate its
// UI layout when AppListView visibility changes.
if (is_fullscreen_app_list_enabled_) {
return gfx::Vector2d(
0, IsSideShelf(root_window) ? 0 : kAnimationOffsetFullscreen);
int app_list_y = view_->GetBoundsInScreen().y();
return gfx::Vector2d(0, IsSideShelf(root_window)
? 0
: shelf->GetIdealBounds().y() - app_list_y);
}
Shelf* shelf = Shelf::ForWindow(root_window);
shelf->UpdateAutoHideState();
switch (shelf->alignment()) {
case SHELF_ALIGNMENT_BOTTOM:
case SHELF_ALIGNMENT_BOTTOM_LOCKED:
......
......@@ -177,18 +177,19 @@ void AppListPresenterImpl::ScheduleAnimation() {
views::Widget* widget = view_->GetWidget();
ui::Layer* layer = GetLayer(widget);
layer->GetAnimator()->StopAnimating();
gfx::Rect target_bounds = is_fullscreen_app_list_enabled_
? widget->GetNativeView()->bounds()
: widget->GetWindowBoundsInScreen();
ui::ScopedLayerAnimationSettings animation(layer->GetAnimator());
aura::Window* root_window = widget->GetNativeView()->GetRootWindow();
const gfx::Vector2d offset =
presenter_delegate_->GetVisibilityAnimationOffset(root_window);
animation.SetTransitionDuration(
base::TimeDelta animation_duration =
presenter_delegate_->GetVisibilityAnimationDuration(root_window,
is_visible_));
is_visible_);
animation.SetTransitionDuration(animation_duration);
gfx::Rect target_bounds = is_fullscreen_app_list_enabled_
? widget->GetNativeView()->bounds()
: widget->GetWindowBoundsInScreen();
if (is_fullscreen_app_list_enabled_) {
view_->StartCloseAnimation(animation_duration);
target_bounds.Offset(offset);
} else {
if (is_visible_) {
......@@ -201,11 +202,11 @@ void AppListPresenterImpl::ScheduleAnimation() {
}
animation.AddObserver(this);
layer->SetOpacity(is_visible_ ? 1.0 : 0.0);
if (is_fullscreen_app_list_enabled_) {
widget->GetNativeView()->SetBounds(target_bounds);
return;
}
layer->SetOpacity(is_visible_ ? 1.0 : 0.0);
widget->SetBounds(target_bounds);
}
......
......@@ -1142,6 +1142,7 @@ void AppListView::StartAnimationForState(AppListState target_state) {
target_state_y = display_height - kHalfAppListHeight;
break;
case CLOSED:
// The close animation is handled by the delegate.
return;
default:
break;
......@@ -1165,6 +1166,14 @@ void AppListView::StartAnimationForState(AppListState target_state) {
new ui::LayerAnimationSequence(std::move(bounds_animation_element)));
}
void AppListView::StartCloseAnimation(base::TimeDelta animation_duration) {
DCHECK(is_fullscreen_app_list_enabled_);
if (is_side_shelf_ || !is_fullscreen_app_list_enabled_)
return;
app_list_main_view_->contents_view()->FadeOutOnClose(animation_duration);
}
void AppListView::SetStateFromSearchBoxView(bool search_box_is_empty) {
switch (app_list_state_) {
case PEEKING:
......
......@@ -156,6 +156,9 @@ class APP_LIST_EXPORT AppListView : public views::BubbleDialogDelegateView,
// in progress it will be interrupted.
void StartAnimationForState(AppListState new_state);
// Starts the close animation.
void StartCloseAnimation(base::TimeDelta animation_duration);
// Changes the app list state depending on the current |app_list_state_| and
// whether the search box is empty.
void SetStateFromSearchBoxView(bool search_box_is_empty);
......
......@@ -24,6 +24,7 @@
#include "ui/app_list/views/search_result_page_view.h"
#include "ui/app_list/views/search_result_tile_item_list_view.h"
#include "ui/app_list/views/start_page_view.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/events/event.h"
......@@ -37,6 +38,15 @@ namespace {
// Layout constants.
constexpr int kDefaultContentsViewHeight = 623;
void DoCloseAnimation(base::TimeDelta animation_duration, ui::Layer* layer) {
ui::ScopedLayerAnimationSettings animation(layer->GetAnimator());
animation.SetTransitionDuration(animation_duration);
animation.SetTweenType(gfx::Tween::EASE_OUT);
animation.SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
layer->SetOpacity(0.0f);
}
} // namespace
ContentsView::ContentsView(AppListMainView* app_list_main_view,
......@@ -553,4 +563,10 @@ int ContentsView::GetDisplayHeight() const {
.height();
}
void ContentsView::FadeOutOnClose(base::TimeDelta animation_duration) {
DCHECK(is_fullscreen_app_list_enabled_);
DoCloseAnimation(animation_duration, this->layer());
DoCloseAnimation(animation_duration, GetSearchBoxView()->layer());
}
} // namespace app_list
......@@ -143,6 +143,9 @@ class APP_LIST_EXPORT ContentsView : public views::View,
// Returns the height of current display.
int GetDisplayHeight() const;
// Starts the fade out animation when the app list is closed.
void FadeOutOnClose(base::TimeDelta animation_duration);
private:
// Sets the active launcher page, accounting for whether the change is for
// search results.
......
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