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.
5 #ifndef UI_EVENTS_GESTURES_GESTURE_CONFIGURATION_H_
6 #define UI_EVENTS_GESTURES_GESTURE_CONFIGURATION_H_
8 #include "base/basictypes.h"
9 #include "ui/events/events_base_export.h"
13 // TODO: Expand this design to support multiple OS configuration
14 // approaches (windows, chrome, others). This would turn into an
15 // abstract base class.
17 class EVENTS_BASE_EXPORT GestureConfiguration
{
19 // Number of parameters in the array of parameters for the fling acceleration
21 static const int NumAccelParams
= 4;
23 // Ordered alphabetically ignoring underscores, to align with the
24 // associated list of prefs in gesture_prefs_aura.cc.
25 static int default_radius() {
26 return default_radius_
;
28 static void set_default_radius(int radius
) { default_radius_
= radius
; }
29 static int fling_max_cancel_to_down_time_in_ms() {
30 return fling_max_cancel_to_down_time_in_ms_
;
32 static void set_fling_max_cancel_to_down_time_in_ms(int val
) {
33 fling_max_cancel_to_down_time_in_ms_
= val
;
35 static int fling_max_tap_gap_time_in_ms() {
36 return fling_max_tap_gap_time_in_ms_
;
38 static void set_fling_max_tap_gap_time_in_ms(int val
) {
39 fling_max_tap_gap_time_in_ms_
= val
;
41 static double long_press_time_in_seconds() {
42 return long_press_time_in_seconds_
;
44 static double semi_long_press_time_in_seconds() {
45 return semi_long_press_time_in_seconds_
;
47 static double max_distance_for_two_finger_tap_in_pixels() {
48 return max_distance_for_two_finger_tap_in_pixels_
;
50 static void set_max_distance_for_two_finger_tap_in_pixels(double val
) {
51 max_distance_for_two_finger_tap_in_pixels_
= val
;
53 static int max_radius() {
56 static void set_long_press_time_in_seconds(double val
) {
57 long_press_time_in_seconds_
= val
;
59 static void set_semi_long_press_time_in_seconds(double val
) {
60 semi_long_press_time_in_seconds_
= val
;
62 static double max_seconds_between_double_click() {
63 return max_seconds_between_double_click_
;
65 static void set_max_seconds_between_double_click(double val
) {
66 max_seconds_between_double_click_
= val
;
68 static int max_separation_for_gesture_touches_in_pixels() {
69 return max_separation_for_gesture_touches_in_pixels_
;
71 static void set_max_separation_for_gesture_touches_in_pixels(int val
) {
72 max_separation_for_gesture_touches_in_pixels_
= val
;
74 static float max_swipe_deviation_angle() {
75 return max_swipe_deviation_angle_
;
77 static void set_max_swipe_deviation_angle(float val
) {
78 max_swipe_deviation_angle_
= val
;
80 static double max_touch_down_duration_in_seconds_for_click() {
81 return max_touch_down_duration_in_seconds_for_click_
;
83 static void set_max_touch_down_duration_in_seconds_for_click(double val
) {
84 max_touch_down_duration_in_seconds_for_click_
= val
;
86 static double max_touch_move_in_pixels_for_click() {
87 return max_touch_move_in_pixels_for_click_
;
89 static void set_max_touch_move_in_pixels_for_click(double val
) {
90 max_touch_move_in_pixels_for_click_
= val
;
92 static double max_distance_between_taps_for_double_tap() {
93 return max_distance_between_taps_for_double_tap_
;
95 static void set_max_distance_between_taps_for_double_tap(double val
) {
96 max_distance_between_taps_for_double_tap_
= val
;
98 static double min_distance_for_pinch_scroll_in_pixels() {
99 return min_distance_for_pinch_scroll_in_pixels_
;
101 static void set_min_distance_for_pinch_scroll_in_pixels(double val
) {
102 min_distance_for_pinch_scroll_in_pixels_
= val
;
104 static double min_flick_speed_squared() {
105 return min_flick_speed_squared_
;
107 static void set_min_flick_speed_squared(double val
) {
108 min_flick_speed_squared_
= val
;
110 static double min_pinch_update_distance_in_pixels() {
111 return min_pinch_update_distance_in_pixels_
;
113 static void set_min_pinch_update_distance_in_pixels(double val
) {
114 min_pinch_update_distance_in_pixels_
= val
;
116 static double min_rail_break_velocity() {
117 return min_rail_break_velocity_
;
119 static void set_min_rail_break_velocity(double val
) {
120 min_rail_break_velocity_
= val
;
122 static double min_scroll_delta_squared() {
123 return min_scroll_delta_squared_
;
125 static void set_min_scroll_delta_squared(double val
) {
126 min_scroll_delta_squared_
= val
;
128 static float min_scroll_velocity() {
129 return min_scroll_velocity_
;
131 static void set_min_scroll_velocity(float val
) {
132 min_scroll_velocity_
= val
;
134 static double min_swipe_speed() {
135 return min_swipe_speed_
;
137 static void set_min_swipe_speed(double val
) {
138 min_swipe_speed_
= val
;
140 static double min_touch_down_duration_in_seconds_for_click() {
141 return min_touch_down_duration_in_seconds_for_click_
;
143 static void set_min_touch_down_duration_in_seconds_for_click(double val
) {
144 min_touch_down_duration_in_seconds_for_click_
= val
;
147 static int min_scaling_span_in_pixels() {
148 return min_scaling_span_in_pixels_
;
151 static void set_min_scaling_span_in_pixels(int val
) {
152 min_scaling_span_in_pixels_
= val
;
155 static int points_buffered_for_velocity() {
156 return points_buffered_for_velocity_
;
158 static void set_points_buffered_for_velocity(int val
) {
159 points_buffered_for_velocity_
= val
;
161 static double rail_break_proportion() {
162 return rail_break_proportion_
;
164 static void set_rail_break_proportion(double val
) {
165 rail_break_proportion_
= val
;
167 static double rail_start_proportion() {
168 return rail_start_proportion_
;
170 static void set_rail_start_proportion(double val
) {
171 rail_start_proportion_
= val
;
173 static double scroll_prediction_seconds() {
174 return scroll_prediction_seconds_
;
176 static void set_scroll_prediction_seconds(double val
) {
177 scroll_prediction_seconds_
= val
;
179 static int show_press_delay_in_ms() {
180 return show_press_delay_in_ms_
;
182 static int set_show_press_delay_in_ms(int val
) {
183 return show_press_delay_in_ms_
= val
;
185 static int scroll_debounce_interval_in_ms() {
186 return scroll_debounce_interval_in_ms_
;
188 static int set_scroll_debounce_interval_in_ms(int val
) {
189 return scroll_debounce_interval_in_ms_
= val
;
191 static void set_fling_acceleration_curve_coefficients(int i
, float val
) {
192 fling_acceleration_curve_coefficients_
[i
] = val
;
194 static float fling_acceleration_curve_coefficients(int i
) {
195 return fling_acceleration_curve_coefficients_
[i
];
197 static float fling_velocity_cap() {
198 return fling_velocity_cap_
;
200 static void set_fling_velocity_cap(float val
) {
201 fling_velocity_cap_
= val
;
203 // TODO(davemoore): Move into chrome/browser/ui.
204 static int tab_scrub_activation_delay_in_ms() {
205 return tab_scrub_activation_delay_in_ms_
;
207 static void set_tab_scrub_activation_delay_in_ms(int val
) {
208 tab_scrub_activation_delay_in_ms_
= val
;
212 // These are listed in alphabetical order ignoring underscores, to
213 // align with the associated list of preferences in
214 // gesture_prefs_aura.cc. These two lists should be kept in sync.
216 // The default touch radius length used when the only information given
217 // by the device is the touch center.
218 static int default_radius_
;
220 // The maximum allowed distance between two fingers for a two finger tap. If
221 // the distance between two fingers is greater than this value, we will not
222 // recognize a two finger tap.
223 static double max_distance_for_two_finger_tap_in_pixels_
;
225 // The maximum allowed size for the radius of a touch region used in
226 // forming an ET_GESTURE_TAP event.
227 static int max_radius_
;
229 // Maximum time between a GestureFlingCancel and a mousedown such that the
230 // mousedown is considered associated with the cancel event.
231 static int fling_max_cancel_to_down_time_in_ms_
;
233 // Maxium time between a mousedown/mouseup pair that is considered to be a
235 static int fling_max_tap_gap_time_in_ms_
;
237 static double long_press_time_in_seconds_
;
238 static double semi_long_press_time_in_seconds_
;
239 static double max_seconds_between_double_click_
;
240 static double max_separation_for_gesture_touches_in_pixels_
;
241 static float max_swipe_deviation_angle_
;
242 static double max_touch_down_duration_in_seconds_for_click_
;
243 static double max_touch_move_in_pixels_for_click_
;
244 static double max_distance_between_taps_for_double_tap_
;
245 static double min_distance_for_pinch_scroll_in_pixels_
;
246 static double min_flick_speed_squared_
;
247 // Only used with --compensate-for-unstable-pinch-zoom.
248 static double min_pinch_update_distance_in_pixels_
;
249 static double min_rail_break_velocity_
;
250 static double min_scroll_delta_squared_
;
251 static float min_scroll_velocity_
;
252 static double min_swipe_speed_
;
253 static double min_touch_down_duration_in_seconds_for_click_
;
254 static int min_scaling_span_in_pixels_
;
255 static int points_buffered_for_velocity_
;
256 static double rail_break_proportion_
;
257 static double rail_start_proportion_
;
258 static double scroll_prediction_seconds_
;
259 static int show_press_delay_in_ms_
;
260 static int scroll_debounce_interval_in_ms_
;
262 static float fling_acceleration_curve_coefficients_
[NumAccelParams
];
263 static float fling_velocity_cap_
;
264 // TODO(davemoore): Move into chrome/browser/ui.
265 static int tab_scrub_activation_delay_in_ms_
;
267 DISALLOW_COPY_AND_ASSIGN(GestureConfiguration
);
272 #endif // UI_EVENTS_GESTURES_GESTURE_CONFIGURATION_H_