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_DETECTOR_H_ | 5 #ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_DETECTOR_H_ |
6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_DETECTOR_H_ | 6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_DETECTOR_H_ |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.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" |
11 #include "ui/events/gesture_detection/velocity_tracker_state.h" | 11 #include "ui/events/gesture_detection/velocity_tracker_state.h" |
12 | 12 |
13 namespace ui { | 13 namespace ui { |
14 | 14 |
15 class MotionEvent; | 15 class MotionEvent; |
16 | 16 |
17 // Port of GestureDetector.java from Android | 17 // Port of GestureDetector.java from Android |
18 // * platform/frameworks/base/core/java/android/view/GestureDetector.java | 18 // * platform/frameworks/base/core/java/android/view/GestureDetector.java |
19 // * Change-Id: Ib470735ec929b0b358fca4597e92dc81084e675f | 19 // * Change-Id: Ib470735ec929b0b358fca4597e92dc81084e675f |
20 // * Please update the Change-Id as upstream Android changes are pulled. | 20 // * Please update the Change-Id as upstream Android changes are pulled. |
21 class GestureDetector { | 21 class GestureDetector { |
22 public: | 22 public: |
23 struct GESTURE_DETECTION_EXPORT Config { | 23 struct GESTURE_DETECTION_EXPORT Config { |
24 Config(); | 24 Config(); |
25 ~Config(); | 25 ~Config(); |
26 | |
26 base::TimeDelta longpress_timeout; | 27 base::TimeDelta longpress_timeout; |
27 base::TimeDelta showpress_timeout; | 28 base::TimeDelta showpress_timeout; |
28 base::TimeDelta double_tap_timeout; | 29 base::TimeDelta double_tap_timeout; |
29 int scaled_touch_slop; | 30 |
30 int scaled_double_tap_slop; | 31 // Distance a touch can wander before a scroll will occur (in dips). |
31 int scaled_minimum_fling_velocity; | 32 float touch_slop; |
32 int scaled_maximum_fling_velocity; | 33 |
34 // Distance the first touch can wander before it is no longer considerd a | |
35 // double tap (in dips). | |
tdresser
2014/04/09 14:00:01
Maximum distance between the first and second touc
jdduke (slow)
2014/04/10 22:04:53
Ah, I keep falling into the Texan spelling... ;)
tdresser
2014/04/11 12:18:14
+1
| |
36 float double_tap_slop; | |
37 | |
38 // Minimum velocity to initiate a fling (in dips/second). | |
39 float minimum_fling_velocity; | |
40 | |
41 // Maximum velocity of an initiated fling (in dips/second). | |
42 float maximum_fling_velocity; | |
33 }; | 43 }; |
34 | 44 |
35 class GestureListener { | 45 class GestureListener { |
36 public: | 46 public: |
37 virtual ~GestureListener() {} | 47 virtual ~GestureListener() {} |
38 virtual bool OnDown(const MotionEvent& e) = 0; | 48 virtual bool OnDown(const MotionEvent& e) = 0; |
39 virtual void OnShowPress(const MotionEvent& e) = 0; | 49 virtual void OnShowPress(const MotionEvent& e) = 0; |
40 virtual bool OnSingleTapUp(const MotionEvent& e) = 0; | 50 virtual bool OnSingleTapUp(const MotionEvent& e) = 0; |
41 virtual bool OnLongPress(const MotionEvent& e) = 0; | 51 virtual bool OnLongPress(const MotionEvent& e) = 0; |
42 virtual bool OnScroll(const MotionEvent& e1, const MotionEvent& e2, | 52 virtual bool OnScroll(const MotionEvent& e1, const MotionEvent& e2, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 void CancelTaps(); | 117 void CancelTaps(); |
108 bool IsConsideredDoubleTap(const MotionEvent& first_down, | 118 bool IsConsideredDoubleTap(const MotionEvent& first_down, |
109 const MotionEvent& first_up, | 119 const MotionEvent& first_up, |
110 const MotionEvent& second_down) const; | 120 const MotionEvent& second_down) const; |
111 | 121 |
112 class TimeoutGestureHandler; | 122 class TimeoutGestureHandler; |
113 scoped_ptr<TimeoutGestureHandler> timeout_handler_; | 123 scoped_ptr<TimeoutGestureHandler> timeout_handler_; |
114 GestureListener* const listener_; | 124 GestureListener* const listener_; |
115 DoubleTapListener* double_tap_listener_; | 125 DoubleTapListener* double_tap_listener_; |
116 | 126 |
117 int touch_slop_square_; | 127 float touch_slop_square_; |
118 int double_tap_touch_slop_square_; | 128 float double_tap_touch_slop_square_; |
119 int double_tap_slop_square_; | 129 float double_tap_slop_square_; |
120 int min_fling_velocity_; | 130 float min_fling_velocity_; |
121 int max_fling_velocity_; | 131 float max_fling_velocity_; |
122 base::TimeDelta double_tap_timeout_; | 132 base::TimeDelta double_tap_timeout_; |
123 | 133 |
124 bool still_down_; | 134 bool still_down_; |
125 bool defer_confirm_single_tap_; | 135 bool defer_confirm_single_tap_; |
126 bool in_longpress_; | 136 bool in_longpress_; |
127 bool always_in_tap_region_; | 137 bool always_in_tap_region_; |
128 bool always_in_bigger_tap_region_; | 138 bool always_in_bigger_tap_region_; |
129 | 139 |
130 scoped_ptr<MotionEvent> current_down_event_; | 140 scoped_ptr<MotionEvent> current_down_event_; |
131 scoped_ptr<MotionEvent> previous_up_event_; | 141 scoped_ptr<MotionEvent> previous_up_event_; |
(...skipping 11 matching lines...) Expand all Loading... | |
143 | 153 |
144 // Determines speed during touch scrolling. | 154 // Determines speed during touch scrolling. |
145 VelocityTrackerState velocity_tracker_; | 155 VelocityTrackerState velocity_tracker_; |
146 | 156 |
147 DISALLOW_COPY_AND_ASSIGN(GestureDetector); | 157 DISALLOW_COPY_AND_ASSIGN(GestureDetector); |
148 }; | 158 }; |
149 | 159 |
150 } // namespace ui | 160 } // namespace ui |
151 | 161 |
152 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_DETECTOR_H_ | 162 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_DETECTOR_H_ |
OLD | NEW |