Chromium Code Reviews| 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 GestureConfiguration* gesture_config; | |
|
jdduke (slow)
2014/10/23 19:11:41
No need to cache this, just pass it as an arg to D
| |
| 13 | |
| 14 GestureDetector::Config DefaultGestureDetectorConfig() { | |
| 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 ScaleGestureDetector::Config config; | |
| 41 config.span_slop = gesture_config->span_slop(); | |
| 42 config.min_scaling_touch_major = gesture_config->min_scaling_touch_major(); | |
| 43 config.min_scaling_span = gesture_config->min_scaling_span_in_pixels(); | |
| 44 config.min_pinch_update_span_delta = | |
| 45 gesture_config->min_pinch_update_span_delta(); | |
| 46 return config; | |
| 47 } | |
| 48 | |
| 49 } // namespace | |
| 50 | |
| 51 GestureProvider::Config DefaultGestureProviderConfig() { | |
| 52 gesture_config = GestureConfiguration::GetInstance(); | |
| 53 GestureProvider::Config config; | |
| 54 gfx::Screen* screen = gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE); | |
| 55 // |screen| is sometimes NULL during tests. | |
| 56 if (screen) | |
| 57 config.display = screen->GetPrimaryDisplay(); | |
| 58 config.gesture_detector_config = DefaultGestureDetectorConfig(); | |
| 59 config.scale_gesture_detector_config = DefaultScaleGestureDetectorConfig(); | |
| 60 config.gesture_begin_end_types_enabled = | |
| 61 gesture_config->gesture_begin_end_types_enabled(); | |
| 62 config.min_gesture_bounds_length = | |
| 63 gesture_config->min_gesture_bounds_length(); | |
| 64 config.max_gesture_bounds_length = | |
| 65 gesture_config->max_gesture_bounds_length(); | |
| 66 return config; | |
| 67 } | |
| 68 | |
| 69 } // namespace ui | |
| OLD | NEW |