Skip to content

Commit

Permalink
Fix app list view layout with side shelf
Browse files Browse the repository at this point in the history
Inset app list main view bounds horixontally by shelf size when
displaying app list with side shelf (to ensure app list content does not
overlap with shelf).

BUG=1020534

Change-Id: I2cbec885ad2c7c0095f77d1909f9f219020ac63f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1895782
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Reviewed-by: Alex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711957}
  • Loading branch information
Toni Barzic authored and Commit Bot committed Nov 2, 2019
1 parent e1b0d1a commit 70f160b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions ash/app_list/views/app_list_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,13 @@ void AppListView::Layout() {
// Exclude the shelf height from the contents bounds to avoid apps grid from
// overlapping with shelf.
gfx::Rect main_bounds = contents_bounds;
main_bounds.Inset(0, 0, 0, delegate_->GetShelfHeight());
if (is_side_shelf()) {
// Set both horizontal insets so the app list remains centered on the
// screen.
main_bounds.Inset(delegate_->GetShelfHeight(), 0);
} else {
main_bounds.Inset(0, 0, 0, delegate_->GetShelfHeight());
}

app_list_main_view_->SetBoundsRect(main_bounds);

Expand Down Expand Up @@ -819,6 +825,10 @@ SkColor AppListView::GetAppListBackgroundShieldColorForTest() {
}

void AppListView::UpdateAppListConfig(aura::Window* parent_window) {
// For side shelf, extra horizontal margin is needed to ensure the apps grid
// does not overlap with shelf.
const int margin_for_side_shelf =
is_side_shelf() ? delegate_->GetShelfHeight() : 0;
// Create the app list configuration override if it's needed for the current
// display bounds and the available apps grid size.
std::unique_ptr<AppListConfig> new_config =
Expand All @@ -827,7 +837,8 @@ void AppListView::UpdateAppListConfig(aura::Window* parent_window) {
->GetDisplayNearestView(parent_window)
.work_area()
.size(),
AppsContainerView::GetMinimumGridHorizontalMargin(),
AppsContainerView::GetMinimumGridHorizontalMargin() +
margin_for_side_shelf,
delegate_->GetShelfHeight(), app_list_config_.get());

if (!new_config)
Expand Down

0 comments on commit 70f160b

Please sign in to comment.