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

cros: Peeking Launcher close animation

Added a closing animation for the peeking launcher. It lives in
AppListPresenterImpl because we use the callback function for the
animation.

The animations for all state changes will be in AppListView once we
move ui/app_list into ash/app_list. (I made  a note in 733662 for this).

bug=748190

Change-Id: I2e2e885306f2005aa3bf54470420a6aada99a3b6
Reviewed-on: https://chromium-review.googlesource.com/588083
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Reviewed-by: default avatarYury Khmel <khmel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491639}
parent d431d1dc
......@@ -24,6 +24,12 @@ namespace {
// Duration for show/hide animation in milliseconds.
constexpr int kAnimationDurationMs = 200;
// Duration for hide animation for the fullscreen app list in milliseconds.
constexpr int kAnimationDurationMsFullscreen = 300;
// Offset for the hide animation for the fullscreen app list in DIPs.
constexpr int kHideAnimationOffset = 400;
// The maximum shift in pixels when over-scroll happens.
constexpr int kMaxOverScrollShift = 48;
......@@ -180,23 +186,29 @@ void AppListPresenterImpl::ScheduleAnimation() {
views::Widget* widget = view_->GetWidget();
ui::Layer* layer = GetLayer(widget);
layer->GetAnimator()->StopAnimating();
gfx::Rect target_bounds = widget->GetWindowBoundsInScreen();
gfx::Vector2d offset = presenter_delegate_->GetVisibilityAnimationOffset(
widget->GetNativeView()->GetRootWindow());
if (is_visible_) {
gfx::Rect start_bounds = gfx::Rect(target_bounds);
start_bounds.Offset(offset);
widget->SetBounds(start_bounds);
ui::ScopedLayerAnimationSettings animation(layer->GetAnimator());
if (is_fullscreen_app_list_enabled_) {
// Set up the hide animation for the app list.
target_bounds.Offset(gfx::Vector2d(0, kHideAnimationOffset));
animation.SetTransitionDuration(
base::TimeDelta::FromMilliseconds(kAnimationDurationMsFullscreen));
} else {
target_bounds.Offset(offset);
gfx::Vector2d offset = presenter_delegate_->GetVisibilityAnimationOffset(
widget->GetNativeView()->GetRootWindow());
if (is_visible_) {
gfx::Rect start_bounds = gfx::Rect(target_bounds);
start_bounds.Offset(offset);
widget->SetBounds(start_bounds);
} else {
target_bounds.Offset(offset);
}
animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
is_visible_ ? 0 : kAnimationDurationMs));
}
ui::ScopedLayerAnimationSettings animation(layer->GetAnimator());
animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
is_visible_ ? 0 : kAnimationDurationMs));
animation.AddObserver(this);
layer->SetOpacity(is_visible_ ? 1.0 : 0.0);
widget->SetBounds(target_bounds);
}
......
......@@ -426,11 +426,14 @@ void AppListView::InitializeFullscreen(gfx::NativeView parent,
const display::Display display_nearest_view = GetDisplayNearestView();
const gfx::Rect display_work_area_bounds = display_nearest_view.work_area();
const int bottom_of_screen = display_nearest_view.size().height();
// todo(crbug.com/750664): Modify animations and bounds of the launcher
// in side shelf mode.
gfx::Rect app_list_overlay_view_bounds(
display_work_area_bounds.x(),
bottom_of_screen, // Set the widget at the bottom of the screen so it can
// animate up when shown.
bottom_of_screen -
kShelfSize, // Set the widget height to the shelf height to replace
// the shelf background on show animation with no
// flicker.
display_work_area_bounds.width(),
display_work_area_bounds.height() + kShelfSize);
......@@ -848,17 +851,16 @@ void AppListView::SetState(AppListState new_state) {
}
}
StartAnimationForState(new_state_override);
switch (new_state_override) {
case PEEKING: {
switch (app_list_state_) {
case HALF:
case FULLSCREEN_ALL_APPS:
StartAnimationForState(new_state_override);
app_list_main_view_->contents_view()->SetActiveState(
AppListModel::STATE_START);
break;
case PEEKING: {
StartAnimationForState(new_state_override);
app_list_main_view_->contents_view()->SetActiveState(
AppListModel::STATE_START);
break;
......@@ -871,21 +873,8 @@ void AppListView::SetState(AppListState new_state) {
break;
}
case HALF:
switch (app_list_state_) {
case PEEKING:
case HALF: {
StartAnimationForState(new_state_override);
break;
}
case FULLSCREEN_SEARCH:
case FULLSCREEN_ALL_APPS:
case CLOSED:
NOTREACHED();
break;
}
break;
case FULLSCREEN_ALL_APPS: {
StartAnimationForState(new_state_override);
AppsContainerView* apps_container_view =
app_list_main_view_->contents_view()->apps_container_view();
......@@ -897,7 +886,6 @@ void AppListView::SetState(AppListState new_state) {
break;
}
case FULLSCREEN_SEARCH:
StartAnimationForState(new_state_override);
break;
case CLOSED:
app_list_main_view_->Close();
......@@ -918,6 +906,8 @@ void AppListView::StartAnimationForState(AppListState target_state) {
case HALF:
target_state_y = display_height - kHalfAppListHeight;
break;
case CLOSED:
return;
default:
break;
}
......@@ -925,18 +915,19 @@ void AppListView::StartAnimationForState(AppListState target_state) {
gfx::Rect target_bounds = fullscreen_widget_->GetWindowBoundsInScreen();
target_bounds.set_y(target_state_y);
std::unique_ptr<ui::LayerAnimationElement> animation_element =
std::unique_ptr<ui::LayerAnimationElement> bounds_animation_element =
ui::LayerAnimationElement::CreateBoundsElement(
target_bounds,
base::TimeDelta::FromMilliseconds(kAppListAnimationDurationMs));
animation_element->set_tween_type(gfx::Tween::EASE_OUT);
bounds_animation_element->set_tween_type(gfx::Tween::EASE_OUT);
ui::LayerAnimator* animator = fullscreen_widget_->GetLayer()->GetAnimator();
animator->set_preemption_strategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
animator->StopAnimating();
animator->ScheduleAnimation(
new ui::LayerAnimationSequence(std::move(animation_element)));
new ui::LayerAnimationSequence(std::move(bounds_animation_element)));
}
void AppListView::SetStateFromSearchBoxView(bool search_box_is_empty) {
......
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