Commit 9c9eb002 authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

Update home arrow visibility when starting to show home launcher

Removes HomeScreenDelegate::UpdateAfterHomeLauncherShown, which was only
updating expand arrow visibility, and move the logic to
HomeScreenDelegate::OnHomeLauncherTargetPositionChanged.
The method was used to update expand arrow visibility when home launcher
is shown. Given that OnHomeLauncherTargetPositionChanged is expected to
get called during the same sequence, expand arrow visilibity can be
moved there without losing much, and reduces the number of methods that
need to be called while using gestures to show/hide home launcher.

Also, updates how app list progress is calculated when app list is
scaled in tablet mode to ignore app list translation that was added
during scaling (without this, if arrow is painted while app list view is
scaled down, it might be slightly bent).

BUG=1022530

Change-Id: Ie284b413bdc576121757c1c4bb1b4280c97e06b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1904235Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarManu Cornet <manucornet@chromium.org>
Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Commit-Queue: Toni Baržić <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714006}
parent cc2ed07e
...@@ -858,11 +858,6 @@ void AppListControllerImpl::UpdateScaleAndOpacityForHomeLauncher( ...@@ -858,11 +858,6 @@ void AppListControllerImpl::UpdateScaleAndOpacityForHomeLauncher(
std::move(callback)); std::move(callback));
} }
void AppListControllerImpl::UpdateAfterHomeLauncherShown() {
// Show or hide the expand arrow view.
UpdateExpandArrowVisibility();
}
base::Optional<base::TimeDelta> base::Optional<base::TimeDelta>
AppListControllerImpl::GetOptionalAnimationDuration() { AppListControllerImpl::GetOptionalAnimationDuration() {
if (model_->state() == ash::AppListState::kStateEmbeddedAssistant) { if (model_->state() == ash::AppListState::kStateEmbeddedAssistant) {
...@@ -1407,6 +1402,12 @@ void AppListControllerImpl::OnVisibilityWillChange(bool visible, ...@@ -1407,6 +1402,12 @@ void AppListControllerImpl::OnVisibilityWillChange(bool visible,
last_target_visible_ = real_target_visibility; last_target_visible_ = real_target_visibility;
last_target_visible_display_id_ = display_id; last_target_visible_display_id_ = display_id;
// Update the arrow visibility when starting to show the home screen
// (presumably, the visibility has already been updated if home is being
// hidden).
if (real_target_visibility && IsTabletMode())
UpdateExpandArrowVisibility();
if (client_) if (client_)
client_->OnAppListVisibilityWillChange(real_target_visibility); client_->OnAppListVisibilityWillChange(real_target_visibility);
......
...@@ -283,7 +283,6 @@ class ASH_EXPORT AppListControllerImpl ...@@ -283,7 +283,6 @@ class ASH_EXPORT AppListControllerImpl
float opacity, float opacity,
base::Optional<AnimationInfo> animation_info, base::Optional<AnimationInfo> animation_info,
UpdateAnimationSettingsCallback callback) override; UpdateAnimationSettingsCallback callback) override;
void UpdateAfterHomeLauncherShown() override;
base::Optional<base::TimeDelta> GetOptionalAnimationDuration() override; base::Optional<base::TimeDelta> GetOptionalAnimationDuration() override;
void OnHomeLauncherAnimationComplete(bool shown, int64_t display_id) override; void OnHomeLauncherAnimationComplete(bool shown, int64_t display_id) override;
void OnHomeLauncherTargetPositionChanged(bool showing, void OnHomeLauncherTargetPositionChanged(bool showing,
......
...@@ -155,10 +155,8 @@ TEST_F(AppListControllerImplTest, UpdateExpandArrowViewVisibility) { ...@@ -155,10 +155,8 @@ TEST_F(AppListControllerImplTest, UpdateExpandArrowViewVisibility) {
// Activate w1 then press home launcher button. Expand arrow view should show // Activate w1 then press home launcher button. Expand arrow view should show
// because w1 still exists. // because w1 still exists.
wm::ActivateWindow(w1.get()); wm::ActivateWindow(w1.get());
Shell::Get() Shell::Get()->home_screen_controller()->GoHome(
->home_screen_controller() display::Screen::GetScreen()->GetPrimaryDisplay().id());
->home_launcher_gesture_handler()
->ShowHomeLauncher(display::Screen::GetScreen()->GetPrimaryDisplay());
EXPECT_EQ(WindowStateType::kMinimized, EXPECT_EQ(WindowStateType::kMinimized,
WindowState::Get(w1.get())->GetStateType()); WindowState::Get(w1.get())->GetStateType());
EXPECT_TRUE(GetExpandArrowViewVisibility()); EXPECT_TRUE(GetExpandArrowViewVisibility());
...@@ -867,10 +865,8 @@ TEST_F(AppListControllerImplMetricsTest, ...@@ -867,10 +865,8 @@ TEST_F(AppListControllerImplMetricsTest,
// hidden. // hidden.
std::unique_ptr<aura::Window> w( std::unique_ptr<aura::Window> w(
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400))); AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400)));
Shell::Get() Shell::Get()->home_screen_controller()->GoHome(
->home_screen_controller() display::Screen::GetScreen()->GetPrimaryDisplay().id());
->home_launcher_gesture_handler()
->ShowHomeLauncher(display::Screen::GetScreen()->GetPrimaryDisplay());
EXPECT_FALSE(w->IsVisible()); EXPECT_FALSE(w->IsVisible());
EXPECT_EQ(AppListViewState::kFullscreenAllApps, EXPECT_EQ(AppListViewState::kFullscreenAllApps,
GetAppListView()->app_list_state()); GetAppListView()->app_list_state());
...@@ -940,10 +936,8 @@ TEST_F(AppListControllerImplMetricsTest, ...@@ -940,10 +936,8 @@ TEST_F(AppListControllerImplMetricsTest,
// hidden. // hidden.
std::unique_ptr<aura::Window> w( std::unique_ptr<aura::Window> w(
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400))); AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400)));
Shell::Get() Shell::Get()->home_screen_controller()->GoHome(
->home_screen_controller() display::Screen::GetScreen()->GetPrimaryDisplay().id());
->home_launcher_gesture_handler()
->ShowHomeLauncher(display::Screen::GetScreen()->GetPrimaryDisplay());
EXPECT_FALSE(w->IsVisible()); EXPECT_FALSE(w->IsVisible());
EXPECT_EQ(AppListViewState::kFullscreenAllApps, EXPECT_EQ(AppListViewState::kFullscreenAllApps,
GetAppListView()->app_list_state()); GetAppListView()->app_list_state());
......
...@@ -1860,6 +1860,16 @@ int AppListView::GetCurrentAppListHeight() const { ...@@ -1860,6 +1860,16 @@ int AppListView::GetCurrentAppListHeight() const {
} }
float AppListView::GetAppListTransitionProgress(int flags) const { float AppListView::GetAppListTransitionProgress(int flags) const {
// During transition between home and overview in tablet mode, the app list
// widget gets scaled down from full screen state - if this is the case,
// the app list layout should match the current app list state, so return
// the progress for the current app list state.
const gfx::Transform transform = GetWidget()->GetLayer()->transform();
if (is_tablet_mode_ && transform.IsScaleOrTranslation() &&
!transform.IsIdentityOrTranslation()) {
return GetTransitionProgressForState(app_list_state_);
}
int current_height = GetCurrentAppListHeight(); int current_height = GetCurrentAppListHeight();
if (flags & kProgressFlagWithTransform) { if (flags & kProgressFlagWithTransform) {
current_height -= current_height -=
......
...@@ -501,8 +501,6 @@ void HomeLauncherGestureHandler::OnImplicitAnimationsCompleted() { ...@@ -501,8 +501,6 @@ void HomeLauncherGestureHandler::OnImplicitAnimationsCompleted() {
} }
if (is_final_state_show) { if (is_final_state_show) {
home_screen_delegate->UpdateAfterHomeLauncherShown();
std::vector<aura::Window*> windows_to_hide_minimize; std::vector<aura::Window*> windows_to_hide_minimize;
windows_to_hide_minimize.push_back(GetActiveWindow()); windows_to_hide_minimize.push_back(GetActiveWindow());
......
...@@ -90,9 +90,6 @@ class HomeScreenDelegate { ...@@ -90,9 +90,6 @@ class HomeScreenDelegate {
base::Optional<AnimationInfo> animation_info, base::Optional<AnimationInfo> animation_info,
UpdateAnimationSettingsCallback callback) = 0; UpdateAnimationSettingsCallback callback) = 0;
// Updates the home launcher view after its show animation has completed.
virtual void UpdateAfterHomeLauncherShown() = 0;
// Returns an optional animation duration which is going to be used to set // Returns an optional animation duration which is going to be used to set
// the transition animation if provided. // the transition animation if provided.
virtual base::Optional<base::TimeDelta> GetOptionalAnimationDuration() = 0; virtual base::Optional<base::TimeDelta> GetOptionalAnimationDuration() = 0;
......
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