Commit 7a46ac43 authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

shelf: Allow gestures to scroll the overflow shelf.

This gives users a way to reach apps when the overflow is beyond filled
on tablet mode. Also fix a bug with the shelf layout manager handling
events on the overflow.

Test: manual
Bug: 808237
Change-Id: Ia3d4a14c8c1a15f7c991a201bdad94d6657f4e6d
Reviewed-on: https://chromium-review.googlesource.com/1208826Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589221}
parent 616d2ac8
......@@ -84,6 +84,17 @@ void OverflowBubbleView::InitOverflowBubble(views::View* anchor,
AddChildView(shelf_view_);
}
void OverflowBubbleView::ProcessGestureEvent(const ui::GestureEvent& event) {
if (event.type() != ui::ET_GESTURE_SCROLL_UPDATE)
return;
if (shelf_->IsHorizontalAlignment())
ScrollByXOffset(static_cast<int>(-event.details().scroll_x()));
else
ScrollByYOffset(static_cast<int>(-event.details().scroll_y()));
Layout();
}
void OverflowBubbleView::ScrollByXOffset(int x_offset) {
const gfx::Rect visible_bounds(GetContentsBounds());
const gfx::Size contents_size(shelf_view_->GetPreferredSize());
......@@ -158,8 +169,10 @@ bool OverflowBubbleView::OnMouseWheel(const ui::MouseWheelEvent& event) {
}
void OverflowBubbleView::OnScrollEvent(ui::ScrollEvent* event) {
ScrollByXOffset(-event->x_offset());
ScrollByYOffset(-event->y_offset());
if (shelf_->IsHorizontalAlignment())
ScrollByXOffset(static_cast<int>(-event->x_offset()));
else
ScrollByYOffset(static_cast<int>(-event->y_offset()));
Layout();
event->SetHandled();
}
......
......@@ -27,6 +27,9 @@ class ASH_EXPORT OverflowBubbleView : public views::BubbleDialogDelegateView,
// ShelfView containing the overflow items.
void InitOverflowBubble(views::View* anchor, ShelfView* shelf_view);
// Scrolls the bubble contents if it is a scroll update event.
void ProcessGestureEvent(const ui::GestureEvent& event);
// views::BubbleDialogDelegateView:
int GetDialogButtons() const override;
gfx::Rect GetBubbleBounds() override;
......@@ -40,13 +43,13 @@ class ASH_EXPORT OverflowBubbleView : public views::BubbleDialogDelegateView,
void ScrollByXOffset(int x_offset);
void ScrollByYOffset(int y_offset);
// views::View overrides:
// views::View:
gfx::Size CalculatePreferredSize() const override;
void Layout() override;
void ChildPreferredSizeChanged(views::View* child) override;
bool OnMouseWheel(const ui::MouseWheelEvent& event) override;
// ui::EventHandler overrides:
// ui::EventHandler:
void OnScrollEvent(ui::ScrollEvent* event) override;
// ShelfBackgroundAnimatorObserver:
......
......@@ -1790,6 +1790,15 @@ void ShelfView::ViewHierarchyChanged(
}
void ShelfView::OnGestureEvent(ui::GestureEvent* event) {
// Do not forward events to |shelf_| (which forwards events to the shelf
// layout manager) as we do not want gestures on the overflow to open the app
// list for example.
if (is_overflow_mode()) {
main_shelf_->overflow_bubble()->bubble_view()->ProcessGestureEvent(*event);
event->StopPropagation();
return;
}
// Convert the event location from current view to screen, since swiping up on
// the shelf can open the fullscreen app list. Updating the bounds of the app
// list during dragging is based on screen coordinate space.
......
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