Home | History | Annotate | Download | only in gestures
      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_BASE_GESTURES_GESTURE_CONFIGURATION_H_
      6 #define UI_BASE_GESTURES_GESTURE_CONFIGURATION_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "ui/base/ui_export.h"
     10 
     11 namespace 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 
     17 class UI_EXPORT GestureConfiguration {
     18  public:
     19   // Number of parameters in the array of parameters for the fling acceleration
     20   // curve.
     21   static const int NumAccelParams = 4;
     22 
     23   // Ordered alphabetically ignoring underscores, to align with the
     24   // associated list of prefs in gesture_prefs_aura.cc.
     25   static int default_radius() {
     26     return default_radius_;
     27   }
     28   static void set_default_radius(int radius) { default_radius_ = radius; }
     29   static int fling_max_cancel_to_down_time_in_ms() {
     30     return fling_max_cancel_to_down_time_in_ms_;
     31   }
     32   static void set_fling_max_cancel_to_down_time_in_ms(int val) {
     33     fling_max_cancel_to_down_time_in_ms_ = val;
     34   }
     35   static int fling_max_tap_gap_time_in_ms() {
     36     return fling_max_tap_gap_time_in_ms_;
     37   }
     38   static void set_fling_max_tap_gap_time_in_ms(int val) {
     39     fling_max_tap_gap_time_in_ms_ = val;
     40   }
     41   static double long_press_time_in_seconds() {
     42     return long_press_time_in_seconds_;
     43   }
     44   static double semi_long_press_time_in_seconds() {
     45     return semi_long_press_time_in_seconds_;
     46   }
     47   static double max_distance_for_two_finger_tap_in_pixels() {
     48     return max_distance_for_two_finger_tap_in_pixels_;
     49   }
     50   static void set_max_distance_for_two_finger_tap_in_pixels(double val) {
     51     max_distance_for_two_finger_tap_in_pixels_ = val;
     52   }
     53   static int max_radius() {
     54     return max_radius_;
     55   }
     56   static void set_long_press_time_in_seconds(double val) {
     57     long_press_time_in_seconds_ = val;
     58   }
     59   static void set_semi_long_press_time_in_seconds(double val) {
     60     semi_long_press_time_in_seconds_ = val;
     61   }
     62   static double max_seconds_between_double_click() {
     63     return max_seconds_between_double_click_;
     64   }
     65   static void set_max_seconds_between_double_click(double val) {
     66     max_seconds_between_double_click_ = val;
     67   }
     68   static int max_separation_for_gesture_touches_in_pixels() {
     69     return max_separation_for_gesture_touches_in_pixels_;
     70   }
     71   static void set_max_separation_for_gesture_touches_in_pixels(int val) {
     72     max_separation_for_gesture_touches_in_pixels_ = val;
     73   }
     74   static double max_swipe_deviation_ratio() {
     75     return max_swipe_deviation_ratio_;
     76   }
     77   static void set_max_swipe_deviation_ratio(double val) {
     78     max_swipe_deviation_ratio_ = val;
     79   }
     80   static double max_touch_down_duration_in_seconds_for_click() {
     81     return max_touch_down_duration_in_seconds_for_click_;
     82   }
     83   static void set_max_touch_down_duration_in_seconds_for_click(double val) {
     84     max_touch_down_duration_in_seconds_for_click_ = val;
     85   }
     86   static double max_touch_move_in_pixels_for_click() {
     87     return max_touch_move_in_pixels_for_click_;
     88   }
     89   static void set_max_touch_move_in_pixels_for_click(double val) {
     90     max_touch_move_in_pixels_for_click_ = val;
     91   }
     92   static double max_distance_between_taps_for_double_tap() {
     93     return max_distance_between_taps_for_double_tap_;
     94   }
     95   static void set_max_distance_between_taps_for_double_tap(double val) {
     96     max_distance_between_taps_for_double_tap_ = val;
     97   }
     98   static double min_distance_for_pinch_scroll_in_pixels() {
     99     return min_distance_for_pinch_scroll_in_pixels_;
    100   }
    101   static void set_min_distance_for_pinch_scroll_in_pixels(double val) {
    102     min_distance_for_pinch_scroll_in_pixels_ = val;
    103   }
    104   static double min_flick_speed_squared() {
    105     return min_flick_speed_squared_;
    106   }
    107   static void set_min_flick_speed_squared(double val) {
    108     min_flick_speed_squared_ = val;
    109   }
    110   static double min_pinch_update_distance_in_pixels() {
    111     return min_pinch_update_distance_in_pixels_;
    112   }
    113   static void set_min_pinch_update_distance_in_pixels(double val) {
    114     min_pinch_update_distance_in_pixels_ = val;
    115   }
    116   static double min_rail_break_velocity() {
    117     return min_rail_break_velocity_;
    118   }
    119   static void set_min_rail_break_velocity(double val) {
    120     min_rail_break_velocity_ = val;
    121   }
    122   static double min_scroll_delta_squared() {
    123     return min_scroll_delta_squared_;
    124   }
    125   static void set_min_scroll_delta_squared(double val) {
    126     min_scroll_delta_squared_ = val;
    127   }
    128   static int min_scroll_successive_velocity_events() {
    129     return min_scroll_successive_velocity_events_;
    130   }
    131   static void set_min_scroll_successive_velocity_events(int val) {
    132     min_scroll_successive_velocity_events_ = val;
    133   }
    134   static float min_scroll_velocity() {
    135     return min_scroll_velocity_;
    136   }
    137   static void set_min_scroll_velocity(float val) {
    138     min_scroll_velocity_ = val;
    139   }
    140   static double min_swipe_speed() {
    141     return min_swipe_speed_;
    142   }
    143   static void set_min_swipe_speed(double val) {
    144     min_swipe_speed_ = val;
    145   }
    146   static double min_touch_down_duration_in_seconds_for_click() {
    147     return min_touch_down_duration_in_seconds_for_click_;
    148   }
    149   static void set_min_touch_down_duration_in_seconds_for_click(double val) {
    150     min_touch_down_duration_in_seconds_for_click_ = val;
    151   }
    152   static int points_buffered_for_velocity() {
    153     return points_buffered_for_velocity_;
    154   }
    155   static void set_points_buffered_for_velocity(int val) {
    156     points_buffered_for_velocity_ = val;
    157   }
    158   static double rail_break_proportion() {
    159     return rail_break_proportion_;
    160   }
    161   static void set_rail_break_proportion(double val) {
    162     rail_break_proportion_ = val;
    163   }
    164   static double rail_start_proportion() {
    165     return rail_start_proportion_;
    166   }
    167   static void set_rail_start_proportion(double val) {
    168     rail_start_proportion_ = val;
    169   }
    170   static double scroll_prediction_seconds() {
    171     return scroll_prediction_seconds_;
    172   }
    173   static void set_scroll_prediction_seconds(double val) {
    174     scroll_prediction_seconds_ = val;
    175   }
    176   static void set_fling_acceleration_curve_coefficients(int i, float val) {
    177     fling_acceleration_curve_coefficients_[i] = val;
    178   }
    179   static float fling_acceleration_curve_coefficients(int i) {
    180     return fling_acceleration_curve_coefficients_[i];
    181   }
    182   static float fling_velocity_cap() {
    183     return fling_velocity_cap_;
    184   }
    185   static void set_fling_velocity_cap(float val) {
    186     fling_velocity_cap_ = val;
    187   }
    188   // TODO(davemoore): Move into chrome/browser/ui.
    189   static int tab_scrub_activation_delay_in_ms() {
    190     return tab_scrub_activation_delay_in_ms_;
    191   }
    192   static void set_tab_scrub_activation_delay_in_ms(int val) {
    193     tab_scrub_activation_delay_in_ms_ = val;
    194   }
    195 
    196  private:
    197   // These are listed in alphabetical order ignoring underscores, to
    198   // align with the associated list of preferences in
    199   // gesture_prefs_aura.cc. These two lists should be kept in sync.
    200 
    201   // The default touch radius length used when the only information given
    202   // by the device is the touch center.
    203   static int default_radius_;
    204 
    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   static double max_distance_for_two_finger_tap_in_pixels_;
    209 
    210   // The maximum allowed size for the radius of a touch region used in
    211   // forming an ET_GESTURE_TAP event.
    212   static int max_radius_;
    213 
    214   // Maximum time between a GestureFlingCancel and a mousedown such that the
    215   // mousedown is considered associated with the cancel event.
    216   static int fling_max_cancel_to_down_time_in_ms_;
    217 
    218   // Maxium time between a mousedown/mouseup pair that is considered to be a
    219   // suppressable tap.
    220   static int fling_max_tap_gap_time_in_ms_;
    221 
    222   static double long_press_time_in_seconds_;
    223   static double semi_long_press_time_in_seconds_;
    224   static double max_seconds_between_double_click_;
    225   static double max_separation_for_gesture_touches_in_pixels_;
    226   static double max_swipe_deviation_ratio_;
    227   static double max_touch_down_duration_in_seconds_for_click_;
    228   static double max_touch_move_in_pixels_for_click_;
    229   static double max_distance_between_taps_for_double_tap_;
    230   static double min_distance_for_pinch_scroll_in_pixels_;
    231   static double min_flick_speed_squared_;
    232   static double min_pinch_update_distance_in_pixels_;
    233   static double min_rail_break_velocity_;
    234   static double min_scroll_delta_squared_;
    235   // TODO(rjkroege): Expose these in chrome://gesture
    236   static int min_scroll_successive_velocity_events_;
    237   static float min_scroll_velocity_;
    238   static double min_swipe_speed_;
    239   static double min_touch_down_duration_in_seconds_for_click_;
    240   static int points_buffered_for_velocity_;
    241   static double rail_break_proportion_;
    242   static double rail_start_proportion_;
    243   static double scroll_prediction_seconds_;
    244   static float fling_acceleration_curve_coefficients_[NumAccelParams];
    245   static float fling_velocity_cap_;
    246   // TODO(davemoore): Move into chrome/browser/ui.
    247   static int tab_scrub_activation_delay_in_ms_;
    248 
    249   DISALLOW_COPY_AND_ASSIGN(GestureConfiguration);
    250 };
    251 
    252 }  // namespace ui
    253 
    254 #endif  // UI_BASE_GESTURES_GESTURE_CONFIGURATION_H_
    255