Commit 32def1a4 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

NewMessageListView: Respect the swipe direction.

In Notification Center, a notification slides out of the screen when
it's removed. When a notification is removed by touch gesture, it's
natural to respect the direction the user swiped.

See the #6 of the bug for detail.

TEST=manual
BUG=882522

Change-Id: I89389a9e9c0297db855227eece2fe42369d2f96e
Reviewed-on: https://chromium-review.googlesource.com/c/1353057Reviewed-by: default avatarManu Cornet <manucornet@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612056}
parent b2e6942f
...@@ -110,6 +110,13 @@ class UnifiedMessageListView::MessageViewContainer ...@@ -110,6 +110,13 @@ class UnifiedMessageListView::MessageViewContainer
return message_view_->GetMode() == MessageView::Mode::PINNED; return message_view_->GetMode() == MessageView::Mode::PINNED;
} }
// Returns the direction that the notification is swiped out. If swiped to the
// left, it returns -1 and if sipwed to the right, it returns 1. By default
// (i.e. the notification is removed but not by touch gesture), it returns 1.
int GetSlideDirection() const {
return message_view_->GetSlideAmount() < 0 ? -1 : 1;
}
// views::View: // views::View:
void ChildPreferredSizeChanged(views::View* child) override { void ChildPreferredSizeChanged(views::View* child) override {
PreferredSizeChanged(); PreferredSizeChanged();
...@@ -397,10 +404,11 @@ void UnifiedMessageListView::UpdateBounds() { ...@@ -397,10 +404,11 @@ void UnifiedMessageListView::UpdateBounds() {
for (int i = 0; i < child_count(); ++i) { for (int i = 0; i < child_count(); ++i) {
auto* view = GetContainer(i); auto* view = GetContainer(i);
const int height = view->GetHeightForWidth(kTrayMenuWidth); const int height = view->GetHeightForWidth(kTrayMenuWidth);
const int direction = view->GetSlideDirection();
view->set_start_bounds(view->ideal_bounds()); view->set_start_bounds(view->ideal_bounds());
view->set_ideal_bounds( view->set_ideal_bounds(
view->is_removed() view->is_removed()
? gfx::Rect(kTrayMenuWidth, y, kTrayMenuWidth, height) ? gfx::Rect(kTrayMenuWidth * direction, y, kTrayMenuWidth, height)
: gfx::Rect(0, y, kTrayMenuWidth, height)); : gfx::Rect(0, y, kTrayMenuWidth, height));
y += height; y += height;
} }
......
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