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