Commit 5d528907 authored by David Black's avatar David Black Committed by Chromium LUCI CQ

Fix previews on shelf alignment/config change.

Addresses two issues:
1. When shelf alignment/config changed any previews that were in the
   process of being removed were appropriately destroyed. However, we
   failed to call `OnOldItemsRemoved()` after so any new/existing items
   weren't animated/shifted into position. The result was missing and
   misplaced previews.
2. The translation calculation in `OnShelfConfigChanged()` was slightly
   off. Fixed with index based calculation.

Bug: 1166804
Change-Id: Ifda6a6a4fa527bfc6753840a7257fc92c9446a20
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2631293Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Reviewed-by: default avatarDavid Black <dmblack@google.com>
Commit-Queue: David Black <dmblack@google.com>
Cr-Commit-Position: refs/heads/master@{#843890}
parent 4f7045ea
...@@ -239,7 +239,11 @@ void HoldingSpaceTrayIcon::UpdatePreviews( ...@@ -239,7 +239,11 @@ void HoldingSpaceTrayIcon::UpdatePreviews(
void HoldingSpaceTrayIcon::OnShelfAlignmentChanged( void HoldingSpaceTrayIcon::OnShelfAlignmentChanged(
aura::Window* root_window, aura::Window* root_window,
ShelfAlignment old_alignment) { ShelfAlignment old_alignment) {
removed_previews_.clear(); if (!removed_previews_.empty()) {
removed_previews_.clear();
OnOldItemsRemoved();
}
for (const auto& preview : previews_by_id_) for (const auto& preview : previews_by_id_)
preview.second->OnShelfAlignmentChanged(old_alignment, shelf_->alignment()); preview.second->OnShelfAlignmentChanged(old_alignment, shelf_->alignment());
...@@ -253,7 +257,11 @@ void HoldingSpaceTrayIcon::OnShelfAlignmentChanged( ...@@ -253,7 +257,11 @@ void HoldingSpaceTrayIcon::OnShelfAlignmentChanged(
} }
void HoldingSpaceTrayIcon::OnShelfConfigUpdated() { void HoldingSpaceTrayIcon::OnShelfConfigUpdated() {
removed_previews_.clear(); if (!removed_previews_.empty()) {
removed_previews_.clear();
OnOldItemsRemoved();
}
for (const auto& preview : previews_by_id_) for (const auto& preview : previews_by_id_)
preview.second->OnShelfConfigChanged(); preview.second->OnShelfConfigChanged();
......
...@@ -366,9 +366,9 @@ void HoldingSpaceTrayIconPreview::OnShelfConfigChanged() { ...@@ -366,9 +366,9 @@ void HoldingSpaceTrayIconPreview::OnShelfConfigChanged() {
return; return;
// Adjust `translation` to account for the change in size. // Adjust `translation` to account for the change in size.
gfx::Vector2dF translation = transform_.To2dTranslation(); DCHECK(index_);
translation.Scale(1.f / GetPreviewSize(!use_small_previews_).width()); gfx::Vector2dF translation(*index_ * GetPreviewSize().width() / 2, 0);
translation.Scale(GetPreviewSize().width()); AdjustForShelfAlignmentAndTextDirection(&translation);
transform_.MakeIdentity(); transform_.MakeIdentity();
transform_.Translate(translation); transform_.Translate(translation);
......
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