Commit 024e6552 authored by Andrew Xu's avatar Andrew Xu Committed by Commit Bot

Part 3 of the arrow button implementation

This CL is the third part of code to implement the arrow button in
the overflow bubble view.
See more details from the below doc link:
https://docs.google.com/document/d/1dO4H_4T6ttWFc75nCNi2Uh18k-3_M8-eOHcfMTcNwd0/edit?usp=sharing

Bug: 918024
Change-Id: Id6fce153c72d38f0260556f6b431f9c91e468230
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1699641Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#678354}
parent 16cc070f
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
namespace ash { namespace ash {
namespace { namespace {
// Padding between the end of the shelf in overview mode and the arrow button // Padding between the end of the shelf in overflow mode and the arrow button
// (if any). // (if any).
constexpr int kDistanceToArrowButton = kShelfButtonSpacing; constexpr int kDistanceToArrowButton = kShelfButtonSpacing;
...@@ -41,6 +41,10 @@ constexpr int kDistanceToMainShelf = 4; ...@@ -41,6 +41,10 @@ constexpr int kDistanceToMainShelf = 4;
// Sum of the shelf button size and the gap between shelf buttons. // Sum of the shelf button size and the gap between shelf buttons.
constexpr int kUnit = kShelfButtonSize + kShelfButtonSpacing; constexpr int kUnit = kShelfButtonSize + kShelfButtonSpacing;
// Decides whether the current first visible shelf icon of the overflow shelf
// should be hidden or fully shown when gesture scroll ends.
constexpr int kGestureDragThreshold = kShelfButtonSize / 2;
} // namespace } // namespace
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
...@@ -256,10 +260,31 @@ OverflowBubbleView::~OverflowBubbleView() = default; ...@@ -256,10 +260,31 @@ OverflowBubbleView::~OverflowBubbleView() = default;
bool OverflowBubbleView::ProcessGestureEvent(const ui::GestureEvent& event) { bool OverflowBubbleView::ProcessGestureEvent(const ui::GestureEvent& event) {
// Handle scroll-related events, but don't do anything special for begin and // Handle scroll-related events, but don't do anything special for begin and
// end. // end.
if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN || if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) {
return true;
}
// Make sure that no visible shelf button is partially shown after gestures.
if (event.type() == ui::ET_GESTURE_END ||
event.type() == ui::ET_GESTURE_SCROLL_END) { event.type() == ui::ET_GESTURE_SCROLL_END) {
int current_scroll_distance = shelf_->IsHorizontalAlignment()
? scroll_offset_.x()
: scroll_offset_.y();
const int residue = current_scroll_distance % kUnit;
// if it does not need to adjust the location of the shelf view,
// return early.
if (current_scroll_distance == CalculateScrollUpperBound() || residue == 0)
return true;
int offset = residue > kGestureDragThreshold ? kUnit - residue : -residue;
if (shelf_->IsHorizontalAlignment())
ScrollByXOffset(offset, /*animate=*/true);
else
ScrollByYOffset(offset, /*animate=*/true);
return true; return true;
} }
if (event.type() != ui::ET_GESTURE_SCROLL_UPDATE) if (event.type() != ui::ET_GESTURE_SCROLL_UPDATE)
return false; return false;
......
This diff is collapsed.
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