Revert of Roll src/third_party/WebKit e0eac24:489c548 (svn 193311:193320) (patchset...
[chromium-blink-merge.git] / ui / events / gesture_detection / gesture_configuration.h
blob1644eed23df5dc7cffca91f821806d6dfebcc122
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 "base/memory/singleton.h"
10 #include "ui/events/gesture_detection/gesture_detection_export.h"
11 #include "ui/events/gesture_detection/velocity_tracker.h"
13 namespace ui {
15 class GESTURE_DETECTION_EXPORT GestureConfiguration {
16 public:
17 // Returns the singleton GestureConfiguration.
18 static GestureConfiguration* GetInstance();
20 // Ordered alphabetically ignoring underscores.
21 float default_radius() const { return default_radius_; }
22 void set_default_radius(float radius) {
23 default_radius_ = radius;
24 min_scaling_touch_major_ = default_radius_ * 2;
25 min_gesture_bounds_length_ = default_radius_;
27 bool double_tap_enabled() const { return double_tap_enabled_; }
28 void set_double_tap_enabled(bool enabled) { double_tap_enabled_ = enabled; }
29 int double_tap_timeout_in_ms() const { return double_tap_timeout_in_ms_; }
30 int fling_max_cancel_to_down_time_in_ms() const {
31 return fling_max_cancel_to_down_time_in_ms_;
33 void set_fling_max_cancel_to_down_time_in_ms(int val) {
34 fling_max_cancel_to_down_time_in_ms_ = val;
36 int fling_max_tap_gap_time_in_ms() const {
37 return fling_max_tap_gap_time_in_ms_;
39 void set_fling_max_tap_gap_time_in_ms(int val) {
40 fling_max_tap_gap_time_in_ms_ = val;
42 bool gesture_begin_end_types_enabled() const {
43 return gesture_begin_end_types_enabled_;
45 void set_gesture_begin_end_types_enabled(bool val) {
46 gesture_begin_end_types_enabled_ = val;
48 int long_press_time_in_ms() const { 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() const {
51 return max_distance_between_taps_for_double_tap_;
53 void set_max_distance_between_taps_for_double_tap(float val) {
54 max_distance_between_taps_for_double_tap_ = val;
56 float max_distance_for_two_finger_tap_in_pixels() const {
57 return max_distance_for_two_finger_tap_in_pixels_;
59 void set_max_distance_for_two_finger_tap_in_pixels(float val) {
60 max_distance_for_two_finger_tap_in_pixels_ = val;
62 float max_fling_velocity() const { return max_fling_velocity_; }
63 void set_max_fling_velocity(float val) { max_fling_velocity_ = val; }
64 float max_gesture_bounds_length() const {
65 return max_gesture_bounds_length_;
67 void set_max_gesture_bounds_length(float val) {
68 max_gesture_bounds_length_ = val;
70 float max_separation_for_gesture_touches_in_pixels() const {
71 return max_separation_for_gesture_touches_in_pixels_;
73 void set_max_separation_for_gesture_touches_in_pixels(float val) {
74 max_separation_for_gesture_touches_in_pixels_ = val;
76 float max_swipe_deviation_angle() const {
77 return max_swipe_deviation_angle_;
79 void set_max_swipe_deviation_angle(float val) {
80 max_swipe_deviation_angle_ = val;
82 int max_time_between_double_click_in_ms() const {
83 return max_time_between_double_click_in_ms_;
85 void set_max_time_between_double_click_in_ms(int val) {
86 max_time_between_double_click_in_ms_ = val;
88 int max_touch_down_duration_for_click_in_ms() const {
89 return max_touch_down_duration_for_click_in_ms_;
91 void set_max_touch_down_duration_for_click_in_ms(int val) {
92 max_touch_down_duration_for_click_in_ms_ = val;
94 float max_touch_move_in_pixels_for_click() const {
95 return max_touch_move_in_pixels_for_click_;
97 void set_max_touch_move_in_pixels_for_click(float val) {
98 max_touch_move_in_pixels_for_click_ = val;
99 span_slop_ = max_touch_move_in_pixels_for_click_ * 2;
101 float min_distance_for_pinch_scroll_in_pixels() const {
102 return min_distance_for_pinch_scroll_in_pixels_;
104 void set_min_distance_for_pinch_scroll_in_pixels(float val) {
105 min_distance_for_pinch_scroll_in_pixels_ = val;
107 float min_fling_velocity() const { return min_fling_velocity_; }
108 void set_min_fling_velocity(float val) { min_fling_velocity_ = val; }
109 float min_gesture_bounds_length() const {
110 return min_gesture_bounds_length_;
112 float min_pinch_update_span_delta() const {
113 return min_pinch_update_span_delta_;
115 void set_min_pinch_update_span_delta(float val) {
116 min_pinch_update_span_delta_ = val;
118 float min_scaling_span_in_pixels() const {
119 return min_scaling_span_in_pixels_;
121 void set_min_scaling_span_in_pixels(float val) {
122 min_scaling_span_in_pixels_ = val;
124 float min_scaling_touch_major() const { return min_scaling_touch_major_; }
125 float min_swipe_velocity() const { return min_swipe_velocity_; }
126 void set_min_swipe_velocity(float val) { min_swipe_velocity_ = val; }
127 int scroll_debounce_interval_in_ms() const {
128 return scroll_debounce_interval_in_ms_;
130 int set_scroll_debounce_interval_in_ms(int val) {
131 return scroll_debounce_interval_in_ms_ = val;
133 int semi_long_press_time_in_ms() const {
134 return semi_long_press_time_in_ms_;
136 void set_semi_long_press_time_in_ms(int val) {
137 semi_long_press_time_in_ms_ = val;
138 double_tap_timeout_in_ms_ = val;
140 int show_press_delay_in_ms() const { return show_press_delay_in_ms_; }
141 int set_show_press_delay_in_ms(int val) {
142 return show_press_delay_in_ms_ = val;
144 float span_slop() const { return span_slop_; }
145 bool swipe_enabled() const { return swipe_enabled_; }
146 void set_swipe_enabled(bool val) { swipe_enabled_ = val; }
148 // TODO(davemoore): Move into chrome/browser/ui.
149 int tab_scrub_activation_delay_in_ms() const {
150 return tab_scrub_activation_delay_in_ms_;
152 void set_tab_scrub_activation_delay_in_ms(int val) {
153 tab_scrub_activation_delay_in_ms_ = val;
155 bool two_finger_tap_enabled() const { return two_finger_tap_enabled_; }
156 void set_two_finger_tap_enabled(bool val) { two_finger_tap_enabled_ = val; }
157 VelocityTracker::Strategy velocity_tracker_strategy() const {
158 return velocity_tracker_strategy_;
160 void set_velocity_tracker_strategy(VelocityTracker::Strategy val) {
161 velocity_tracker_strategy_ = val;
164 protected:
165 GestureConfiguration();
166 virtual ~GestureConfiguration();
168 // The below configuration parameters are dependent on other parameters,
169 // whose setter functions will setup these values as well, so we will not
170 // provide public setter functions for them.
171 void set_double_tap_timeout_in_ms(int val) {
172 double_tap_timeout_in_ms_ = val;
174 void set_min_gesture_bounds_length(float val) {
175 min_gesture_bounds_length_ = val;
177 void set_min_scaling_touch_major(float val) {
178 min_scaling_touch_major_ = val;
180 void set_span_slop(float val) { span_slop_ = val; }
182 private:
183 // These are listed in alphabetical order ignoring underscores.
184 // NOTE: Adding new configuration parameters requires initializing
185 // corresponding entries in aura_test_base.cc's SetUp().
187 // The default touch radius length used when the only information given
188 // by the device is the touch center.
189 float default_radius_;
191 bool double_tap_enabled_;
192 int double_tap_timeout_in_ms_;
194 // Maximum time between a GestureFlingCancel and a mousedown such that the
195 // mousedown is considered associated with the cancel event.
196 int fling_max_cancel_to_down_time_in_ms_;
198 // Maxium time between a mousedown/mouseup pair that is considered to be a
199 // suppressable tap.
200 int fling_max_tap_gap_time_in_ms_;
201 bool gesture_begin_end_types_enabled_;
202 int long_press_time_in_ms_;
203 float max_distance_between_taps_for_double_tap_;
205 // The maximum allowed distance between two fingers for a two finger tap. If
206 // the distance between two fingers is greater than this value, we will not
207 // recognize a two finger tap.
208 float max_distance_for_two_finger_tap_in_pixels_;
209 float max_fling_velocity_;
210 float max_gesture_bounds_length_;
211 float max_separation_for_gesture_touches_in_pixels_;
212 float max_swipe_deviation_angle_;
213 int max_time_between_double_click_in_ms_;
214 int max_touch_down_duration_for_click_in_ms_;
215 float max_touch_move_in_pixels_for_click_;
216 float min_distance_for_pinch_scroll_in_pixels_;
217 float min_fling_velocity_;
218 float min_gesture_bounds_length_;
219 // Only used with --compensate-for-unstable-pinch-zoom.
220 float min_pinch_update_span_delta_;
221 float min_scaling_span_in_pixels_;
222 float min_scaling_touch_major_;
223 float min_swipe_velocity_;
224 int scroll_debounce_interval_in_ms_;
225 int semi_long_press_time_in_ms_;
226 int show_press_delay_in_ms_;
227 float span_slop_;
228 bool swipe_enabled_;
230 // TODO(davemoore): Move into chrome/browser/ui.
231 int tab_scrub_activation_delay_in_ms_;
232 bool two_finger_tap_enabled_;
233 VelocityTracker::Strategy velocity_tracker_strategy_;
235 friend struct DefaultSingletonTraits<GestureConfiguration>;
236 DISALLOW_COPY_AND_ASSIGN(GestureConfiguration);
239 } // namespace ui
241 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_CONFIGURATION_H_