Chromium Code Reviews| 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 // The TrayDragController helps to process the swiping events that happened on | |
| 16 // TrayBackgroundView or TrayBubbleView. Not all the TrayBackgroundView can be | |
| 17 // dragged currently. Only ImeMenuTray, SystemTray, PaletteTray, | |
| 18 // WebNotificationTray and their's accosiated tray bubbles can be dragged. | |
|
tdanderson
2017/07/18 16:38:05
Thanks, this is a nice description. One small typo
minch1
2017/07/18 20:01:52
Done.
| |
| 19 class ASH_EXPORT TrayDragController { | |
| 20 public: | |
| 21 // The threshold of the velocity of the fling event. | |
| 22 static constexpr float kFlingVelocity = 100.0f; | |
| 23 | |
| 24 explicit TrayDragController(Shelf* shelf); | |
| 25 | |
| 26 // Processes a gesture event and updates the dragging state of the bubble when | |
| 27 // appropriate. | |
| 28 void ProcessGestureEvent(ui::GestureEvent* event, | |
| 29 TrayBackgroundView* tray_view); | |
| 30 | |
| 31 private: | |
| 32 // Gesture related functions: | |
| 33 bool StartGestureDrag(const ui::GestureEvent& gesture); | |
| 34 void UpdateGestureDrag(const ui::GestureEvent& gesture); | |
| 35 void CompleteGestureDrag(const ui::GestureEvent& gesture); | |
| 36 | |
| 37 // Update the bounds of the tray bubble according to | |
| 38 // |gesture_drag_amount_|. | |
| 39 void UpdateBubbleBounds(); | |
| 40 | |
| 41 // Return true if the bubble should be shown (i.e., animated upward to | |
| 42 // be made fully visible) after a sequence of scroll events terminated by | |
| 43 // |sequence_end|. Otherwise return false, indicating that the | |
| 44 // partially-visible bubble should be animated downward and made fully | |
| 45 // hidden. | |
| 46 bool ShouldShowBubbleAfterScrollSequence( | |
| 47 const ui::GestureEvent& sequence_end); | |
| 48 | |
| 49 // The shelf containing the TrayBackgroundView. | |
| 50 Shelf* shelf_; | |
| 51 | |
| 52 // The specific TrayBackgroundView that dragging happened on. e.g, SystemTray. | |
| 53 TrayBackgroundView* tray_view_ = nullptr; | |
| 54 | |
| 55 // The original bounds of the tray bubble. | |
| 56 gfx::Rect tray_bubble_bounds_; | |
| 57 | |
| 58 // Tracks the amount of the drag. Only valid if |is_in_drag_| is true. | |
| 59 float gesture_drag_amount_ = 0.f; | |
| 60 | |
| 61 // True if the user is in the process of gesture-dragging on | |
| 62 // TrayBackgroundView to open the tray bubble, or on the already-opened | |
| 63 // TrayBubbleView to close it. Otherwise false. | |
| 64 bool is_in_drag_ = false; | |
| 65 | |
| 66 // True if the dragging happened on the bubble view, false if it happened on | |
| 67 // the tray view. Note, only valid if |is_in_drag_| is true. | |
| 68 bool is_on_bubble_ = false; | |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(TrayDragController); | |
| 71 }; | |
| 72 | |
| 73 } // namespace ash | |
| 74 | |
| 75 #endif // ASH_SYSTEM_TRAY_DRAG_CONTROLLER_H_ | |
| OLD | NEW |