OLD | NEW |
(Empty) | |
| 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 #include "ui/events/gesture_detection/gesture_configuration.h" |
| 6 |
| 7 namespace ui { |
| 8 |
| 9 GestureConfiguration::GestureConfiguration() |
| 10 : default_radius_(25), |
| 11 max_distance_for_two_finger_tap_in_pixels_(300), |
| 12 fling_max_cancel_to_down_time_in_ms_(400), |
| 13 fling_max_tap_gap_time_in_ms_(200), |
| 14 fling_velocity_cap_(17000.0f), |
| 15 tab_scrub_activation_delay_in_ms_(200), |
| 16 long_press_timeout_in_ms_(1000), |
| 17 semi_long_press_time_in_seconds_(0.4), |
| 18 max_seconds_between_double_click_(0.7), |
| 19 max_separation_for_gesture_touches_in_pixels_(150), |
| 20 max_swipe_deviation_angle_(20), |
| 21 max_touch_down_duration_in_seconds_for_click_(0.8), |
| 22 max_touch_move_in_pixels_for_click_(15), |
| 23 max_distance_between_taps_for_double_tap_(20), |
| 24 min_distance_for_pinch_scroll_in_pixels_(20), |
| 25 min_pinch_update_distance_in_pixels_(5), |
| 26 min_scroll_velocity_(30.0f), |
| 27 min_swipe_speed_(20), |
| 28 |
| 29 // If this is too small, we currently can get single finger pinch zoom. |
| 30 // See |
| 31 // crbug.com/357237 for details. |
| 32 min_scaling_span_in_pixels_(125), |
| 33 show_press_delay_in_ms_(150) { |
| 34 // TODO(jdduke): Disable and remove entirely when issues with intermittent |
| 35 // scroll end detection on the Pixel are resolved, crbug.com/353702. |
| 36 #if defined(OS_CHROMEOS) |
| 37 scroll_debounce_interval_in_ms_ = 30; |
| 38 #else |
| 39 scroll_debounce_interval_in_ms_ = 0; |
| 40 #endif |
| 41 } |
| 42 |
| 43 GestureConfiguration::~GestureConfiguration() { |
| 44 } |
| 45 |
| 46 GestureDetector::Config GestureConfiguration::DefaultGestureDetectorConfig() { |
| 47 GestureDetector::Config config; |
| 48 config.longpress_timeout = |
| 49 base::TimeDelta::FromMilliseconds(long_press_timeout_in_ms()); |
| 50 config.showpress_timeout = |
| 51 base::TimeDelta::FromMilliseconds(show_press_delay_in_ms()); |
| 52 config.double_tap_timeout = |
| 53 base::TimeDelta::FromMilliseconds(double_tap_timeout_in_ms()); |
| 54 config.touch_slop = max_touch_move_in_pixels_for_click(); |
| 55 config.double_tap_slop = max_distance_between_taps_for_double_tap(); |
| 56 config.minimum_fling_velocity = min_scroll_velocity(); |
| 57 config.maximum_fling_velocity = fling_velocity_cap(); |
| 58 |
| 59 return config; |
| 60 } |
| 61 |
| 62 ScaleGestureDetector::Config |
| 63 GestureConfiguration::DefaultScaleGestureDetectorConfig() { |
| 64 ScaleGestureDetector::Config config; |
| 65 config.span_slop = span_slop_in_pixels(); |
| 66 config.min_scaling_touch_major = min_scaling_touch_major_in_pixels(); |
| 67 config.min_scaling_span = min_scaling_span_in_pixels(); |
| 68 config.min_pinch_update_span_delta = min_pinch_update_distance_in_pixels(); |
| 69 return config; |
| 70 } |
| 71 |
| 72 int GestureConfiguration::default_radius() { |
| 73 return default_radius_; |
| 74 } |
| 75 int GestureConfiguration::fling_max_cancel_to_down_time_in_ms() { |
| 76 return fling_max_cancel_to_down_time_in_ms_; |
| 77 } |
| 78 int GestureConfiguration::fling_max_tap_gap_time_in_ms() { |
| 79 return fling_max_tap_gap_time_in_ms_; |
| 80 } |
| 81 int GestureConfiguration::long_press_timeout_in_ms() { |
| 82 return long_press_timeout_in_ms_; |
| 83 } |
| 84 double GestureConfiguration::semi_long_press_time_in_seconds() { |
| 85 return semi_long_press_time_in_seconds_; |
| 86 } |
| 87 double GestureConfiguration::max_distance_for_two_finger_tap_in_pixels() { |
| 88 return max_distance_for_two_finger_tap_in_pixels_; |
| 89 } |
| 90 double GestureConfiguration::max_seconds_between_double_click() { |
| 91 return max_seconds_between_double_click_; |
| 92 } |
| 93 int GestureConfiguration::max_separation_for_gesture_touches_in_pixels() { |
| 94 return max_separation_for_gesture_touches_in_pixels_; |
| 95 } |
| 96 float GestureConfiguration::max_swipe_deviation_angle() { |
| 97 return max_swipe_deviation_angle_; |
| 98 } |
| 99 double GestureConfiguration::max_touch_down_duration_in_seconds_for_click() { |
| 100 return max_touch_down_duration_in_seconds_for_click_; |
| 101 } |
| 102 double GestureConfiguration::max_touch_move_in_pixels_for_click() { |
| 103 return max_touch_move_in_pixels_for_click_; |
| 104 } |
| 105 double GestureConfiguration::max_distance_between_taps_for_double_tap() { |
| 106 return max_distance_between_taps_for_double_tap_; |
| 107 } |
| 108 double GestureConfiguration::min_distance_for_pinch_scroll_in_pixels() { |
| 109 return min_distance_for_pinch_scroll_in_pixels_; |
| 110 } |
| 111 double GestureConfiguration::min_pinch_update_distance_in_pixels() { |
| 112 return min_pinch_update_distance_in_pixels_; |
| 113 } |
| 114 float GestureConfiguration::min_scroll_velocity() { |
| 115 return min_scroll_velocity_; |
| 116 } |
| 117 double GestureConfiguration::min_swipe_speed() { |
| 118 return min_swipe_speed_; |
| 119 } |
| 120 int GestureConfiguration::min_scaling_span_in_pixels() { |
| 121 return min_scaling_span_in_pixels_; |
| 122 } |
| 123 |
| 124 int GestureConfiguration::show_press_delay_in_ms() { |
| 125 return show_press_delay_in_ms_; |
| 126 } |
| 127 int GestureConfiguration::scroll_debounce_interval_in_ms() { |
| 128 return scroll_debounce_interval_in_ms_; |
| 129 } |
| 130 float GestureConfiguration::fling_velocity_cap() { |
| 131 return fling_velocity_cap_; |
| 132 } |
| 133 // TODO(davemoore): Move into chrome/browser/ui. |
| 134 int GestureConfiguration::tab_scrub_activation_delay_in_ms() { |
| 135 return tab_scrub_activation_delay_in_ms_; |
| 136 } |
| 137 |
| 138 int GestureConfiguration::double_tap_timeout_in_ms() { |
| 139 return double_tap_timeout_in_ms_; |
| 140 } |
| 141 |
| 142 int GestureConfiguration::min_scaling_touch_major_in_pixels() { |
| 143 return min_scaling_touch_major_in_pixels_; |
| 144 } |
| 145 |
| 146 int GestureConfiguration::touch_slop_in_pixels() { |
| 147 return touch_slop_in_pixels_; |
| 148 } |
| 149 |
| 150 int GestureConfiguration::span_slop_in_pixels() { |
| 151 return span_slop_in_pixels_; |
| 152 } |
| 153 |
| 154 } // namespace ui |
OLD | NEW |