Commit aec33eab authored by Andrew Xu's avatar Andrew Xu Committed by Commit Bot

Provide feedback for pinning app - part 1

To solve the issue 1012772, we need to implement an interface to
scroll the shelf view to show the icon for a given app id. This CL
provides the following helper functions:
(1) Calculates the offset distance of scrolling Shelf to the
previous/next page.
(2) Calculates the layout strategy for the given scroll distance.
(3) Calculates the first/last tappable app indices for the given
layout strategy and scroll offset.

No UI changes should be introduced by this CL.

Bug: 1012772
Change-Id: I3aa27d0fa035f9a9a3186bbe9963065afe465f89
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1762558Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715870}
parent aa63b9ce
This diff is collapsed.
...@@ -150,8 +150,10 @@ class ASH_EXPORT ScrollableShelfView : public views::AccessiblePaneView, ...@@ -150,8 +150,10 @@ class ASH_EXPORT ScrollableShelfView : public views::AccessiblePaneView,
// Creates the animation for scrolling shelf by |scroll_distance|. // Creates the animation for scrolling shelf by |scroll_distance|.
void StartShelfScrollAnimation(float scroll_distance); void StartShelfScrollAnimation(float scroll_distance);
// Updates the layout strategy based on the available space. // Calculates the layout strategy based on the available space and scroll
void UpdateLayoutStrategy(); // distance.
LayoutStrategy CalculateLayoutStrategy(
int scroll_distance_on_main_axis) const;
// Returns whether the view should adapt to RTL. // Returns whether the view should adapt to RTL.
bool ShouldAdaptToRTL() const; bool ShouldAdaptToRTL() const;
...@@ -246,9 +248,11 @@ class ASH_EXPORT ScrollableShelfView : public views::AccessiblePaneView, ...@@ -246,9 +248,11 @@ class ASH_EXPORT ScrollableShelfView : public views::AccessiblePaneView,
void ScrollToXOffset(float x_target_offset, bool animating); void ScrollToXOffset(float x_target_offset, bool animating);
void ScrollToYOffset(float y_target_offset, bool animating); void ScrollToYOffset(float y_target_offset, bool animating);
// Calculates the distance of scrolling to show a new page of shelf icons. // Calculates the scroll distance to show a new page of shelf icons for
// |forward| indicates whether the next page or previous page is shown. // the given layout strategy. |forward| indicates whether the next page or
float CalculatePageScrollingOffset(bool forward) const; // previous page is shown.
float CalculatePageScrollingOffset(bool forward,
LayoutStrategy layout_strategy) const;
// Updates the gradient zone. // Updates the gradient zone.
void UpdateGradientZone(); void UpdateGradientZone();
...@@ -270,6 +274,14 @@ class ASH_EXPORT ScrollableShelfView : public views::AccessiblePaneView, ...@@ -270,6 +274,14 @@ class ASH_EXPORT ScrollableShelfView : public views::AccessiblePaneView,
// Updates |first_tappable_app_index_| and |last_tappable_app_index_|. // Updates |first_tappable_app_index_| and |last_tappable_app_index_|.
void UpdateTappableIconIndices(); void UpdateTappableIconIndices();
// Calculates the indices of the first/last tappable app under the given
// layout strategy and offset along the main axis (that is the x-axis when
// shelf is horizontally aligned or the y-axis if the shelf is vertically
// aligned).
std::pair<int, int> CalculateTappableIconIndices(
LayoutStrategy layout_strategy,
int scroll_distance_on_main_axis) const;
views::View* FindFirstFocusableChild(); views::View* FindFirstFocusableChild();
views::View* FindLastFocusableChild(); views::View* FindLastFocusableChild();
...@@ -313,6 +325,9 @@ class ASH_EXPORT ScrollableShelfView : public views::AccessiblePaneView, ...@@ -313,6 +325,9 @@ class ASH_EXPORT ScrollableShelfView : public views::AccessiblePaneView,
// to the shelf. // to the shelf.
bool ShouldDelegateScrollToShelf(const ui::ScrollEvent& event) const; bool ShouldDelegateScrollToShelf(const ui::ScrollEvent& event) const;
// Calculates the scroll distance along the main axis.
float CalculateMainAxisScrollDistance() const;
LayoutStrategy layout_strategy_ = kNotShowArrowButtons; LayoutStrategy layout_strategy_ = kNotShowArrowButtons;
// Child views Owned by views hierarchy. // Child views Owned by views hierarchy.
......
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