Commit 655d2044 authored by Andrew Xu's avatar Andrew Xu Committed by Commit Bot

Make the minimization animation work for display centering alignment

This CL does the job similar to https://crrev.com/c/1996268 but
particularly for display centering alignment. It ensures that the
active window is animated to the final icon bounds when the scrollable
shelf follows the display centering alignment.

Bug: 1030819
Change-Id: Idd81ef831e427a2f6328720193d8eb1585c0d77d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2015404Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734284}
parent b363378e
...@@ -605,6 +605,8 @@ gfx::Rect ScrollableShelfView::GetTargetScreenBoundsOfItemIcon( ...@@ -605,6 +605,8 @@ gfx::Rect ScrollableShelfView::GetTargetScreenBoundsOfItemIcon(
gfx::Rect icon_bounds = shelf_view_->view_model()->ideal_bounds( gfx::Rect icon_bounds = shelf_view_->view_model()->ideal_bounds(
shelf_view_->model()->ItemIndexByID(id)); shelf_view_->model()->ItemIndexByID(id));
icon_bounds.Offset(edge_padding.left() - padding_insets_.left(), 0);
// Transforms |icon_bounds| from shelf view's coordinates to scrollable shelf // Transforms |icon_bounds| from shelf view's coordinates to scrollable shelf
// view's coordinates manually. // view's coordinates manually.
icon_bounds.Offset( icon_bounds.Offset(
...@@ -1262,7 +1264,7 @@ gfx::Insets ScrollableShelfView::CalculateEdgePadding( ...@@ -1262,7 +1264,7 @@ gfx::Insets ScrollableShelfView::CalculateEdgePadding(
bool use_target_bounds) const { bool use_target_bounds) const {
// Display centering alignment // Display centering alignment
if (ShouldApplyDisplayCentering(use_target_bounds)) if (ShouldApplyDisplayCentering(use_target_bounds))
return CalculatePaddingForDisplayCentering(); return CalculatePaddingForDisplayCentering(use_target_bounds);
const int icons_size = shelf_view_->GetSizeOfAppIcons( const int icons_size = shelf_view_->GetSizeOfAppIcons(
shelf_view_->number_of_visible_apps(), false) + shelf_view_->number_of_visible_apps(), false) +
...@@ -1319,7 +1321,8 @@ gfx::Rect ScrollableShelfView::GetAvailableLocalBounds( ...@@ -1319,7 +1321,8 @@ gfx::Rect ScrollableShelfView::GetAvailableLocalBounds(
: GetLocalBounds(); : GetLocalBounds();
} }
gfx::Insets ScrollableShelfView::CalculatePaddingForDisplayCentering() const { gfx::Insets ScrollableShelfView::CalculatePaddingForDisplayCentering(
bool use_target_bounds) const {
const int icons_size = shelf_view_->GetSizeOfAppIcons( const int icons_size = shelf_view_->GetSizeOfAppIcons(
shelf_view_->number_of_visible_apps(), false) + shelf_view_->number_of_visible_apps(), false) +
2 * ShelfConfig::Get()->GetAppIconEndPadding(); 2 * ShelfConfig::Get()->GetAppIconEndPadding();
...@@ -1330,7 +1333,9 @@ gfx::Insets ScrollableShelfView::CalculatePaddingForDisplayCentering() const { ...@@ -1330,7 +1333,9 @@ gfx::Insets ScrollableShelfView::CalculatePaddingForDisplayCentering() const {
const int gap = (display_size_primary - icons_size) / 2; const int gap = (display_size_primary - icons_size) / 2;
// Calculates paddings in view coordinates. // Calculates paddings in view coordinates.
const gfx::Rect screen_bounds = GetBoundsInScreen(); const gfx::Rect screen_bounds =
use_target_bounds ? GetShelf()->shelf_layout_manager()->GetHotseatBounds()
: GetBoundsInScreen();
const int before_padding = gap - GetShelf()->PrimaryAxisValue( const int before_padding = gap - GetShelf()->PrimaryAxisValue(
screen_bounds.x() - display_bounds.x(), screen_bounds.x() - display_bounds.x(),
screen_bounds.y() - display_bounds.y()); screen_bounds.y() - display_bounds.y());
......
...@@ -257,8 +257,9 @@ class ASH_EXPORT ScrollableShelfView : public views::AccessiblePaneView, ...@@ -257,8 +257,9 @@ class ASH_EXPORT ScrollableShelfView : public views::AccessiblePaneView,
// view bounds or target view bounds. // view bounds or target view bounds.
gfx::Rect GetAvailableLocalBounds(bool use_target_bounds) const; gfx::Rect GetAvailableLocalBounds(bool use_target_bounds) const;
// Calculates padding for display centering alignment. // Calculates padding for display centering alignment depending on which view
gfx::Insets CalculatePaddingForDisplayCentering() const; // bounds are used: actual view bounds or target view bounds.
gfx::Insets CalculatePaddingForDisplayCentering(bool use_target_bounds) const;
// Returns whether the received gesture event should be handled here. // Returns whether the received gesture event should be handled here.
bool ShouldHandleGestures(const ui::GestureEvent& event); bool ShouldHandleGestures(const ui::GestureEvent& event);
......
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