OLD | NEW |
(Empty) | |
| 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 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" |
| 6 |
| 7 #include "ui/events/gesture_detection/gesture_configuration.h" |
| 8 #include "ui/gfx/screen.h" |
| 9 |
| 10 namespace ui { |
| 11 namespace { |
| 12 |
| 13 GestureDetector::Config DefaultGestureDetectorConfig( |
| 14 GestureConfiguration* gesture_config) { |
| 15 GestureDetector::Config config; |
| 16 config.longpress_timeout = base::TimeDelta::FromMilliseconds( |
| 17 gesture_config->long_press_time_in_ms()); |
| 18 config.showpress_timeout = base::TimeDelta::FromMilliseconds( |
| 19 gesture_config->show_press_delay_in_ms()); |
| 20 config.double_tap_timeout = base::TimeDelta::FromMilliseconds( |
| 21 gesture_config->double_tap_timeout_in_ms()); |
| 22 config.touch_slop = gesture_config->max_touch_move_in_pixels_for_click(); |
| 23 config.double_tap_slop = |
| 24 gesture_config->max_distance_between_taps_for_double_tap(); |
| 25 config.minimum_fling_velocity = gesture_config->min_fling_velocity(); |
| 26 config.maximum_fling_velocity = gesture_config->max_fling_velocity(); |
| 27 config.swipe_enabled = gesture_config->swipe_enabled(); |
| 28 config.minimum_swipe_velocity = gesture_config->min_swipe_velocity(); |
| 29 config.maximum_swipe_deviation_angle = |
| 30 gesture_config->max_swipe_deviation_angle(); |
| 31 config.two_finger_tap_enabled = gesture_config->two_finger_tap_enabled(); |
| 32 config.two_finger_tap_max_separation = |
| 33 gesture_config->max_distance_for_two_finger_tap_in_pixels(); |
| 34 config.two_finger_tap_timeout = base::TimeDelta::FromMilliseconds( |
| 35 gesture_config->max_touch_down_duration_for_click_in_ms()); |
| 36 return config; |
| 37 } |
| 38 |
| 39 ScaleGestureDetector::Config DefaultScaleGestureDetectorConfig( |
| 40 GestureConfiguration* gesture_config) { |
| 41 ScaleGestureDetector::Config config; |
| 42 config.span_slop = gesture_config->span_slop(); |
| 43 config.min_scaling_touch_major = gesture_config->min_scaling_touch_major(); |
| 44 config.min_scaling_span = gesture_config->min_scaling_span_in_pixels(); |
| 45 config.min_pinch_update_span_delta = |
| 46 gesture_config->min_pinch_update_span_delta(); |
| 47 return config; |
| 48 } |
| 49 |
| 50 } // namespace |
| 51 |
| 52 GestureProvider::Config DefaultGestureProviderConfig() { |
| 53 GestureConfiguration* gesture_config = GestureConfiguration::GetInstance(); |
| 54 GestureProvider::Config config; |
| 55 gfx::Screen* screen = gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE); |
| 56 // |screen| is sometimes NULL during tests. |
| 57 if (screen) |
| 58 config.display = screen->GetPrimaryDisplay(); |
| 59 config.gesture_detector_config = DefaultGestureDetectorConfig(gesture_config); |
| 60 config.scale_gesture_detector_config = |
| 61 DefaultScaleGestureDetectorConfig(gesture_config); |
| 62 config.gesture_begin_end_types_enabled = |
| 63 gesture_config->gesture_begin_end_types_enabled(); |
| 64 config.min_gesture_bounds_length = |
| 65 gesture_config->min_gesture_bounds_length(); |
| 66 config.max_gesture_bounds_length = |
| 67 gesture_config->max_gesture_bounds_length(); |
| 68 return config; |
| 69 } |
| 70 |
| 71 } // namespace ui |
OLD | NEW |