Commit 9069c243 authored by Manu Cornet's avatar Manu Cornet Committed by Commit Bot

CrOS Shelf: For overflow, only forward to bubble events it can handle

Bug: 882991
Change-Id: I952c5e9ed4d2153b50fb7cfb2bc15b4f7557b9fb
Reviewed-on: https://chromium-review.googlesource.com/c/1373809Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Manu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615982}
parent cdb75d30
......@@ -86,15 +86,22 @@ void OverflowBubbleView::InitOverflowBubble(views::View* anchor,
AddChildView(shelf_view_);
}
void 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
// end.
if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN ||
event.type() == ui::ET_GESTURE_SCROLL_END) {
return true;
}
if (event.type() != ui::ET_GESTURE_SCROLL_UPDATE)
return;
return false;
if (shelf_->IsHorizontalAlignment())
ScrollByXOffset(static_cast<int>(-event.details().scroll_x()));
else
ScrollByYOffset(static_cast<int>(-event.details().scroll_y()));
Layout();
return true;
}
void OverflowBubbleView::ScrollByXOffset(int x_offset) {
......
......@@ -27,8 +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);
// Handles events for scrolling the bubble. Returns whether the event
// has been consumed.
bool ProcessGestureEvent(const ui::GestureEvent& event);
// views::BubbleDialogDelegateView:
int GetDialogButtons() const override;
......
......@@ -1799,11 +1799,13 @@ void ShelfView::OnGestureEvent(ui::GestureEvent* event) {
if (shelf_->ProcessGestureEvent(*event))
event->StopPropagation();
else if (is_overflow_mode()) {
// If the event hasn't been processed and the overflow shelf is showing,
// let the bubble process the event.
main_shelf_->overflow_bubble()->bubble_view()->ProcessGestureEvent(*event);
event->StopPropagation();
return;
// If the event hasn't been processed yet and the overflow shelf is showing,
// give the bubble a chance to process the event.
if (main_shelf_->overflow_bubble()->bubble_view()->ProcessGestureEvent(
*event)) {
event->StopPropagation();
return;
}
}
}
......
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