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 int fling_max_cancel_to_down_time_in_ms() const {
32 return fling_max_cancel_to_down_time_in_ms_
;
34 void set_fling_max_cancel_to_down_time_in_ms(int val
) {
35 fling_max_cancel_to_down_time_in_ms_
= val
;
37 int fling_max_tap_gap_time_in_ms() const {
38 return fling_max_tap_gap_time_in_ms_
;
40 void set_fling_max_tap_gap_time_in_ms(int val
) {
41 fling_max_tap_gap_time_in_ms_
= val
;
43 bool gesture_begin_end_types_enabled() const {
44 return gesture_begin_end_types_enabled_
;
46 void set_gesture_begin_end_types_enabled(bool val
) {
47 gesture_begin_end_types_enabled_
= val
;
49 int long_press_time_in_ms() const { return long_press_time_in_ms_
; }
50 void set_long_press_time_in_ms(int val
) { long_press_time_in_ms_
= val
; }
51 float max_distance_between_taps_for_double_tap() const {
52 return max_distance_between_taps_for_double_tap_
;
54 void set_max_distance_between_taps_for_double_tap(float val
) {
55 max_distance_between_taps_for_double_tap_
= val
;
57 float max_distance_for_two_finger_tap_in_pixels() const {
58 return max_distance_for_two_finger_tap_in_pixels_
;
60 void set_max_distance_for_two_finger_tap_in_pixels(float val
) {
61 max_distance_for_two_finger_tap_in_pixels_
= val
;
63 float max_fling_velocity() const { return max_fling_velocity_
; }
64 void set_max_fling_velocity(float val
) { max_fling_velocity_
= val
; }
65 float max_gesture_bounds_length() const {
66 return max_gesture_bounds_length_
;
68 void set_max_gesture_bounds_length(float val
) {
69 max_gesture_bounds_length_
= val
;
71 float max_separation_for_gesture_touches_in_pixels() const {
72 return max_separation_for_gesture_touches_in_pixels_
;
74 void set_max_separation_for_gesture_touches_in_pixels(float val
) {
75 max_separation_for_gesture_touches_in_pixels_
= val
;
77 float max_swipe_deviation_angle() const {
78 return max_swipe_deviation_angle_
;
80 void set_max_swipe_deviation_angle(float val
) {
81 max_swipe_deviation_angle_
= val
;
83 int max_time_between_double_click_in_ms() const {
84 return max_time_between_double_click_in_ms_
;
86 void set_max_time_between_double_click_in_ms(int val
) {
87 max_time_between_double_click_in_ms_
= val
;
89 int max_touch_down_duration_for_click_in_ms() const {
90 return max_touch_down_duration_for_click_in_ms_
;
92 void set_max_touch_down_duration_for_click_in_ms(int val
) {
93 max_touch_down_duration_for_click_in_ms_
= val
;
95 float max_touch_move_in_pixels_for_click() const {
96 return max_touch_move_in_pixels_for_click_
;
98 void set_max_touch_move_in_pixels_for_click(float val
) {
99 max_touch_move_in_pixels_for_click_
= val
;
100 span_slop_
= max_touch_move_in_pixels_for_click_
* 2;
102 float min_distance_for_pinch_scroll_in_pixels() const {
103 return min_distance_for_pinch_scroll_in_pixels_
;
105 void set_min_distance_for_pinch_scroll_in_pixels(float val
) {
106 min_distance_for_pinch_scroll_in_pixels_
= val
;
108 float min_fling_velocity() const { return min_fling_velocity_
; }
109 void set_min_fling_velocity(float val
) { min_fling_velocity_
= val
; }
110 float min_gesture_bounds_length() const {
111 return min_gesture_bounds_length_
;
113 float min_pinch_update_span_delta() const {
114 return min_pinch_update_span_delta_
;
116 void set_min_pinch_update_span_delta(float val
) {
117 min_pinch_update_span_delta_
= val
;
119 float min_scaling_span_in_pixels() const {
120 return min_scaling_span_in_pixels_
;
122 void set_min_scaling_span_in_pixels(float val
) {
123 min_scaling_span_in_pixels_
= val
;
125 float min_scaling_touch_major() const { return min_scaling_touch_major_
; }
126 float min_swipe_velocity() const { return min_swipe_velocity_
; }
127 void set_min_swipe_velocity(float val
) { min_swipe_velocity_
= val
; }
128 int scroll_debounce_interval_in_ms() const {
129 return scroll_debounce_interval_in_ms_
;
131 int set_scroll_debounce_interval_in_ms(int val
) {
132 return scroll_debounce_interval_in_ms_
= val
;
134 int semi_long_press_time_in_ms() const {
135 return semi_long_press_time_in_ms_
;
137 void set_semi_long_press_time_in_ms(int val
) {
138 semi_long_press_time_in_ms_
= val
;
139 double_tap_timeout_in_ms_
= val
;
141 int show_press_delay_in_ms() const { return show_press_delay_in_ms_
; }
142 int set_show_press_delay_in_ms(int val
) {
143 return show_press_delay_in_ms_
= val
;
145 float span_slop() const { return span_slop_
; }
146 bool swipe_enabled() const { return swipe_enabled_
; }
147 void set_swipe_enabled(bool val
) { swipe_enabled_
= val
; }
149 // TODO(davemoore): Move into chrome/browser/ui.
150 int tab_scrub_activation_delay_in_ms() const {
151 return tab_scrub_activation_delay_in_ms_
;
153 void set_tab_scrub_activation_delay_in_ms(int val
) {
154 tab_scrub_activation_delay_in_ms_
= val
;
156 bool two_finger_tap_enabled() const { return two_finger_tap_enabled_
; }
157 void set_two_finger_tap_enabled(bool val
) { two_finger_tap_enabled_
= val
; }
158 VelocityTracker::Strategy
velocity_tracker_strategy() const {
159 return velocity_tracker_strategy_
;
161 void set_velocity_tracker_strategy(VelocityTracker::Strategy val
) {
162 velocity_tracker_strategy_
= val
;
166 GestureConfiguration();
167 virtual ~GestureConfiguration();
169 // The below configuration parameters are dependent on other parameters,
170 // whose setter functions will setup these values as well, so we will not
171 // provide public setter functions for them.
172 void set_double_tap_timeout_in_ms(int val
) {
173 double_tap_timeout_in_ms_
= val
;
175 void set_min_gesture_bounds_length(float val
) {
176 min_gesture_bounds_length_
= val
;
178 void set_min_scaling_touch_major(float val
) {
179 min_scaling_touch_major_
= val
;
181 void set_span_slop(float val
) { span_slop_
= val
; }
184 // Returns the platform specific instance. This is invoked if a specific
185 // instance has not been set.
186 static GestureConfiguration
* GetPlatformSpecificInstance();
188 // These are listed in alphabetical order ignoring underscores.
189 // NOTE: Adding new configuration parameters requires initializing
190 // corresponding entries in aura_test_base.cc's SetUp().
192 // The default touch radius length used when the only information given
193 // by the device is the touch center.
194 float default_radius_
;
196 bool double_tap_enabled_
;
197 int double_tap_timeout_in_ms_
;
199 // Maximum time between a GestureFlingCancel and a mousedown such that the
200 // mousedown is considered associated with the cancel event.
201 int fling_max_cancel_to_down_time_in_ms_
;
203 // Maxium time between a mousedown/mouseup pair that is considered to be a
205 int fling_max_tap_gap_time_in_ms_
;
206 bool gesture_begin_end_types_enabled_
;
207 int long_press_time_in_ms_
;
208 float max_distance_between_taps_for_double_tap_
;
210 // The maximum allowed distance between two fingers for a two finger tap. If
211 // the distance between two fingers is greater than this value, we will not
212 // recognize a two finger tap.
213 float max_distance_for_two_finger_tap_in_pixels_
;
214 float max_fling_velocity_
;
215 float max_gesture_bounds_length_
;
216 float max_separation_for_gesture_touches_in_pixels_
;
217 float max_swipe_deviation_angle_
;
218 int max_time_between_double_click_in_ms_
;
219 int max_touch_down_duration_for_click_in_ms_
;
220 float max_touch_move_in_pixels_for_click_
;
221 float min_distance_for_pinch_scroll_in_pixels_
;
222 float min_fling_velocity_
;
223 float min_gesture_bounds_length_
;
224 // Only used with --compensate-for-unstable-pinch-zoom.
225 float min_pinch_update_span_delta_
;
226 float min_scaling_span_in_pixels_
;
227 float min_scaling_touch_major_
;
228 float min_swipe_velocity_
;
229 int scroll_debounce_interval_in_ms_
;
230 int semi_long_press_time_in_ms_
;
231 int show_press_delay_in_ms_
;
235 // TODO(davemoore): Move into chrome/browser/ui.
236 int tab_scrub_activation_delay_in_ms_
;
237 bool two_finger_tap_enabled_
;
238 VelocityTracker::Strategy velocity_tracker_strategy_
;
240 DISALLOW_COPY_AND_ASSIGN(GestureConfiguration
);
245 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_CONFIGURATION_H_