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 <memory> |
| 9 |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "ui/events/gesture_detection/gesture_detection_export.h" | 12 #include "ui/events/gesture_detection/gesture_detection_export.h" |
12 #include "ui/events/gesture_detection/velocity_tracker_state.h" | 13 #include "ui/events/gesture_detection/velocity_tracker_state.h" |
13 | 14 |
14 namespace ui { | 15 namespace ui { |
15 | 16 |
16 class DoubleTapListener; | 17 class DoubleTapListener; |
17 class GestureListener; | 18 class GestureListener; |
18 class MotionEvent; | 19 class MotionEvent; |
19 | 20 |
20 // Port of GestureDetector.java from Android | 21 // Port of GestureDetector.java from Android |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 void OnLongPressTimeout(); | 105 void OnLongPressTimeout(); |
105 void OnTapTimeout(); | 106 void OnTapTimeout(); |
106 void Cancel(); | 107 void Cancel(); |
107 void CancelTaps(); | 108 void CancelTaps(); |
108 bool IsRepeatedTap(const MotionEvent& first_down, | 109 bool IsRepeatedTap(const MotionEvent& first_down, |
109 const MotionEvent& first_up, | 110 const MotionEvent& first_up, |
110 const MotionEvent& second_down) const; | 111 const MotionEvent& second_down) const; |
111 bool HandleSwipeIfNeeded(const MotionEvent& up, float vx, float vy); | 112 bool HandleSwipeIfNeeded(const MotionEvent& up, float vx, float vy); |
112 | 113 |
113 class TimeoutGestureHandler; | 114 class TimeoutGestureHandler; |
114 scoped_ptr<TimeoutGestureHandler> timeout_handler_; | 115 std::unique_ptr<TimeoutGestureHandler> timeout_handler_; |
115 GestureListener* const listener_; | 116 GestureListener* const listener_; |
116 DoubleTapListener* double_tap_listener_; | 117 DoubleTapListener* double_tap_listener_; |
117 | 118 |
118 float touch_slop_square_; | 119 float touch_slop_square_; |
119 float double_tap_touch_slop_square_; | 120 float double_tap_touch_slop_square_; |
120 float double_tap_slop_square_; | 121 float double_tap_slop_square_; |
121 float two_finger_tap_distance_square_; | 122 float two_finger_tap_distance_square_; |
122 float min_fling_velocity_; | 123 float min_fling_velocity_; |
123 float max_fling_velocity_; | 124 float max_fling_velocity_; |
124 float min_swipe_velocity_; | 125 float min_swipe_velocity_; |
125 float min_swipe_direction_component_ratio_; | 126 float min_swipe_direction_component_ratio_; |
126 base::TimeDelta double_tap_timeout_; | 127 base::TimeDelta double_tap_timeout_; |
127 base::TimeDelta two_finger_tap_timeout_; | 128 base::TimeDelta two_finger_tap_timeout_; |
128 base::TimeDelta double_tap_min_time_; | 129 base::TimeDelta double_tap_min_time_; |
129 | 130 |
130 bool still_down_; | 131 bool still_down_; |
131 bool defer_confirm_single_tap_; | 132 bool defer_confirm_single_tap_; |
132 bool always_in_tap_region_; | 133 bool always_in_tap_region_; |
133 bool always_in_bigger_tap_region_; | 134 bool always_in_bigger_tap_region_; |
134 bool two_finger_tap_allowed_for_gesture_; | 135 bool two_finger_tap_allowed_for_gesture_; |
135 | 136 |
136 scoped_ptr<MotionEvent> current_down_event_; | 137 std::unique_ptr<MotionEvent> current_down_event_; |
137 scoped_ptr<MotionEvent> previous_up_event_; | 138 std::unique_ptr<MotionEvent> previous_up_event_; |
138 scoped_ptr<MotionEvent> secondary_pointer_down_event_; | 139 std::unique_ptr<MotionEvent> secondary_pointer_down_event_; |
139 | 140 |
140 // True when the user is still touching for the second tap (down, move, and | 141 // True when the user is still touching for the second tap (down, move, and |
141 // up events). Can only be true if there is a double tap listener attached. | 142 // up events). Can only be true if there is a double tap listener attached. |
142 bool is_double_tapping_; | 143 bool is_double_tapping_; |
143 | 144 |
144 // Whether the current ACTION_DOWN event meets the criteria for being a | 145 // Whether the current ACTION_DOWN event meets the criteria for being a |
145 // repeated tap. Note that it will be considered a repeated tap only if the | 146 // repeated tap. Note that it will be considered a repeated tap only if the |
146 // corresponding ACTION_UP yields a valid tap and double-tap detection is | 147 // corresponding ACTION_UP yields a valid tap and double-tap detection is |
147 // disabled. | 148 // disabled. |
148 bool is_down_candidate_for_repeated_single_tap_; | 149 bool is_down_candidate_for_repeated_single_tap_; |
(...skipping 15 matching lines...) Expand all Loading... |
164 | 165 |
165 // Determines speed during touch scrolling. | 166 // Determines speed during touch scrolling. |
166 VelocityTrackerState velocity_tracker_; | 167 VelocityTrackerState velocity_tracker_; |
167 | 168 |
168 DISALLOW_COPY_AND_ASSIGN(GestureDetector); | 169 DISALLOW_COPY_AND_ASSIGN(GestureDetector); |
169 }; | 170 }; |
170 | 171 |
171 } // namespace ui | 172 } // namespace ui |
172 | 173 |
173 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_DETECTOR_H_ | 174 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_DETECTOR_H_ |
OLD | NEW |