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_SCALE_GESTURE_DETECTOR_H_ | 5 #ifndef UI_EVENTS_GESTURE_DETECTION_SCALE_GESTURE_DETECTOR_H_ |
6 #define UI_EVENTS_GESTURE_DETECTION_SCALE_GESTURE_DETECTOR_H_ | 6 #define UI_EVENTS_GESTURE_DETECTION_SCALE_GESTURE_DETECTOR_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.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/gesture_detector.h" | 11 #include "ui/events/gesture_detection/gesture_detector.h" |
12 | 12 |
13 namespace ui { | 13 namespace ui { |
14 | 14 |
15 class MotionEvent; | 15 class MotionEvent; |
16 | 16 |
17 // Port of ScaleGestureDetector.java from Android | 17 // Port of ScaleGestureDetector.java from Android |
18 // * platform/frameworks/base/core/java/android/view/ScaleGestureDetector.java | 18 // * platform/frameworks/base/core/java/android/view/ScaleGestureDetector.java |
19 // * Change-Id: I3e7926a4f6f9ab4951f380bd004499c78b3bda69 | 19 // * Change-Id: I3e7926a4f6f9ab4951f380bd004499c78b3bda69 |
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 ScaleGestureDetector : public GestureDetector::SimpleGestureListener { | 21 class ScaleGestureDetector : public GestureDetector::SimpleGestureListener { |
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 GestureDetector::Config gesture_detector_config; | 26 GestureDetector::Config gesture_detector_config; |
| 27 |
| 28 // Minimum accepted value for TouchMajor while scaling (in dips). |
| 29 float min_scaling_touch_major; |
| 30 |
| 31 // Minimum span needed to initiate a scaling gesture (in dips). |
| 32 float min_scaling_span; |
| 33 |
| 34 // Whether double-tap drag scaling is enabled. |
27 bool quick_scale_enabled; | 35 bool quick_scale_enabled; |
28 int min_scaling_touch_major; | |
29 int min_scaling_span; | |
30 }; | 36 }; |
31 | 37 |
32 class ScaleGestureListener { | 38 class ScaleGestureListener { |
33 public: | 39 public: |
34 virtual ~ScaleGestureListener() {} | 40 virtual ~ScaleGestureListener() {} |
35 virtual bool OnScale(const ScaleGestureDetector& detector, | 41 virtual bool OnScale(const ScaleGestureDetector& detector, |
36 const MotionEvent& e) = 0; | 42 const MotionEvent& e) = 0; |
37 virtual bool OnScaleBegin(const ScaleGestureDetector& detector, | 43 virtual bool OnScaleBegin(const ScaleGestureDetector& detector, |
38 const MotionEvent& e) = 0; | 44 const MotionEvent& e) = 0; |
39 virtual void OnScaleEnd(const ScaleGestureDetector& detector, | 45 virtual void OnScaleEnd(const ScaleGestureDetector& detector, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 float curr_span_; | 119 float curr_span_; |
114 float prev_span_; | 120 float prev_span_; |
115 float initial_span_; | 121 float initial_span_; |
116 float curr_span_x_; | 122 float curr_span_x_; |
117 float curr_span_y_; | 123 float curr_span_y_; |
118 float prev_span_x_; | 124 float prev_span_x_; |
119 float prev_span_y_; | 125 float prev_span_y_; |
120 base::TimeTicks curr_time_; | 126 base::TimeTicks curr_time_; |
121 base::TimeTicks prev_time_; | 127 base::TimeTicks prev_time_; |
122 bool in_progress_; | 128 bool in_progress_; |
123 int span_slop_; | 129 float span_slop_; |
124 int min_span_; | 130 float min_span_; |
125 | 131 |
126 // Bounds for recently seen values. | 132 // Bounds for recently seen values. |
127 float touch_upper_; | 133 float touch_upper_; |
128 float touch_lower_; | 134 float touch_lower_; |
129 float touch_history_last_accepted_; | 135 float touch_history_last_accepted_; |
130 int touch_history_direction_; | 136 int touch_history_direction_; |
131 base::TimeTicks touch_history_last_accepted_time_; | 137 base::TimeTicks touch_history_last_accepted_time_; |
132 int touch_min_major_; | 138 float touch_min_major_; |
133 float double_tap_focus_x_; | 139 float double_tap_focus_x_; |
134 float double_tap_focus_y_; | 140 float double_tap_focus_y_; |
135 DoubleTapMode double_tap_mode_; | 141 DoubleTapMode double_tap_mode_; |
136 | 142 |
137 bool event_before_or_above_starting_gesture_event_; | 143 bool event_before_or_above_starting_gesture_event_; |
138 | 144 |
139 scoped_ptr<GestureDetector> gesture_detector_; | 145 scoped_ptr<GestureDetector> gesture_detector_; |
140 | 146 |
141 DISALLOW_COPY_AND_ASSIGN(ScaleGestureDetector); | 147 DISALLOW_COPY_AND_ASSIGN(ScaleGestureDetector); |
142 }; | 148 }; |
143 | 149 |
144 } // namespace ui | 150 } // namespace ui |
145 | 151 |
146 #endif // UI_EVENTS_GESTURE_DETECTION_SCALE_GESTURE_DETECTOR_H_ | 152 #endif // UI_EVENTS_GESTURE_DETECTION_SCALE_GESTURE_DETECTOR_H_ |
OLD | NEW |