Commit ccb54485 authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

Use hotseat size instead of shelf size when laying out app list

AppListView uses AppListViewDelegate::GetShelfSize() to get the shelf
size for calculating:
*   background shield rounded corners.
*   the app list layout.

For both purposes, app list can assume that the shelf height equals
non-in-app height (i.e. assume that in-app shelf is not used).
The former is only used in clamshell mode. For the later, app list will
not be shown with the in-app shelf (at least in static state).

Though, while transitioning from app window to app list (e.g. while
dragging the app window), app list view will be laid out while in-app
shelf shown - if the actual current shelf height is used to calculate
the layout, the app list grid items might jump up once the transition
completes (as the shelf height changes and the app list gets laid out
again with less vertical space available).

This can be avoided if app list view always assumed that the shelf size
equals the non-in-app size, as done in this cl.

BUG=1013706

Change-Id: I5175781baefe1e92cf8abcd92185b1b3fdf8dc19
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1857200Reviewed-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@{#713184}
parent 4e56a478
......@@ -1304,7 +1304,7 @@ gfx::Rect AppListControllerImpl::SnapBoundsToDisplayEdge(
}
int AppListControllerImpl::GetShelfHeight() {
return ShelfConfig::Get()->shelf_size();
return ShelfConfig::Get()->system_shelf_size();
}
void AppListControllerImpl::RecordAppLaunched(
......
......@@ -60,6 +60,9 @@ class ASH_EXPORT ShelfConfig : public TabletModeObserver,
// Size of the shelf when an app is visible in tablet mode.
int in_app_shelf_size() const;
// Size of the shelf when not in tablet mode, or when no apps are visible.
int system_shelf_size() const;
// Size of the hotseat, which contains the scrollable shelf in tablet mode.
int hotseat_size() const;
......@@ -164,6 +167,11 @@ class ASH_EXPORT ShelfConfig : public TabletModeObserver,
// Updates |is_dense_| and notifies all observers of the update.
void UpdateIsDense();
// Gets the current shelf size.
// |ignore_in_app_state| - Whether the returned shelf size should be
// calculated as if is_in_app() returns false.
int GetShelfSize(bool ignore_in_app_state) const;
// Whether shelf is currently standard or dense.
bool is_dense_;
......
......@@ -122,24 +122,17 @@ void ShelfConfig::OnAppListVisibilityWillChange(bool shown,
}
int ShelfConfig::shelf_size() const {
// Before the hotseat redesign, the shelf always has the same size.
if (!chromeos::switches::ShouldShowShelfHotseat())
return 56;
// In clamshell mode, the shelf always has the same size.
if (!IsTabletMode())
return 48;
if (is_in_app())
return in_app_shelf_size();
return is_dense_ ? 48 : 56;
return GetShelfSize(false /*ignore_in_app_state*/);
}
int ShelfConfig::in_app_shelf_size() const {
return is_dense_ ? 36 : 40;
}
int ShelfConfig::system_shelf_size() const {
return GetShelfSize(true /*ignore_in_app_state*/);
}
int ShelfConfig::hotseat_size() const {
if (!chromeos::switches::ShouldShowShelfHotseat() || !IsTabletMode()) {
return shelf_size();
......@@ -218,6 +211,21 @@ void ShelfConfig::UpdateIsDense() {
OnShelfConfigUpdated();
}
int ShelfConfig::GetShelfSize(bool ignore_in_app_state) const {
// Before the hotseat redesign, the shelf always has the same size.
if (!chromeos::switches::ShouldShowShelfHotseat())
return 56;
// In clamshell mode, the shelf always has the same size.
if (!IsTabletMode())
return 48;
if (!ignore_in_app_state && is_in_app())
return in_app_shelf_size();
return is_dense_ ? 48 : 56;
}
SkColor ShelfConfig::GetShelfControlButtonColor() const {
if (chromeos::switches::ShouldShowShelfHotseat() && IsTabletMode() &&
Shell::Get()->session_controller()->GetSessionState() ==
......
......@@ -104,11 +104,15 @@ TEST_F(ShelfConfigTest, ShelfSizeChangesWithContext) {
std::unique_ptr<views::Widget> widget = CreateTestWidget();
GetAppListTestHelper()->CheckVisibility(false);
const int tablet_dense_in_app = ShelfConfig::Get()->shelf_size();
const int system_shelf_tablet_dense_in_app =
ShelfConfig::Get()->system_shelf_size();
const int control_tablet_dense_in_app = ShelfConfig::Get()->control_size();
widget->Close();
GetAppListTestHelper()->CheckVisibility(true);
const int tablet_dense_home = ShelfConfig::Get()->shelf_size();
const int system_shelf_tablet_dense_home =
ShelfConfig::Get()->system_shelf_size();
const int control_tablet_dense_home = ShelfConfig::Get()->control_size();
UpdateDisplay("1000x1000");
......@@ -116,22 +120,30 @@ TEST_F(ShelfConfigTest, ShelfSizeChangesWithContext) {
widget = CreateTestWidget();
GetAppListTestHelper()->CheckVisibility(false);
const int tablet_standard_in_app = ShelfConfig::Get()->shelf_size();
const int system_shelf_tablet_standard_in_app =
ShelfConfig::Get()->system_shelf_size();
const int control_tablet_standard_in_app = ShelfConfig::Get()->control_size();
widget->Close();
GetAppListTestHelper()->CheckVisibility(true);
const int tablet_standard_home = ShelfConfig::Get()->shelf_size();
const int system_shelf_tablet_standard_home =
ShelfConfig::Get()->system_shelf_size();
const int control_tablet_standard_home = ShelfConfig::Get()->control_size();
SetTabletMode(false);
ASSERT_FALSE(IsTabletMode());
GetAppListTestHelper()->Dismiss();
const int clamshell_home = ShelfConfig::Get()->shelf_size();
const int system_shelf_clamshell_home =
ShelfConfig::Get()->system_shelf_size();
const int control_clamshell_home = ShelfConfig::Get()->control_size();
widget = CreateTestWidget();
widget->Maximize();
const int clamshell_in_app = ShelfConfig::Get()->shelf_size();
const int system_shelf_clamshell_in_app =
ShelfConfig::Get()->system_shelf_size();
const int control_clamshell_in_app = ShelfConfig::Get()->control_size();
EXPECT_LT(tablet_dense_in_app, tablet_standard_in_app);
......@@ -145,6 +157,14 @@ TEST_F(ShelfConfigTest, ShelfSizeChangesWithContext) {
EXPECT_EQ(control_clamshell_in_app, control_clamshell_home);
EXPECT_LT(control_clamshell_home, control_tablet_standard_in_app);
EXPECT_EQ(control_tablet_standard_in_app, control_tablet_standard_home);
// System shelf size should return size that matches out-of-app (home) state.
EXPECT_EQ(system_shelf_tablet_dense_in_app, tablet_dense_home);
EXPECT_EQ(system_shelf_tablet_dense_home, tablet_dense_home);
EXPECT_EQ(system_shelf_tablet_standard_in_app, tablet_standard_home);
EXPECT_EQ(system_shelf_tablet_standard_home, tablet_standard_home);
EXPECT_EQ(system_shelf_clamshell_home, clamshell_home);
EXPECT_EQ(system_shelf_clamshell_in_app, clamshell_home);
}
// Make sure that we consider ourselves inside an app when appropriate.
......
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