OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_PROVIDER_H_ | 5 #ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_PROVIDER_H_ |
6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_PROVIDER_H_ | 6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_PROVIDER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "ui/events/gesture_detection/gesture_detection_export.h" | 10 #include "ui/events/gesture_detection/gesture_detection_export.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 GestureProvider(const Config& config, GestureProviderClient* client); | 38 GestureProvider(const Config& config, GestureProviderClient* client); |
39 ~GestureProvider(); | 39 ~GestureProvider(); |
40 | 40 |
41 // Handle the incoming MotionEvent, returning false if the event could not | 41 // Handle the incoming MotionEvent, returning false if the event could not |
42 // be handled. | 42 // be handled. |
43 bool OnTouchEvent(const MotionEvent& event); | 43 bool OnTouchEvent(const MotionEvent& event); |
44 | 44 |
45 // Resets all gesture detectors; called on DidStartLoading(). | 45 // Resets all gesture detectors; called on DidStartLoading(). |
46 void ResetGestureDetectors(); | 46 void ResetGestureDetectors(); |
47 | 47 |
48 // Cancel the current touch event sequence by sending ACTION_CANCEL, and | |
49 // ignore all the subsequent events until the next ACTION_DOWN. | |
50 // One example usecase is to stop processing the touch events when showing | |
51 // a context popup menu. | |
52 void CancelActiveTouchSequence(); | |
53 | |
54 // Update whether multi-touch gestures are supported. | 48 // Update whether multi-touch gestures are supported. |
55 void SetMultiTouchSupportEnabled(bool enabled); | 49 void SetMultiTouchSupportEnabled(bool enabled); |
56 | 50 |
57 // Update whether double-tap gestures are supported. This allows | 51 // Update whether double-tap gestures are supported. This allows |
58 // double-tap gesture suppression independent of whether or not the page's | 52 // double-tap gesture suppression independent of whether or not the page's |
59 // viewport and scale would normally prevent double-tap. | 53 // viewport and scale would normally prevent double-tap. |
60 // Note: This should not be called while a double-tap gesture is in progress. | 54 // Note: This should not be called while a double-tap gesture is in progress. |
61 void SetDoubleTapSupportForPlatformEnabled(bool enabled); | 55 void SetDoubleTapSupportForPlatformEnabled(bool enabled); |
62 | 56 |
63 // Update whether double-tap gesture detection should be suppressed due to | 57 // Update whether double-tap gesture detection should be suppressed due to |
64 // the viewport or scale of the current page. Suppressing double-tap gesture | 58 // the viewport or scale of the current page. Suppressing double-tap gesture |
65 // detection allows for rapid and responsive single-tap gestures. | 59 // detection allows for rapid and responsive single-tap gestures. |
66 void SetDoubleTapSupportForPageEnabled(bool enabled); | 60 void SetDoubleTapSupportForPageEnabled(bool enabled); |
67 | 61 |
68 // Whether a scroll gesture is in-progress. | 62 // Whether a scroll gesture is in-progress. |
69 bool IsScrollInProgress() const; | 63 bool IsScrollInProgress() const; |
70 | 64 |
71 // Whether a pinch gesture is in-progress (i.e. a pinch update has been | 65 // Whether a pinch gesture is in-progress (i.e. a pinch update has been |
72 // forwarded and detection is still active). | 66 // forwarded and detection is still active). |
73 bool IsPinchInProgress() const; | 67 bool IsPinchInProgress() const; |
74 | 68 |
75 // Whether a double tap-gesture is in-progress. | 69 // Whether a double tap-gesture is in-progress. |
76 bool IsDoubleTapInProgress() const; | 70 bool IsDoubleTapInProgress() const; |
77 | 71 |
78 // Whether the tap gesture delay is explicitly disabled (independent of | 72 // Whether the tap gesture delay is explicitly disabled (independent of |
79 // whether double-tap is supported), see |Config.disable_click_delay|. | 73 // whether double-tap is supported), see |Config.disable_click_delay|. |
80 bool IsClickDelayDisabled() const; | 74 bool IsClickDelayDisabled() const; |
81 | 75 |
| 76 // May be NULL if there is no currently active touch sequence. |
| 77 const ui::MotionEvent* current_down_event() const { |
| 78 return current_down_event_.get(); |
| 79 } |
| 80 |
82 private: | 81 private: |
83 void InitGestureDetectors(const Config& config); | 82 void InitGestureDetectors(const Config& config); |
84 | 83 |
85 bool CanHandle(const MotionEvent& event) const; | 84 bool CanHandle(const MotionEvent& event) const; |
86 | 85 |
87 void Fling(base::TimeTicks time, | 86 void Fling(base::TimeTicks time, |
88 float x, | 87 float x, |
89 float y, | 88 float y, |
90 float velocity_x, | 89 float velocity_x, |
91 float velocity_y); | 90 float velocity_y); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 122 |
124 // Keeps track of the current GESTURE_LONG_PRESS event. If a context menu is | 123 // Keeps track of the current GESTURE_LONG_PRESS event. If a context menu is |
125 // opened after a GESTURE_LONG_PRESS, this is used to insert a | 124 // opened after a GESTURE_LONG_PRESS, this is used to insert a |
126 // GESTURE_TAP_CANCEL for removing any ::active styling. | 125 // GESTURE_TAP_CANCEL for removing any ::active styling. |
127 base::TimeTicks current_longpress_time_; | 126 base::TimeTicks current_longpress_time_; |
128 }; | 127 }; |
129 | 128 |
130 } // namespace ui | 129 } // namespace ui |
131 | 130 |
132 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_PROVIDER_H_ | 131 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_PROVIDER_H_ |
OLD | NEW |