Commit 5897f1fc authored by Ana Salazar's avatar Ana Salazar Committed by Commit Bot

Cros: Fix bounds for scaled app icon on app list.

There was a small jump observed when we scaled the icon on long press.
We need to scale the padding of the icon as well as we are making the
icon bigger.

Bug: 1050730
Change-Id: I0aaa015a121963742e179319a8aa6ccc333251e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2083605
Commit-Queue: Ana Salazar <anasalazar@chromium.org>
Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746194}
parent 4b01708d
......@@ -674,12 +674,12 @@ void AppListItemView::Layout() {
return;
const gfx::Rect icon_bounds = GetIconBoundsForTargetViewBounds(
GetAppListConfig(), rect, icon_->GetImage().size());
GetAppListConfig(), rect, icon_->GetImage().size(), icon_scale_);
icon_->SetBoundsRect(icon_bounds);
if (icon_shadow_) {
const gfx::Rect icon_shadow_bounds = GetIconBoundsForTargetViewBounds(
GetAppListConfig(), rect, icon_shadow_->size());
GetAppListConfig(), rect, icon_shadow_->size(), icon_scale_);
icon_shadow_->SetBoundsRect(icon_shadow_bounds);
}
......@@ -961,9 +961,10 @@ void AppListItemView::SetDragUIState() {
gfx::Rect AppListItemView::GetIconBoundsForTargetViewBounds(
const AppListConfig& config,
const gfx::Rect& target_bounds,
const gfx::Size& icon_size) {
const gfx::Size& icon_size,
const float icon_scale) {
gfx::Rect rect(target_bounds);
rect.Inset(0, 0, 0, config.grid_icon_bottom_padding());
rect.Inset(0, 0, 0, config.grid_icon_bottom_padding() * icon_scale);
rect.ClampToCenteredSize(icon_size);
return rect;
}
......
......@@ -105,11 +105,13 @@ class APP_LIST_EXPORT AppListItemView : public views::Button,
void SetDragUIState();
// Returns the icon bounds for with |target_bounds| as the bounds of this view
// and given |icon_size|.
// and given |icon_size| and the |icon_scale| if the icon was scaled from the
// original display size.
static gfx::Rect GetIconBoundsForTargetViewBounds(
const AppListConfig& config,
const gfx::Rect& target_bounds,
const gfx::Size& icon_size);
const gfx::Size& icon_size,
float icon_scale);
// Returns the title bounds for with |target_bounds| as the bounds of this
// view and given |title_size|.
......
......@@ -1735,7 +1735,7 @@ gfx::Rect AppsGridView::GetTargetIconRectInFolder(
const gfx::Rect icon_ideal_bounds =
folder_item_view->GetIconBoundsForTargetViewBounds(
GetAppListConfig(), view_ideal_bounds,
folder_item_view->GetIconImage().size());
folder_item_view->GetIconImage().size(), /*icon_scale=*/1.0f);
AppListFolderItem* folder_item =
static_cast<AppListFolderItem*>(folder_item_view->item());
return folder_item->GetTargetIconRectInFolderForItem(
......
......@@ -557,7 +557,8 @@ void SearchResultTileItemView::Layout() {
if (IsSuggestedAppTileShownInAppPage()) {
icon_->SetBoundsRect(AppListItemView::GetIconBoundsForTargetViewBounds(
AppListConfig::instance(), rect, icon_->GetImage().size()));
AppListConfig::instance(), rect, icon_->GetImage().size(),
/*icon_scale=*/1.0f));
title_->SetBoundsRect(AppListItemView::GetTitleBoundsForTargetViewBounds(
AppListConfig::instance(), rect, title_->GetPreferredSize()));
} else {
......
......@@ -130,7 +130,8 @@ void TopIconAnimationView::Layout() {
return;
icon_->SetBoundsRect(AppListItemView::GetIconBoundsForTargetViewBounds(
grid_->GetAppListConfig(), rect, icon_->GetImage().size()));
grid_->GetAppListConfig(), rect, icon_->GetImage().size(),
/*icon_scale=*/1.0f));
title_->SetBoundsRect(AppListItemView::GetTitleBoundsForTargetViewBounds(
grid_->GetAppListConfig(), rect, title_->GetPreferredSize()));
}
......
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