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.
4
5#ifndef UI_EVENTS_GESTURES_GESTURE_CONFIGURATION_H_
6#define UI_EVENTS_GESTURES_GESTURE_CONFIGURATION_H_
7
8#include "base/basictypes.h"
9#include "ui/events/events_base_export.h"
10
11namespace ui {
12
13// TODO: Expand this design to support multiple OS configuration
14// approaches (windows, chrome, others).  This would turn into an
15// abstract base class.
16
17class EVENTS_BASE_EXPORT GestureConfiguration {
18 public:
19  // Ordered alphabetically ignoring underscores, to align with the
20  // associated list of prefs in gesture_prefs_aura.cc.
21  static int default_radius() {
22    return default_radius_;
23  }
24  static void set_default_radius(int radius) { default_radius_ = radius; }
25  static int fling_max_cancel_to_down_time_in_ms() {
26    return fling_max_cancel_to_down_time_in_ms_;
27  }
28  static void set_fling_max_cancel_to_down_time_in_ms(int val) {
29    fling_max_cancel_to_down_time_in_ms_ = val;
30  }
31  static int fling_max_tap_gap_time_in_ms() {
32    return fling_max_tap_gap_time_in_ms_;
33  }
34  static void set_fling_max_tap_gap_time_in_ms(int val) {
35    fling_max_tap_gap_time_in_ms_ = val;
36  }
37  static double long_press_time_in_seconds() {
38    return long_press_time_in_seconds_;
39  }
40  static double semi_long_press_time_in_seconds() {
41    return semi_long_press_time_in_seconds_;
42  }
43  static double max_distance_for_two_finger_tap_in_pixels() {
44    return max_distance_for_two_finger_tap_in_pixels_;
45  }
46  static void set_max_distance_for_two_finger_tap_in_pixels(double val) {
47    max_distance_for_two_finger_tap_in_pixels_ = val;
48  }
49  static void set_long_press_time_in_seconds(double val) {
50    long_press_time_in_seconds_ = val;
51  }
52  static void set_semi_long_press_time_in_seconds(double val) {
53    semi_long_press_time_in_seconds_ = val;
54  }
55  static double max_seconds_between_double_click() {
56    return max_seconds_between_double_click_;
57  }
58  static void set_max_seconds_between_double_click(double val) {
59    max_seconds_between_double_click_ = val;
60  }
61  static int max_separation_for_gesture_touches_in_pixels() {
62    return max_separation_for_gesture_touches_in_pixels_;
63  }
64  static void set_max_separation_for_gesture_touches_in_pixels(int val) {
65    max_separation_for_gesture_touches_in_pixels_ = val;
66  }
67  static float max_swipe_deviation_angle() {
68    return max_swipe_deviation_angle_;
69  }
70  static void set_max_swipe_deviation_angle(float val) {
71    max_swipe_deviation_angle_ = val;
72  }
73  static double max_touch_down_duration_in_seconds_for_click() {
74    return max_touch_down_duration_in_seconds_for_click_;
75  }
76  static void set_max_touch_down_duration_in_seconds_for_click(double val) {
77    max_touch_down_duration_in_seconds_for_click_ = val;
78  }
79  static double max_touch_move_in_pixels_for_click() {
80    return max_touch_move_in_pixels_for_click_;
81  }
82  static void set_max_touch_move_in_pixels_for_click(double val) {
83    max_touch_move_in_pixels_for_click_ = val;
84  }
85  static double max_distance_between_taps_for_double_tap() {
86    return max_distance_between_taps_for_double_tap_;
87  }
88  static void set_max_distance_between_taps_for_double_tap(double val) {
89    max_distance_between_taps_for_double_tap_ = val;
90  }
91  static double min_distance_for_pinch_scroll_in_pixels() {
92    return min_distance_for_pinch_scroll_in_pixels_;
93  }
94  static void set_min_distance_for_pinch_scroll_in_pixels(double val) {
95    min_distance_for_pinch_scroll_in_pixels_ = val;
96  }
97  static double min_pinch_update_distance_in_pixels() {
98    return min_pinch_update_distance_in_pixels_;
99  }
100  static void set_min_pinch_update_distance_in_pixels(double val) {
101    min_pinch_update_distance_in_pixels_ = val;
102  }
103  static float min_scroll_velocity() {
104    return min_scroll_velocity_;
105  }
106  static void set_min_scroll_velocity(float val) {
107    min_scroll_velocity_ = val;
108  }
109  static double min_swipe_speed() {
110    return min_swipe_speed_;
111  }
112  static void set_min_swipe_speed(double val) {
113    min_swipe_speed_ = val;
114  }
115  static int min_scaling_span_in_pixels() {
116    return min_scaling_span_in_pixels_;
117  };
118  static void set_min_scaling_span_in_pixels(int val) {
119    min_scaling_span_in_pixels_ = val;
120  }
121  static int show_press_delay_in_ms() {
122    return show_press_delay_in_ms_;
123  }
124  static int set_show_press_delay_in_ms(int val) {
125    return show_press_delay_in_ms_ = val;
126  }
127  static int scroll_debounce_interval_in_ms() {
128    return scroll_debounce_interval_in_ms_;
129  }
130  static int set_scroll_debounce_interval_in_ms(int val) {
131    return scroll_debounce_interval_in_ms_ = val;
132  }
133  static float fling_velocity_cap() {
134    return fling_velocity_cap_;
135  }
136  static void set_fling_velocity_cap(float val) {
137    fling_velocity_cap_ = val;
138  }
139  // TODO(davemoore): Move into chrome/browser/ui.
140  static int tab_scrub_activation_delay_in_ms() {
141    return tab_scrub_activation_delay_in_ms_;
142  }
143  static void set_tab_scrub_activation_delay_in_ms(int val) {
144    tab_scrub_activation_delay_in_ms_ = val;
145  }
146
147 private:
148  // These are listed in alphabetical order ignoring underscores, to
149  // align with the associated list of preferences in
150  // gesture_prefs_aura.cc. These two lists should be kept in sync.
151
152  // The default touch radius length used when the only information given
153  // by the device is the touch center.
154  static int default_radius_;
155
156  // The maximum allowed distance between two fingers for a two finger tap. If
157  // the distance between two fingers is greater than this value, we will not
158  // recognize a two finger tap.
159  static double max_distance_for_two_finger_tap_in_pixels_;
160
161  // Maximum time between a GestureFlingCancel and a mousedown such that the
162  // mousedown is considered associated with the cancel event.
163  static int fling_max_cancel_to_down_time_in_ms_;
164
165  // Maxium time between a mousedown/mouseup pair that is considered to be a
166  // suppressable tap.
167  static int fling_max_tap_gap_time_in_ms_;
168
169  static double long_press_time_in_seconds_;
170  static double semi_long_press_time_in_seconds_;
171  static double max_seconds_between_double_click_;
172  static double max_separation_for_gesture_touches_in_pixels_;
173  static float max_swipe_deviation_angle_;
174  static double max_touch_down_duration_in_seconds_for_click_;
175  static double max_touch_move_in_pixels_for_click_;
176  static double max_distance_between_taps_for_double_tap_;
177  static double min_distance_for_pinch_scroll_in_pixels_;
178  // Only used with --compensate-for-unstable-pinch-zoom.
179  static double min_pinch_update_distance_in_pixels_;
180  static float min_scroll_velocity_;
181  static double min_swipe_speed_;
182  static int min_scaling_span_in_pixels_;
183  static int show_press_delay_in_ms_;
184  static int scroll_debounce_interval_in_ms_;
185  static float fling_velocity_cap_;
186  // TODO(davemoore): Move into chrome/browser/ui.
187  static int tab_scrub_activation_delay_in_ms_;
188
189  DISALLOW_COPY_AND_ASSIGN(GestureConfiguration);
190};
191
192}  // namespace ui
193
194#endif  // UI_EVENTS_GESTURES_GESTURE_CONFIGURATION_H_
195