Commit 29dd5a08 authored by Tatsuhisa Yamaguchi's avatar Tatsuhisa Yamaguchi Committed by Commit Bot

Expand and collapse unified system tray by fling.

Bug: 850437
Test: manually tested
Change-Id: I36952d2962dc46ea0d9867fd89a7841d02fc1bbe
Reviewed-on: https://chromium-review.googlesource.com/1125583Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Tatsuhisa Yamaguchi <yamaguchi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572531}
parent f72db202
......@@ -177,7 +177,22 @@ void UnifiedSystemTrayController::UpdateDrag(const gfx::Point& location) {
UpdateExpandedAmount();
}
void UnifiedSystemTrayController::StartAnimation(bool expand) {
if (expand) {
animation_->Show();
} else {
// To animate to hidden state, first set SlideAnimation::IsShowing() to
// true.
animation_->Show();
animation_->Hide();
}
}
void UnifiedSystemTrayController::EndDrag(const gfx::Point& location) {
if (animation_->is_animating()) {
// Prevent overwriting the state right after fling event
return;
}
bool expanded = GetDragExpandedAmount(location) > 0.5;
if (was_expanded_ != expanded) {
UMA_HISTOGRAM_ENUMERATION("ChromeOS.SystemTray.ToggleExpanded",
......@@ -186,14 +201,12 @@ void UnifiedSystemTrayController::EndDrag(const gfx::Point& location) {
}
// If dragging is finished, animate to closer state.
if (expanded) {
animation_->Show();
} else {
// To animate to hidden state, first set SlideAnimation::IsShowing() to
// true.
animation_->Show();
animation_->Hide();
}
StartAnimation(expanded);
}
void UnifiedSystemTrayController::Fling(int velocity) {
// Expand when flinging up. Collapse otherwise.
StartAnimation(velocity < 0);
}
void UnifiedSystemTrayController::ShowUserChooserWidget() {
......
......@@ -65,6 +65,7 @@ class ASH_EXPORT UnifiedSystemTrayController : public gfx::AnimationDelegate {
void BeginDrag(const gfx::Point& location);
void UpdateDrag(const gfx::Point& location);
void EndDrag(const gfx::Point& location);
void Fling(int velocity);
// Show user selector popup widget. Called from the view.
void ShowUserChooserWidget();
......@@ -139,6 +140,9 @@ class ASH_EXPORT UnifiedSystemTrayController : public gfx::AnimationDelegate {
// Return true if UnifiedSystemTray is expanded.
bool IsExpanded() const;
// Starts animation to expand or collapse the bubble.
void StartAnimation(bool expand);
// Model that stores UI specific variables. Unowned.
UnifiedSystemTrayModel* const model_;
......
......@@ -248,6 +248,9 @@ void UnifiedSystemTrayView::OnGestureEvent(ui::GestureEvent* event) {
controller_->EndDrag(screen_location);
event->SetHandled();
break;
case ui::ET_SCROLL_FLING_START:
controller_->Fling(event->details().velocity_y());
break;
default:
break;
}
......
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