Commit 982a5694 authored by Andrew Xu's avatar Andrew Xu Committed by Commit Bot

Make the icon's final bounds be minimization's target bounds

The current minimization animation, which is triggered by going to
home screen from in-app shelf, uses the bounds of the icon
which corresponds to the active window to be minimized as the
animation's target bounds. However, hotseat's bounds change due to
entering the home screen. As a result, the target bounds are not the
final bounds.

This CL fixes the issue by providing an interface to calculate
the icon's bounds according to the hotseat's target bounds instead
of the actual bounds.

There are four ways to show the home screen from in-app shelf:
(1) Press the home button.
(2) Gesture fling up on the hotseat.
(3) Back gesture.
(4) Tap on the shelf icon.

In case (1), hotseat's target bounds have been set before starting
the window scaling animation. In other cases, target bounds are not
set yet. Thanks to https://crrev.com/c/1999443, case 3 and case 4 are
solved. The last one, case 2, will be fixed in the following CL.

Bug: 1030819
Change-Id: I63cafabe6527aba49e9f98e338f9f248284e1d0d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1996268
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732416}
parent 8630c10d
......@@ -109,12 +109,9 @@ gfx::Transform WindowScaleAnimation::GetWindowTransformToShelf() {
gfx::Transform transform;
Shelf* shelf = Shelf::ForWindow(window_);
gfx::Rect shelf_item_bounds =
const gfx::Rect shelf_item_bounds =
shelf->GetScreenBoundsOfItemIconForWindow(window_);
// |shelf_item_bounds| is the item bounds in a extended hotseat (i.e., the
// hotseat state during dragging). Adjust it to the bounds in a shown
// hotseat (i.e., the hotseat state after dragging).
shelf_item_bounds.Offset(0, ShelfConfig::Get()->shelf_size());
if (!shelf_item_bounds.IsEmpty()) {
transform.Translate(shelf_item_bounds.x() - origin_without_transform.x(),
......
This diff is collapsed.
......@@ -82,6 +82,12 @@ class ASH_EXPORT ScrollableShelfView : public views::AccessiblePaneView,
// Returns whether the view should adapt to RTL.
bool ShouldAdaptToRTL() const;
// Returns the icon's target bounds in screen. The returned bounds are
// calculated with the hotseat's target bounds instead of the actual bounds.
// It helps to get the icon's final location before the bounds animation on
// hotseat ends.
gfx::Rect GetTargetScreenBoundsOfItemIcon(const ShelfID& id) const;
views::View* GetShelfContainerViewForTest();
bool ShouldAdjustForTest() const;
......@@ -147,22 +153,28 @@ class ASH_EXPORT ScrollableShelfView : public views::AccessiblePaneView,
kNotInScroll
};
// Returns the maximum scroll distance.
int CalculateScrollUpperBound() const;
// Returns the maximum scroll distance based on the given space for icons.
int CalculateScrollUpperBound(int available_space_for_icons) const;
// Returns the clamped scroll offset.
float CalculateClampedScrollOffset(float scroll) const;
float CalculateClampedScrollOffset(float scroll,
int available_space_for_icons) const;
// Creates the animation for scrolling shelf by |scroll_distance|.
void StartShelfScrollAnimation(float scroll_distance);
// Calculates the layout strategy based on the available space and scroll
// distance.
LayoutStrategy CalculateLayoutStrategy(
int scroll_distance_on_main_axis) const;
// Calculates the layout strategy based on the three factors:
// (1) scroll offset on the main axis; (2) available space for shelf icons;
// (3) Bounds of the scrollable shelf view: actual view bounds or target
// bounds.
LayoutStrategy CalculateLayoutStrategy(int scroll_distance_on_main_axis,
int space_for_icons,
bool use_target_bounds) const;
// Returns whether the app icon layout should be centering alignment.
bool ShouldApplyDisplayCentering() const;
// |use_target_bounds| indicates which view bounds are used for
// calculation: actual view bounds or target view bounds.
bool ShouldApplyDisplayCentering(bool use_target_bounds) const;
Shelf* GetShelf();
const Shelf* GetShelf() const;
......@@ -235,7 +247,15 @@ class ASH_EXPORT ScrollableShelfView : public views::AccessiblePaneView,
// (1) display centering alignment
// (2) scrollable shelf centering alignment
// (3) overflow mode
gfx::Insets CalculateEdgePadding() const;
// |use_target_bounds| indicates which view bounds are used for
// calculation: actual view bounds or target view bounds.
gfx::Insets CalculateEdgePadding(bool use_target_bounds) const;
int GetStatusWidgetSizeOnPrimaryAxis(bool use_target_bounds) const;
// Returns the local bounds depending on which view bounds are used: actual
// view bounds or target view bounds.
gfx::Rect GetAvailableLocalBounds(bool use_target_bounds) const;
// Calculates padding for display centering alignment.
gfx::Insets CalculatePaddingForDisplayCentering() const;
......@@ -312,7 +332,9 @@ class ASH_EXPORT ScrollableShelfView : public views::AccessiblePaneView,
int GetSpaceForIcons() const;
// Returns whether there is available space to accommodate all shelf icons.
bool CanFitAllAppsWithoutScrolling() const;
// |use_target_bounds| indicates which view bounds are used for
// calculation: actual view bounds or target view bounds.
bool CanFitAllAppsWithoutScrolling(bool use_target_bounds) const;
// Returns whether scrolling should be handled. |is_gesture_fling| is true
// when the scrolling is triggered by gesture fling event; when it is false,
......@@ -326,8 +348,11 @@ class ASH_EXPORT ScrollableShelfView : public views::AccessiblePaneView,
// Returns the offset by which the scroll distance along the main axis should
// be adjusted to ensure the correct UI under the specific layout strategy.
// Three parameters are needed: (1) scroll offset on the main axis (2) layout
// strategy (3) available space for shelf icons.
int CalculateAdjustmentOffset(int main_axis_scroll_distance,
LayoutStrategy layout_strategy) const;
LayoutStrategy layout_strategy,
int available_space_for_icons) const;
int CalculateScrollDistanceAfterAdjustment(
int main_axis_scroll_distance,
......@@ -374,6 +399,10 @@ class ASH_EXPORT ScrollableShelfView : public views::AccessiblePaneView,
// offset and layout strategy.
void UpdateAvailableSpaceAndScroll();
// Returns the scroll offset assuming view bounds being the target bounds.
int CalculateScrollOffsetForTargetAvailableSpace(
const gfx::Rect& target_space) const;
LayoutStrategy layout_strategy_ = kNotShowArrowButtons;
// Child views Owned by views hierarchy.
......
......@@ -23,6 +23,7 @@
#include "ash/shelf/login_shelf_view.h"
#include "ash/shelf/overflow_bubble.h"
#include "ash/shelf/overflow_bubble_view.h"
#include "ash/shelf/scrollable_shelf_view.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_background_animator_observer.h"
#include "ash/shelf/shelf_layout_manager.h"
......@@ -630,6 +631,12 @@ gfx::Rect ShelfWidget::GetScreenBoundsOfItemIconForWindow(
if (id.IsNull())
return gfx::Rect();
if (chromeos::switches::ShouldShowShelfHotseat()) {
return hotseat_widget()
->scrollable_shelf_view()
->GetTargetScreenBoundsOfItemIcon(id);
}
gfx::Rect bounds(
hotseat_widget()->GetShelfView()->GetIdealBoundsOfItemIcon(id));
gfx::Point screen_origin;
......
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