OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ASH_SYSTEM_TRAY_DRAG_CONTROLLER_H_ |
| 6 #define ASH_SYSTEM_TRAY_DRAG_CONTROLLER_H_ |
| 7 |
| 8 #include "ash/ash_export.h" |
| 9 #include "ash/shelf/shelf.h" |
| 10 #include "ui/views/view.h" |
| 11 |
| 12 namespace ash { |
| 13 class TrayBackgroundView; |
| 14 |
| 15 class ASH_EXPORT TrayDragController { |
| 16 public: |
| 17 // The threshold of the velocity of the fling event. |
| 18 static constexpr float kFlingVelocity = 100.0f; |
| 19 |
| 20 explicit TrayDragController(Shelf* shelf); |
| 21 |
| 22 // Process a gesture event and updates the dragging state of the bubble when |
| 23 // appropriate. Returns true if the gesture has been handled and it should not |
| 24 // be processed any further, false otherwise. |
| 25 bool ProcessGestureEvent(ui::GestureEvent* event, |
| 26 TrayBackgroundView* tray_view); |
| 27 |
| 28 private: |
| 29 // Gesture related functions: |
| 30 bool StartGestureDrag(const ui::GestureEvent& gesture); |
| 31 void UpdateGestureDrag(const ui::GestureEvent& gesture); |
| 32 void CompleteGestureDrag(const ui::GestureEvent& gesture); |
| 33 |
| 34 // Update the bounds of the tray bubbles according to |
| 35 // |gesture_drag_amount_|. |
| 36 void UpdateBubbleBounds(); |
| 37 |
| 38 // Return true if the bubbles should be shown (i.e., animated upward to |
| 39 // be made fully visible) after a sequence of scroll events terminated by |
| 40 // |sequence_end|. Otherwise return false, indicating that the |
| 41 // partially-visible bubble should be animated downward and made fully |
| 42 // hidden. |
| 43 bool ShouldShowBubbleAfterScrollSequence( |
| 44 const ui::GestureEvent& sequence_end); |
| 45 |
| 46 Shelf* shelf_; |
| 47 TrayBackgroundView* tray_view_ = nullptr; |
| 48 |
| 49 // The original bounds of the tray bubble. |
| 50 gfx::Rect tray_bubble_bounds_; |
| 51 |
| 52 // Tracks the amount of the drag. Only valid if |is_in_drag_| is true. |
| 53 float gesture_drag_amount_ = 0.f; |
| 54 |
| 55 // True if the user is in the process of gesture-dragging to open the tray |
| 56 // bubble, false otherwise. |
| 57 bool is_in_drag_ = false; |
| 58 |
| 59 // True if the dragging happened on the bubble view, false if it happened on |
| 60 // the tray view. |
| 61 bool is_on_bubble_ = false; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(TrayDragController); |
| 64 }; |
| 65 |
| 66 } // namespace ash |
| 67 |
| 68 #endif // ASH_SYSTEM_TRAY_DRAG_CONTROLLER_H_ |
OLD | NEW |