Chromium Code Reviews| Index: ash/system/tray_drag_controller.h |
| diff --git a/ash/system/tray_drag_controller.h b/ash/system/tray_drag_controller.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0e7269f3627178b89eeab646d19bf3cb42d4966d |
| --- /dev/null |
| +++ b/ash/system/tray_drag_controller.h |
| @@ -0,0 +1,68 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef ASH_SYSTEM_TRAY_DRAG_CONTROLLER_H_ |
| +#define ASH_SYSTEM_TRAY_DRAG_CONTROLLER_H_ |
| + |
| +#include "ash/ash_export.h" |
| +#include "ash/shelf/shelf.h" |
| +#include "ui/views/view.h" |
| + |
| +namespace ash { |
| +class TrayBackgroundView; |
| + |
| +class ASH_EXPORT TrayDragController { |
|
tdanderson
2017/07/17 22:44:37
Please add brief class-level documentation here.
minch1
2017/07/18 03:58:59
Done.
|
| + public: |
| + // The threshold of the velocity of the fling event. |
| + static constexpr float kFlingVelocity = 100.0f; |
| + |
| + explicit TrayDragController(Shelf* shelf); |
| + |
| + // Process a gesture event and updates the dragging state of the bubble when |
| + // appropriate. Returns true if the gesture has been handled and it should not |
|
tdanderson
2017/07/17 22:44:37
It looks like you return true if and only if |even
minch1
2017/07/18 03:58:59
Done.
|
| + // be processed any further, false otherwise. |
| + bool ProcessGestureEvent(ui::GestureEvent* event, |
| + TrayBackgroundView* tray_view); |
| + |
| + private: |
| + // Gesture related functions: |
| + bool StartGestureDrag(const ui::GestureEvent& gesture); |
| + void UpdateGestureDrag(const ui::GestureEvent& gesture); |
| + void CompleteGestureDrag(const ui::GestureEvent& gesture); |
| + |
| + // Update the bounds of the tray bubbles according to |
|
tdanderson
2017/07/17 22:44:37
nit: 'bubble' instead of 'bubbles'. Similar for li
minch1
2017/07/18 03:58:59
Done.
|
| + // |gesture_drag_amount_|. |
| + void UpdateBubbleBounds(); |
| + |
| + // Return true if the bubbles should be shown (i.e., animated upward to |
| + // be made fully visible) after a sequence of scroll events terminated by |
| + // |sequence_end|. Otherwise return false, indicating that the |
| + // partially-visible bubble should be animated downward and made fully |
| + // hidden. |
| + bool ShouldShowBubbleAfterScrollSequence( |
| + const ui::GestureEvent& sequence_end); |
| + |
| + Shelf* shelf_; |
| + TrayBackgroundView* tray_view_ = nullptr; |
|
tdanderson
2017/07/17 22:44:37
nit: please add brief documentation for these two
minch1
2017/07/18 03:58:59
Done.
|
| + |
| + // The original bounds of the tray bubble. |
| + gfx::Rect tray_bubble_bounds_; |
| + |
| + // Tracks the amount of the drag. Only valid if |is_in_drag_| is true. |
| + float gesture_drag_amount_ = 0.f; |
| + |
| + // True if the user is in the process of gesture-dragging to open the tray |
|
tdanderson
2017/07/17 22:44:37
Isn't this also true if the user is gesture-draggi
minch1
2017/07/18 03:58:59
Done.
|
| + // bubble, false otherwise. |
| + bool is_in_drag_ = false; |
| + |
| + // True if the dragging happened on the bubble view, false if it happened on |
| + // the tray view. |
| + bool is_on_bubble_ = false; |
|
tdanderson
2017/07/17 22:44:37
Should you also say "Only valid if |is_in_drag_| i
minch1
2017/07/18 03:58:59
Done.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(TrayDragController); |
| +}; |
| + |
| +} // namespace ash |
| + |
| +#endif // ASH_SYSTEM_TRAY_DRAG_CONTROLLER_H_ |