Commit 840e6acc authored by Weidong Guo's avatar Weidong Guo Committed by Commit Bot

Fix app list animation issue for toggling overview mode

Background:
When active window exists, toggling overview mode will show a
enlarge/shrink animation instead of slide up/down animation. In this
case, app list should stay invisible during the animation.

Changes:
Only run animation when overview mode is using slide animation.
Otherwise, set the animation duration to 0 so that app list will
immediately disappear when overview mode is on and will immediately
show up after overview mode animation when overview mode is off.

Bug: 876781
Change-Id: Ifc7af8838beead1dbd1b6d70ee46eec3af19dc19
Reviewed-on: https://chromium-review.googlesource.com/1186036
Commit-Queue: Weidong Guo <weidongg@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585540}
parent c4f038aa
......@@ -24,6 +24,7 @@
#include "ash/shell.h"
#include "ash/voice_interaction/voice_interaction_controller.h"
#include "ash/wallpaper/wallpaper_controller.h"
#include "ash/wm/overview/window_selector_controller.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
......@@ -498,14 +499,27 @@ void AppListControllerImpl::OnOverviewModeStarting() {
DismissAppList();
return;
}
presenter_.ScheduleOverviewModeAnimation(true /* start */);
// Only animate the app list when overview mode is using slide animation.
presenter_.ScheduleOverviewModeAnimation(
true /* start */, Shell::Get()
->window_selector_controller()
->window_selector()
->use_slide_animation() /* animate */);
}
void AppListControllerImpl::OnOverviewModeEnding() {
in_overview_mode_ = false;
if (IsHomeLauncherEnabledInTabletMode())
presenter_.ScheduleOverviewModeAnimation(false /* start */);
if (!IsHomeLauncherEnabledInTabletMode())
return;
// Only animate the app list when overview mode is using slide animation.
presenter_.ScheduleOverviewModeAnimation(
false /* start */, Shell::Get()
->window_selector_controller()
->window_selector()
->use_slide_animation() /* animate */);
}
void AppListControllerImpl::OnTabletModeStarted() {
......
......@@ -213,11 +213,12 @@ void AppListPresenterImpl::ProcessMouseWheelOffset(int y_scroll_offset) {
view_->HandleScroll(y_scroll_offset, ui::ET_MOUSEWHEEL);
}
void AppListPresenterImpl::ScheduleOverviewModeAnimation(bool start) {
void AppListPresenterImpl::ScheduleOverviewModeAnimation(bool start,
bool animate) {
if (ui::ScopedAnimationDurationScaleMode::duration_scale_mode() ==
ui::ScopedAnimationDurationScaleMode::ZERO_DURATION) {
// Start animation immediately in test.
StartOverviewModeAnimation(start);
StartOverviewModeAnimation(start, false);
return;
}
......@@ -225,16 +226,19 @@ void AppListPresenterImpl::ScheduleOverviewModeAnimation(bool start) {
start_animation_timer_.Start(
FROM_HERE, start ? base::TimeDelta() : kOverViewEndAnimationDelay,
base::BindOnce(&AppListPresenterImpl::StartOverviewModeAnimation,
base::Unretained(this), start));
base::Unretained(this), start, animate));
}
void AppListPresenterImpl::StartOverviewModeAnimation(bool start) {
void AppListPresenterImpl::StartOverviewModeAnimation(bool start,
bool animate) {
if (!GetTargetVisibility())
return;
// Calculate the source and target parameters used in the animation.
gfx::Transform transform;
transform.Translate(0, kOverViewAnimationYOffset);
const base::TimeDelta duration =
animate ? kOverViewAnimationDuration : base::TimeDelta();
const gfx::Transform source_transform = start ? gfx::Transform() : transform;
const gfx::Transform target_transform = start ? transform : gfx::Transform();
const float source_opacity = start ? 1.0f : 0.0f;
......@@ -250,7 +254,7 @@ void AppListPresenterImpl::StartOverviewModeAnimation(bool start) {
{
ui::ScopedLayerAnimationSettings animation(layer->GetAnimator());
animation.SetTransitionDuration(kOverViewAnimationDuration);
animation.SetTransitionDuration(duration);
animation.SetTweenType(gfx::Tween::FAST_OUT_SLOW_IN);
animation.SetAnimationMetricsReporter(
state_animation_metrics_reporter_.get());
......@@ -267,7 +271,7 @@ void AppListPresenterImpl::StartOverviewModeAnimation(bool start) {
{
ui::ScopedLayerAnimationSettings animation(search_box_layer->GetAnimator());
animation.SetTransitionDuration(kOverViewAnimationDuration);
animation.SetTransitionDuration(duration);
animation.SetTweenType(gfx::Tween::FAST_OUT_SLOW_IN);
animation.SetAnimationMetricsReporter(
state_animation_metrics_reporter_.get());
......
......@@ -85,11 +85,13 @@ class APP_LIST_PRESENTER_EXPORT AppListPresenterImpl
// Passes a MouseWheelEvent from the shelf to the AppListView.
void ProcessMouseWheelOffset(int y_scroll_offset);
// Schedules animation for app list when overview mode starts or ends.
void ScheduleOverviewModeAnimation(bool start);
// Schedules animation for app list when overview mode starts or ends. The
// animation duration will be set to 0 if |animate| is false.
void ScheduleOverviewModeAnimation(bool start, bool animate);
// Immediately start animation for app list when overview mode starts or ends.
void StartOverviewModeAnimation(bool start);
// The animation duration will be set to 0 if |animate| is false.
void StartOverviewModeAnimation(bool start, bool animate);
private:
// Sets the app list view and attempts to show it.
......
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