Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / ui / events / gesture_detection / gesture_configuration.h
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.
4
5 #ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_CONFIGURATION_H_
6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_CONFIGURATION_H_
7
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"
12
13 namespace ui {
14
15 class GESTURE_DETECTION_EXPORT GestureConfiguration {
16  public:
17   // Returns the singleton GestureConfiguration.
18   static GestureConfiguration* GetInstance();
19
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_;
26   }
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_;
30   }
31   void set_fling_max_cancel_to_down_time_in_ms(int val) {
32     fling_max_cancel_to_down_time_in_ms_ = val;
33   }
34   int fling_max_tap_gap_time_in_ms() const {
35     return fling_max_tap_gap_time_in_ms_;
36   }
37   void set_fling_max_tap_gap_time_in_ms(int val) {
38     fling_max_tap_gap_time_in_ms_ = val;
39   }
40   bool gesture_begin_end_types_enabled() const {
41     return gesture_begin_end_types_enabled_;
42   }
43   int long_press_time_in_ms() const { return long_press_time_in_ms_; }
44   void set_long_press_time_in_ms(int val) { long_press_time_in_ms_ = val; }
45   float max_distance_between_taps_for_double_tap() const {
46     return max_distance_between_taps_for_double_tap_;
47   }
48   void set_max_distance_between_taps_for_double_tap(float val) {
49     max_distance_between_taps_for_double_tap_ = val;
50   }
51   float max_distance_for_two_finger_tap_in_pixels() const {
52     return max_distance_for_two_finger_tap_in_pixels_;
53   }
54   void set_max_distance_for_two_finger_tap_in_pixels(float val) {
55     max_distance_for_two_finger_tap_in_pixels_ = val;
56   }
57   float max_fling_velocity() const { return max_fling_velocity_; }
58   void set_max_fling_velocity(float val) { max_fling_velocity_ = val; }
59   float max_gesture_bounds_length() const {
60     return max_gesture_bounds_length_;
61   }
62   float max_separation_for_gesture_touches_in_pixels() const {
63     return max_separation_for_gesture_touches_in_pixels_;
64   }
65   void set_max_separation_for_gesture_touches_in_pixels(float val) {
66     max_separation_for_gesture_touches_in_pixels_ = val;
67   }
68   float max_swipe_deviation_angle() const {
69     return max_swipe_deviation_angle_;
70   }
71   int max_time_between_double_click_in_ms() const {
72     return max_time_between_double_click_in_ms_;
73   }
74   void set_max_time_between_double_click_in_ms(int val) {
75     max_time_between_double_click_in_ms_ = val;
76   }
77   int max_touch_down_duration_for_click_in_ms() const {
78     return max_touch_down_duration_for_click_in_ms_;
79   }
80   void set_max_touch_down_duration_for_click_in_ms(int val) {
81     max_touch_down_duration_for_click_in_ms_ = val;
82   }
83   float max_touch_move_in_pixels_for_click() const {
84     return max_touch_move_in_pixels_for_click_;
85   }
86   void set_max_touch_move_in_pixels_for_click(float val) {
87     max_touch_move_in_pixels_for_click_ = val;
88     span_slop_ = max_touch_move_in_pixels_for_click_ * 2;
89   }
90   float min_distance_for_pinch_scroll_in_pixels() const {
91     return min_distance_for_pinch_scroll_in_pixels_;
92   }
93   void set_min_distance_for_pinch_scroll_in_pixels(float val) {
94     min_distance_for_pinch_scroll_in_pixels_ = val;
95   }
96   float min_fling_velocity() const { return min_fling_velocity_; }
97   float min_gesture_bounds_length() const {
98     return min_gesture_bounds_length_;
99   }
100   float min_pinch_update_span_delta() const {
101     return min_pinch_update_span_delta_;
102   }
103   void set_min_pinch_update_span_delta(float val) {
104     min_pinch_update_span_delta_ = val;
105   }
106   float min_scaling_span_in_pixels() const {
107     return min_scaling_span_in_pixels_;
108   }
109   float min_scaling_touch_major() const { return min_scaling_touch_major_; }
110   float min_swipe_velocity() const { return min_swipe_velocity_; }
111   void set_min_swipe_velocity(float val) { min_swipe_velocity_ = val; }
112   int scroll_debounce_interval_in_ms() const {
113     return scroll_debounce_interval_in_ms_;
114   }
115   int set_scroll_debounce_interval_in_ms(int val) {
116     return scroll_debounce_interval_in_ms_ = val;
117   }
118   int semi_long_press_time_in_ms() const {
119     return semi_long_press_time_in_ms_;
120   }
121   VelocityTracker::Strategy velocity_tracker_strategy() const {
122     return velocity_tracker_strategy_;
123   }
124   void set_semi_long_press_time_in_ms(int val) {
125     semi_long_press_time_in_ms_ = val;
126     double_tap_timeout_in_ms_ = val;
127   }
128   int show_press_delay_in_ms() const { return show_press_delay_in_ms_; }
129   int set_show_press_delay_in_ms(int val) {
130     return show_press_delay_in_ms_ = val;
131   }
132   float span_slop() const { return span_slop_; }
133   bool swipe_enabled() const { return swipe_enabled_; }
134
135   // TODO(davemoore): Move into chrome/browser/ui.
136   int tab_scrub_activation_delay_in_ms() const {
137     return tab_scrub_activation_delay_in_ms_;
138   }
139   void set_tab_scrub_activation_delay_in_ms(int val) {
140     tab_scrub_activation_delay_in_ms_ = val;
141   }
142   bool two_finger_tap_enabled() const { return two_finger_tap_enabled_; }
143
144  protected:
145   GestureConfiguration();
146   virtual ~GestureConfiguration();
147
148   void set_double_tap_timeout_in_ms(int val) {
149     double_tap_timeout_in_ms_ = val;
150   }
151   void set_gesture_begin_end_types_enabled(bool val) {
152     gesture_begin_end_types_enabled_ = val;
153   }
154   void set_max_gesture_bounds_length(float val) {
155     max_gesture_bounds_length_ = val;
156   }
157   void set_max_swipe_deviation_angle(float val) {
158     max_swipe_deviation_angle_ = val;
159   }
160   void set_min_fling_velocity(float val) { min_fling_velocity_ = val; }
161   void set_min_gesture_bounds_length(float val) {
162     min_gesture_bounds_length_ = val;
163   }
164   void set_min_scaling_span_in_pixels(float val) {
165     min_scaling_span_in_pixels_ = val;
166   }
167   void set_min_scaling_touch_major(float val) {
168     min_scaling_touch_major_ = val;
169   }
170   void set_velocity_tracker_strategy(VelocityTracker::Strategy val) {
171     velocity_tracker_strategy_ = val;
172   }
173   void set_span_slop(float val) { span_slop_ = val; }
174   void set_swipe_enabled(bool val) { swipe_enabled_ = val; }
175   void set_two_finger_tap_enabled(bool val) { two_finger_tap_enabled_ = val; }
176
177  private:
178   // These are listed in alphabetical order ignoring underscores.
179
180   // The default touch radius length used when the only information given
181   // by the device is the touch center.
182   float default_radius_;
183   int double_tap_timeout_in_ms_;
184   // Maximum time between a GestureFlingCancel and a mousedown such that the
185   // mousedown is considered associated with the cancel event.
186   int fling_max_cancel_to_down_time_in_ms_;
187
188   // Maxium time between a mousedown/mouseup pair that is considered to be a
189   // suppressable tap.
190   int fling_max_tap_gap_time_in_ms_;
191   bool gesture_begin_end_types_enabled_;
192   int long_press_time_in_ms_;
193   float max_distance_between_taps_for_double_tap_;
194
195   // The maximum allowed distance between two fingers for a two finger tap. If
196   // the distance between two fingers is greater than this value, we will not
197   // recognize a two finger tap.
198   float max_distance_for_two_finger_tap_in_pixels_;
199   float max_fling_velocity_;
200   float max_gesture_bounds_length_;
201   float max_separation_for_gesture_touches_in_pixels_;
202   float max_swipe_deviation_angle_;
203   int max_time_between_double_click_in_ms_;
204   int max_touch_down_duration_for_click_in_ms_;
205   float max_touch_move_in_pixels_for_click_;
206   float min_distance_for_pinch_scroll_in_pixels_;
207   float min_fling_velocity_;
208   float min_gesture_bounds_length_;
209   // Only used with --compensate-for-unstable-pinch-zoom.
210   float min_pinch_update_span_delta_;
211   float min_scaling_span_in_pixels_;
212   float min_scaling_touch_major_;
213   float min_swipe_velocity_;
214   VelocityTracker::Strategy velocity_tracker_strategy_;
215   int scroll_debounce_interval_in_ms_;
216   int semi_long_press_time_in_ms_;
217   int show_press_delay_in_ms_;
218   float span_slop_;
219   bool swipe_enabled_;
220
221   // TODO(davemoore): Move into chrome/browser/ui.
222   int tab_scrub_activation_delay_in_ms_;
223   bool two_finger_tap_enabled_;
224
225   friend struct DefaultSingletonTraits<GestureConfiguration>;
226   DISALLOW_COPY_AND_ASSIGN(GestureConfiguration);
227 };
228
229 }  // namespace ui
230
231 #endif  // UI_EVENTS_GESTURE_DETECTION_GESTURE_CONFIGURATION_H_