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
3 // found in the LICENSE file.
5 #ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_CONFIGURATION_H_
6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_CONFIGURATION_H_
8 #include "base/basictypes.h"
9 #include "ui/events/gesture_detection/gesture_detection_export.h"
10 #include "ui/events/gesture_detection/velocity_tracker.h"
14 class GESTURE_DETECTION_EXPORT GestureConfiguration
{
16 // Sets the shared instance. This does not take ownership of |config|.
17 static void SetInstance(GestureConfiguration
* config
);
18 // Returns the singleton GestureConfiguration.
19 static GestureConfiguration
* GetInstance();
21 // Ordered alphabetically ignoring underscores.
22 float default_radius() const { return default_radius_
; }
23 void set_default_radius(float radius
) {
24 default_radius_
= radius
;
25 min_scaling_touch_major_
= default_radius_
* 2;
26 min_gesture_bounds_length_
= default_radius_
;
28 bool double_tap_enabled() const { return double_tap_enabled_
; }
29 void set_double_tap_enabled(bool enabled
) { double_tap_enabled_
= enabled
; }
30 int double_tap_timeout_in_ms() const { return double_tap_timeout_in_ms_
; }
31 bool fling_touchpad_tap_suppression_enabled() const {
32 return fling_touchpad_tap_suppression_enabled_
;
34 void set_fling_touchpad_tap_suppression_enabled(bool enabled
) {
35 fling_touchpad_tap_suppression_enabled_
= enabled
;
37 bool fling_touchscreen_tap_suppression_enabled() const {
38 return fling_touchscreen_tap_suppression_enabled_
;
40 void set_fling_touchscreen_tap_suppression_enabled(bool enabled
) {
41 fling_touchscreen_tap_suppression_enabled_
= enabled
;
43 int fling_max_cancel_to_down_time_in_ms() const {
44 return fling_max_cancel_to_down_time_in_ms_
;
46 void set_fling_max_cancel_to_down_time_in_ms(int val
) {
47 fling_max_cancel_to_down_time_in_ms_
= val
;
49 int fling_max_tap_gap_time_in_ms() const {
50 return fling_max_tap_gap_time_in_ms_
;
52 void set_fling_max_tap_gap_time_in_ms(int val
) {
53 fling_max_tap_gap_time_in_ms_
= val
;
55 bool gesture_begin_end_types_enabled() const {
56 return gesture_begin_end_types_enabled_
;
58 void set_gesture_begin_end_types_enabled(bool val
) {
59 gesture_begin_end_types_enabled_
= val
;
61 int long_press_time_in_ms() const { return long_press_time_in_ms_
; }
62 void set_long_press_time_in_ms(int val
) { long_press_time_in_ms_
= val
; }
63 float max_distance_between_taps_for_double_tap() const {
64 return max_distance_between_taps_for_double_tap_
;
66 void set_max_distance_between_taps_for_double_tap(float val
) {
67 max_distance_between_taps_for_double_tap_
= val
;
69 float max_distance_for_two_finger_tap_in_pixels() const {
70 return max_distance_for_two_finger_tap_in_pixels_
;
72 void set_max_distance_for_two_finger_tap_in_pixels(float val
) {
73 max_distance_for_two_finger_tap_in_pixels_
= val
;
75 float max_fling_velocity() const { return max_fling_velocity_
; }
76 void set_max_fling_velocity(float val
) { max_fling_velocity_
= val
; }
77 float max_gesture_bounds_length() const {
78 return max_gesture_bounds_length_
;
80 void set_max_gesture_bounds_length(float val
) {
81 max_gesture_bounds_length_
= val
;
83 float max_separation_for_gesture_touches_in_pixels() const {
84 return max_separation_for_gesture_touches_in_pixels_
;
86 void set_max_separation_for_gesture_touches_in_pixels(float val
) {
87 max_separation_for_gesture_touches_in_pixels_
= val
;
89 float max_swipe_deviation_angle() const {
90 return max_swipe_deviation_angle_
;
92 void set_max_swipe_deviation_angle(float val
) {
93 max_swipe_deviation_angle_
= val
;
95 int max_time_between_double_click_in_ms() const {
96 return max_time_between_double_click_in_ms_
;
98 void set_max_time_between_double_click_in_ms(int val
) {
99 max_time_between_double_click_in_ms_
= val
;
101 int max_touch_down_duration_for_click_in_ms() const {
102 return max_touch_down_duration_for_click_in_ms_
;
104 void set_max_touch_down_duration_for_click_in_ms(int val
) {
105 max_touch_down_duration_for_click_in_ms_
= val
;
107 float max_touch_move_in_pixels_for_click() const {
108 return max_touch_move_in_pixels_for_click_
;
110 void set_max_touch_move_in_pixels_for_click(float val
) {
111 max_touch_move_in_pixels_for_click_
= val
;
112 span_slop_
= max_touch_move_in_pixels_for_click_
* 2;
114 float min_distance_for_pinch_scroll_in_pixels() const {
115 return min_distance_for_pinch_scroll_in_pixels_
;
117 void set_min_distance_for_pinch_scroll_in_pixels(float val
) {
118 min_distance_for_pinch_scroll_in_pixels_
= val
;
120 float min_fling_velocity() const { return min_fling_velocity_
; }
121 void set_min_fling_velocity(float val
) { min_fling_velocity_
= val
; }
122 float min_gesture_bounds_length() const {
123 return min_gesture_bounds_length_
;
125 float min_pinch_update_span_delta() const {
126 return min_pinch_update_span_delta_
;
128 void set_min_pinch_update_span_delta(float val
) {
129 min_pinch_update_span_delta_
= val
;
131 float min_scaling_span_in_pixels() const {
132 return min_scaling_span_in_pixels_
;
134 void set_min_scaling_span_in_pixels(float val
) {
135 min_scaling_span_in_pixels_
= val
;
137 float min_scaling_touch_major() const { return min_scaling_touch_major_
; }
138 float min_swipe_velocity() const { return min_swipe_velocity_
; }
139 void set_min_swipe_velocity(float val
) { min_swipe_velocity_
= val
; }
140 int scroll_debounce_interval_in_ms() const {
141 return scroll_debounce_interval_in_ms_
;
143 int set_scroll_debounce_interval_in_ms(int val
) {
144 return scroll_debounce_interval_in_ms_
= val
;
146 int semi_long_press_time_in_ms() const {
147 return semi_long_press_time_in_ms_
;
149 void set_semi_long_press_time_in_ms(int val
) {
150 semi_long_press_time_in_ms_
= val
;
151 double_tap_timeout_in_ms_
= val
;
153 int show_press_delay_in_ms() const { return show_press_delay_in_ms_
; }
154 int set_show_press_delay_in_ms(int val
) {
155 return show_press_delay_in_ms_
= val
;
157 float span_slop() const { return span_slop_
; }
158 bool swipe_enabled() const { return swipe_enabled_
; }
159 void set_swipe_enabled(bool val
) { swipe_enabled_
= val
; }
161 // TODO(davemoore): Move into chrome/browser/ui.
162 int tab_scrub_activation_delay_in_ms() const {
163 return tab_scrub_activation_delay_in_ms_
;
165 void set_tab_scrub_activation_delay_in_ms(int val
) {
166 tab_scrub_activation_delay_in_ms_
= val
;
168 bool two_finger_tap_enabled() const { return two_finger_tap_enabled_
; }
169 void set_two_finger_tap_enabled(bool val
) { two_finger_tap_enabled_
= val
; }
170 VelocityTracker::Strategy
velocity_tracker_strategy() const {
171 return velocity_tracker_strategy_
;
173 void set_velocity_tracker_strategy(VelocityTracker::Strategy val
) {
174 velocity_tracker_strategy_
= val
;
178 GestureConfiguration();
179 virtual ~GestureConfiguration();
181 // The below configuration parameters are dependent on other parameters,
182 // whose setter functions will setup these values as well, so we will not
183 // provide public setter functions for them.
184 void set_double_tap_timeout_in_ms(int val
) {
185 double_tap_timeout_in_ms_
= val
;
187 void set_min_gesture_bounds_length(float val
) {
188 min_gesture_bounds_length_
= val
;
190 void set_min_scaling_touch_major(float val
) {
191 min_scaling_touch_major_
= val
;
193 void set_span_slop(float val
) { span_slop_
= val
; }
196 // Returns the platform specific instance. This is invoked if a specific
197 // instance has not been set.
198 static GestureConfiguration
* GetPlatformSpecificInstance();
200 // These are listed in alphabetical order ignoring underscores.
201 // NOTE: Adding new configuration parameters requires initializing
202 // corresponding entries in aura_test_base.cc's SetUp().
204 // The default touch radius length used when the only information given
205 // by the device is the touch center.
206 float default_radius_
;
208 bool double_tap_enabled_
;
209 int double_tap_timeout_in_ms_
;
211 // Whether to suppress touchscreen/touchpad taps that occur during a fling (
212 // in particular, when such taps cancel the active fling).
213 bool fling_touchpad_tap_suppression_enabled_
;
214 bool fling_touchscreen_tap_suppression_enabled_
;
216 // Maximum time between a GestureFlingCancel and a mousedown such that the
217 // mousedown is considered associated with the cancel event.
218 int fling_max_cancel_to_down_time_in_ms_
;
220 // Maxium time between a mousedown/mouseup pair that is considered to be a
222 int fling_max_tap_gap_time_in_ms_
;
223 bool gesture_begin_end_types_enabled_
;
224 int long_press_time_in_ms_
;
225 float max_distance_between_taps_for_double_tap_
;
227 // The maximum allowed distance between two fingers for a two finger tap. If
228 // the distance between two fingers is greater than this value, we will not
229 // recognize a two finger tap.
230 float max_distance_for_two_finger_tap_in_pixels_
;
231 float max_fling_velocity_
;
232 float max_gesture_bounds_length_
;
233 float max_separation_for_gesture_touches_in_pixels_
;
234 float max_swipe_deviation_angle_
;
235 int max_time_between_double_click_in_ms_
;
236 int max_touch_down_duration_for_click_in_ms_
;
237 float max_touch_move_in_pixels_for_click_
;
238 float min_distance_for_pinch_scroll_in_pixels_
;
239 float min_fling_velocity_
;
240 float min_gesture_bounds_length_
;
241 // Only used with --compensate-for-unstable-pinch-zoom.
242 float min_pinch_update_span_delta_
;
243 float min_scaling_span_in_pixels_
;
244 float min_scaling_touch_major_
;
245 float min_swipe_velocity_
;
246 int scroll_debounce_interval_in_ms_
;
247 int semi_long_press_time_in_ms_
;
248 int show_press_delay_in_ms_
;
252 // TODO(davemoore): Move into chrome/browser/ui.
253 int tab_scrub_activation_delay_in_ms_
;
254 bool two_finger_tap_enabled_
;
255 VelocityTracker::Strategy velocity_tracker_strategy_
;
257 DISALLOW_COPY_AND_ASSIGN(GestureConfiguration
);
262 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_CONFIGURATION_H_