Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_CONFIGURATION_H_ | |
| 6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_CONFIGURATION_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/command_line.h" | |
| 10 #include "base/memory/singleton.h" | |
| 11 #include "ui/events/event_switches.h" | |
| 12 #include "ui/events/gesture_detection/gesture_detection_export.h" | |
| 13 #include "ui/events/gesture_detection/gesture_detector.h" | |
| 14 #include "ui/events/gesture_detection/gesture_provider.h" | |
| 15 #include "ui/events/gesture_detection/scale_gesture_detector.h" | |
| 16 #include "ui/gfx/screen.h" | |
| 17 | |
| 18 namespace ui { | |
| 19 | |
| 20 class GESTURE_DETECTION_EXPORT GestureConfiguration { | |
| 21 public: | |
| 22 virtual ~GestureConfiguration(); | |
| 23 | |
| 24 static GestureConfiguration* GetInstance(); | |
| 25 GestureProvider::Config DefaultGestureProviderConfig(); | |
|
jdduke (slow)
2014/10/23 15:01:27
I'd prefer if this method could remain in gesture_
lanwei
2014/10/23 19:54:19
Done.
| |
| 26 | |
| 27 // Ordered alphabetically ignoring underscores. | |
| 28 float default_radius() { return default_radius_; } | |
| 29 void set_default_radius(float radius) { | |
| 30 default_radius_ = radius; | |
| 31 min_scaling_touch_major_ = default_radius_ * 2; | |
| 32 min_gesture_bounds_length_ = default_radius_; | |
| 33 } | |
| 34 int double_tap_timeout_in_ms() { return double_tap_timeout_in_ms_; } | |
| 35 int fling_max_cancel_to_down_time_in_ms() { | |
| 36 return fling_max_cancel_to_down_time_in_ms_; | |
| 37 } | |
| 38 void set_fling_max_cancel_to_down_time_in_ms(int val) { | |
| 39 fling_max_cancel_to_down_time_in_ms_ = val; | |
| 40 } | |
| 41 int fling_max_tap_gap_time_in_ms() { return fling_max_tap_gap_time_in_ms_; } | |
| 42 void set_fling_max_tap_gap_time_in_ms(int val) { | |
| 43 fling_max_tap_gap_time_in_ms_ = val; | |
| 44 } | |
| 45 bool gesture_begin_end_types_enabled() { | |
| 46 return gesture_begin_end_types_enabled_; | |
| 47 } | |
| 48 int long_press_time_in_ms() { return long_press_time_in_ms_; } | |
| 49 void set_long_press_time_in_ms(int val) { long_press_time_in_ms_ = val; } | |
| 50 float max_distance_between_taps_for_double_tap() { | |
| 51 return max_distance_between_taps_for_double_tap_; | |
| 52 } | |
| 53 void set_max_distance_between_taps_for_double_tap(float val) { | |
| 54 max_distance_between_taps_for_double_tap_ = val; | |
| 55 } | |
| 56 float max_distance_for_two_finger_tap_in_pixels() { | |
| 57 return max_distance_for_two_finger_tap_in_pixels_; | |
| 58 } | |
| 59 void set_max_distance_for_two_finger_tap_in_pixels(float val) { | |
| 60 max_distance_for_two_finger_tap_in_pixels_ = val; | |
| 61 } | |
| 62 float max_fling_velocity() { return max_fling_velocity_; } | |
| 63 void set_max_fling_velocity(float val) { max_fling_velocity_ = val; } | |
| 64 float max_gesture_bounds_length() { return max_gesture_bounds_length_; } | |
| 65 float max_separation_for_gesture_touches_in_pixels() { | |
| 66 return max_separation_for_gesture_touches_in_pixels_; | |
| 67 } | |
| 68 void set_max_separation_for_gesture_touches_in_pixels(float val) { | |
| 69 max_separation_for_gesture_touches_in_pixels_ = val; | |
| 70 } | |
| 71 float max_swipe_deviation_angle() { return max_swipe_deviation_angle_; } | |
| 72 int max_time_between_double_click_in_ms() { | |
| 73 return max_time_between_double_click_in_ms_; | |
| 74 } | |
| 75 void set_max_time_between_double_click_in_ms(int val) { | |
| 76 max_time_between_double_click_in_ms_ = val; | |
| 77 } | |
| 78 int max_touch_down_duration_for_click_in_ms() { | |
| 79 return max_touch_down_duration_for_click_in_ms_; | |
| 80 } | |
| 81 void set_max_touch_down_duration_for_click_in_ms(int val) { | |
| 82 max_touch_down_duration_for_click_in_ms_ = val; | |
| 83 } | |
| 84 float max_touch_move_in_pixels_for_click() { | |
| 85 return max_touch_move_in_pixels_for_click_; | |
| 86 } | |
| 87 void set_max_touch_move_in_pixels_for_click(float val) { | |
| 88 max_touch_move_in_pixels_for_click_ = val; | |
| 89 span_slop_ = max_touch_move_in_pixels_for_click_ * 2; | |
| 90 } | |
| 91 float min_distance_for_pinch_scroll_in_pixels() { | |
| 92 return min_distance_for_pinch_scroll_in_pixels_; | |
| 93 } | |
| 94 void set_min_distance_for_pinch_scroll_in_pixels(float val) { | |
| 95 min_distance_for_pinch_scroll_in_pixels_ = val; | |
| 96 } | |
| 97 float min_fling_velocity() { return min_fling_velocity_; } | |
| 98 float min_gesture_bounds_length() { return min_gesture_bounds_length_; } | |
| 99 float min_pinch_update_distance_in_pixels() { | |
| 100 return min_pinch_update_distance_in_pixels_; | |
| 101 } | |
| 102 void set_min_pinch_update_distance_in_pixels(float val) { | |
| 103 min_pinch_update_distance_in_pixels_ = val; | |
| 104 min_pinch_update_span_delta_ = | |
|
jdduke (slow)
2014/10/23 15:01:27
tdresser@: Is this really logic that we want here?
tdresser
2014/10/23 15:14:07
Doesn't look like we ever use min_pinch_update_dis
jdduke (slow)
2014/10/23 15:30:10
Sounds great.
lanwei
2014/10/23 19:54:19
Done.
| |
| 105 CommandLine::ForCurrentProcess()->HasSwitch( | |
| 106 switches::kCompensateForUnstablePinchZoom) | |
| 107 ? min_pinch_update_distance_in_pixels() | |
| 108 : 0; | |
| 109 } | |
| 110 float min_pinch_update_span_delta() { return min_pinch_update_span_delta_; } | |
| 111 void set_min_pinch_update_span_delta(float val) { | |
| 112 min_pinch_update_span_delta_ = val; | |
| 113 } | |
| 114 float min_scaling_span_in_pixels() { return min_scaling_span_in_pixels_; } | |
| 115 float min_scaling_touch_major() { return min_scaling_touch_major_; } | |
| 116 float min_swipe_velocity() { return min_swipe_velocity_; } | |
| 117 void set_min_swipe_velocity(float val) { min_swipe_velocity_ = val; } | |
| 118 int scroll_debounce_interval_in_ms() { | |
| 119 return scroll_debounce_interval_in_ms_; | |
| 120 } | |
| 121 int set_scroll_debounce_interval_in_ms(int val) { | |
| 122 return scroll_debounce_interval_in_ms_ = val; | |
| 123 } | |
| 124 int semi_long_press_time_in_ms() { return semi_long_press_time_in_ms_; } | |
| 125 void set_semi_long_press_time_in_ms(int val) { | |
| 126 semi_long_press_time_in_ms_ = val; | |
| 127 double_tap_timeout_in_ms_ = val; | |
| 128 } | |
| 129 int show_press_delay_in_ms() { return show_press_delay_in_ms_; } | |
| 130 int set_show_press_delay_in_ms(int val) { | |
| 131 return show_press_delay_in_ms_ = val; | |
| 132 } | |
| 133 float span_slop() { return span_slop_; } | |
| 134 bool swipe_enabled() { return swipe_enabled_; } | |
| 135 | |
| 136 // TODO(davemoore): Move into chrome/browser/ui. | |
| 137 int tab_scrub_activation_delay_in_ms() { | |
| 138 return tab_scrub_activation_delay_in_ms_; | |
| 139 } | |
| 140 void set_tab_scrub_activation_delay_in_ms(int val) { | |
| 141 tab_scrub_activation_delay_in_ms_ = val; | |
| 142 } | |
| 143 bool two_finger_tap_enabled() { return two_finger_tap_enabled_; } | |
| 144 | |
| 145 protected: | |
| 146 GestureConfiguration(); | |
| 147 GestureDetector::Config DefaultGestureDetectorConfig(); | |
|
jdduke (slow)
2014/10/23 15:01:26
These |DefaultFooConfig()| methods could also go b
lanwei
2014/10/23 19:54:19
Done.
| |
| 148 ScaleGestureDetector::Config DefaultScaleGestureDetectorConfig(); | |
| 149 void set_double_tap_timeout_in_ms(int val) { | |
| 150 double_tap_timeout_in_ms_ = val; | |
| 151 } | |
| 152 void set_gesture_begin_end_types_enabled(bool val) { | |
| 153 gesture_begin_end_types_enabled_ = val; | |
| 154 } | |
| 155 void set_max_gesture_bounds_length(float val) { | |
| 156 max_gesture_bounds_length_ = val; | |
| 157 } | |
| 158 void set_max_swipe_deviation_angle(float val) { | |
| 159 max_swipe_deviation_angle_ = val; | |
| 160 } | |
| 161 void set_min_fling_velocity(float val) { min_fling_velocity_ = val; } | |
| 162 void set_min_gesture_bounds_length(float val) { | |
| 163 min_gesture_bounds_length_ = val; | |
| 164 } | |
| 165 void set_min_scaling_span_in_pixels(float val) { | |
| 166 min_scaling_span_in_pixels_ = val; | |
| 167 } | |
| 168 void set_min_scaling_touch_major(float val) { | |
| 169 min_scaling_touch_major_ = val; | |
| 170 } | |
| 171 void set_span_slop(float val) { span_slop_ = val; } | |
| 172 void set_swipe_enabled(bool val) { swipe_enabled_ = val; } | |
| 173 void set_two_finger_tap_enabled(bool val) { two_finger_tap_enabled_ = val; } | |
| 174 | |
| 175 private: | |
| 176 // These are listed in alphabetical order ignoring underscores. | |
| 177 | |
| 178 // The default touch radius length used when the only information given | |
| 179 // by the device is the touch center. | |
| 180 float default_radius_; | |
| 181 int double_tap_timeout_in_ms_; | |
| 182 // Maximum time between a GestureFlingCancel and a mousedown such that the | |
| 183 // mousedown is considered associated with the cancel event. | |
| 184 int fling_max_cancel_to_down_time_in_ms_; | |
| 185 | |
| 186 // Maxium time between a mousedown/mouseup pair that is considered to be a | |
| 187 // suppressable tap. | |
| 188 int fling_max_tap_gap_time_in_ms_; | |
| 189 bool gesture_begin_end_types_enabled_; | |
| 190 int long_press_time_in_ms_; | |
| 191 float max_distance_between_taps_for_double_tap_; | |
| 192 | |
| 193 // The maximum allowed distance between two fingers for a two finger tap. If | |
| 194 // the distance between two fingers is greater than this value, we will not | |
| 195 // recognize a two finger tap. | |
| 196 float max_distance_for_two_finger_tap_in_pixels_; | |
|
jdduke (slow)
2014/10/23 15:01:26
It's a shame all of these references are in |pixel
tdresser
2014/10/23 15:14:07
Yeah, that definitely is a shame. Not a change I'd
| |
| 197 float max_fling_velocity_; | |
| 198 float max_gesture_bounds_length_; | |
| 199 float max_separation_for_gesture_touches_in_pixels_; | |
| 200 float max_swipe_deviation_angle_; | |
| 201 int max_time_between_double_click_in_ms_; | |
| 202 int max_touch_down_duration_for_click_in_ms_; | |
| 203 float max_touch_move_in_pixels_for_click_; | |
| 204 float min_distance_for_pinch_scroll_in_pixels_; | |
| 205 float min_fling_velocity_; | |
| 206 float min_gesture_bounds_length_; | |
| 207 // Only used with --compensate-for-unstable-pinch-zoom. | |
| 208 float min_pinch_update_distance_in_pixels_; | |
| 209 float min_pinch_update_span_delta_; | |
| 210 float min_scaling_span_in_pixels_; | |
| 211 float min_scaling_touch_major_; | |
| 212 float min_swipe_velocity_; | |
| 213 int scroll_debounce_interval_in_ms_; | |
| 214 int semi_long_press_time_in_ms_; | |
| 215 int show_press_delay_in_ms_; | |
| 216 float span_slop_; | |
| 217 bool swipe_enabled_; | |
| 218 | |
| 219 // TODO(davemoore): Move into chrome/browser/ui. | |
| 220 int tab_scrub_activation_delay_in_ms_; | |
| 221 bool two_finger_tap_enabled_; | |
| 222 | |
| 223 friend struct DefaultSingletonTraits<GestureConfiguration>; | |
| 224 DISALLOW_COPY_AND_ASSIGN(GestureConfiguration); | |
| 225 }; | |
| 226 | |
| 227 GESTURE_DETECTION_EXPORT GestureProvider::Config DefaultGestureProviderConfig(); | |
| 228 | |
| 229 } // namespace ui | |
| 230 | |
| 231 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_CONFIGURATION_H_ | |
| OLD | NEW |