| 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/macros.h" | 8 #include "base/macros.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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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 |
| 27 // Distance the current span can deviate from the initial span before | 27 // Distance the current span can deviate from the initial span before |
| 28 // scaling will start (in dips). The span is the diameter of the circle with | 28 // scaling will start (in dips). The span is the diameter of the circle with |
| 29 // a radius of average pointer deviation from the focal point. | 29 // a radius of average pointer deviation from the focal point. |
| 30 float span_slop; | 30 float span_slop; |
| 31 | 31 |
| 32 // Minimum accepted value for TouchMajor while scaling (in dips). | |
| 33 float min_scaling_touch_major; | |
| 34 | |
| 35 // Minimum span needed to initiate a scaling gesture (in dips). | 32 // Minimum span needed to initiate a scaling gesture (in dips). |
| 36 float min_scaling_span; | 33 float min_scaling_span; |
| 37 | 34 |
| 38 // Minimum pinch span change before pinch occurs (in dips). See | 35 // Minimum pinch span change before pinch occurs (in dips). See |
| 39 // crbug.com/373318. | 36 // crbug.com/373318. |
| 40 float min_pinch_update_span_delta; | 37 float min_pinch_update_span_delta; |
| 41 | 38 |
| 42 // Whether the associated |ScaleGestureListener| should receive |OnScale| | 39 // Whether the associated |ScaleGestureListener| should receive |OnScale| |
| 43 // callbacks when the user uses a stylus and presses the button. | 40 // callbacks when the user uses a stylus and presses the button. |
| 44 // Defaults to false. | 41 // Defaults to false. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 base::TimeDelta GetTimeDelta() const; | 79 base::TimeDelta GetTimeDelta() const; |
| 83 base::TimeTicks GetEventTime() const; | 80 base::TimeTicks GetEventTime() const; |
| 84 | 81 |
| 85 private: | 82 private: |
| 86 enum AnchoredScaleMode { | 83 enum AnchoredScaleMode { |
| 87 ANCHORED_SCALE_MODE_NONE, | 84 ANCHORED_SCALE_MODE_NONE, |
| 88 ANCHORED_SCALE_MODE_DOUBLE_TAP, | 85 ANCHORED_SCALE_MODE_DOUBLE_TAP, |
| 89 ANCHORED_SCALE_MODE_STYLUS | 86 ANCHORED_SCALE_MODE_STYLUS |
| 90 }; | 87 }; |
| 91 | 88 |
| 92 // The TouchMajor/TouchMinor elements of a MotionEvent can flutter/jitter on | |
| 93 // some hardware/driver combos. Smooth out to get kinder, gentler behavior. | |
| 94 void AddTouchHistory(const MotionEvent& ev); | |
| 95 void ResetTouchHistory(); | |
| 96 | |
| 97 void ResetScaleWithSpan(float span); | 89 void ResetScaleWithSpan(float span); |
| 98 | 90 |
| 99 ScaleGestureListener* const listener_; | 91 ScaleGestureListener* const listener_; |
| 100 bool stylus_scale_enabled_; | 92 bool stylus_scale_enabled_; |
| 101 | 93 |
| 102 float focus_x_; | 94 float focus_x_; |
| 103 float focus_y_; | 95 float focus_y_; |
| 104 float curr_span_; | 96 float curr_span_; |
| 105 float prev_span_; | 97 float prev_span_; |
| 106 float initial_span_; | 98 float initial_span_; |
| 107 float curr_span_x_; | 99 float curr_span_x_; |
| 108 float curr_span_y_; | 100 float curr_span_y_; |
| 109 float prev_span_x_; | 101 float prev_span_x_; |
| 110 float prev_span_y_; | 102 float prev_span_y_; |
| 111 base::TimeTicks curr_time_; | 103 base::TimeTicks curr_time_; |
| 112 base::TimeTicks prev_time_; | 104 base::TimeTicks prev_time_; |
| 113 bool in_progress_; | 105 bool in_progress_; |
| 114 float span_slop_; | 106 float span_slop_; |
| 115 float min_span_; | 107 float min_span_; |
| 116 | 108 |
| 117 // Bounds for recently seen values. | |
| 118 float touch_upper_; | |
| 119 float touch_lower_; | |
| 120 float touch_history_last_accepted_; | |
| 121 int touch_history_direction_; | |
| 122 base::TimeTicks touch_history_last_accepted_time_; | |
| 123 float touch_min_major_; | |
| 124 float touch_max_major_; | |
| 125 | |
| 126 float anchored_scale_start_x_; | 109 float anchored_scale_start_x_; |
| 127 float anchored_scale_start_y_; | 110 float anchored_scale_start_y_; |
| 128 AnchoredScaleMode anchored_scale_mode_; | 111 AnchoredScaleMode anchored_scale_mode_; |
| 129 | 112 |
| 130 bool event_before_or_above_starting_gesture_event_; | 113 bool event_before_or_above_starting_gesture_event_; |
| 131 | 114 |
| 132 DISALLOW_COPY_AND_ASSIGN(ScaleGestureDetector); | 115 DISALLOW_COPY_AND_ASSIGN(ScaleGestureDetector); |
| 133 }; | 116 }; |
| 134 | 117 |
| 135 } // namespace ui | 118 } // namespace ui |
| 136 | 119 |
| 137 #endif // UI_EVENTS_GESTURE_DETECTION_SCALE_GESTURE_DETECTOR_H_ | 120 #endif // UI_EVENTS_GESTURE_DETECTION_SCALE_GESTURE_DETECTOR_H_ |
| OLD | NEW |