| 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_config_helper.h" | |
| 6 | |
| 7 #include <cmath> | |
| 8 | |
| 9 #include "base/command_line.h" | |
| 10 #include "ui/events/event_switches.h" | |
| 11 #include "ui/events/gestures/gesture_configuration.h" | |
| 12 #include "ui/gfx/screen.h" | |
| 13 | |
| 14 namespace ui { | |
| 15 namespace { | |
| 16 | |
| 17 GestureDetector::Config DefaultGestureDetectorConfig() { | |
| 18 GestureDetector::Config config; | |
| 19 | |
| 20 config.longpress_timeout = base::TimeDelta::FromMilliseconds( | |
| 21 GestureConfiguration::long_press_time_in_seconds() * 1000.); | |
| 22 config.showpress_timeout = base::TimeDelta::FromMilliseconds( | |
| 23 GestureConfiguration::show_press_delay_in_ms()); | |
| 24 config.double_tap_timeout = base::TimeDelta::FromMilliseconds( | |
| 25 GestureConfiguration::semi_long_press_time_in_seconds() * 1000.); | |
| 26 config.touch_slop = | |
| 27 GestureConfiguration::max_touch_move_in_pixels_for_click(); | |
| 28 config.double_tap_slop = | |
| 29 GestureConfiguration::max_distance_between_taps_for_double_tap(); | |
| 30 config.minimum_fling_velocity = | |
| 31 GestureConfiguration::min_scroll_velocity(); | |
| 32 config.maximum_fling_velocity = GestureConfiguration::fling_velocity_cap(); | |
| 33 config.swipe_enabled = true; | |
| 34 config.minimum_swipe_velocity = GestureConfiguration::min_swipe_speed(); | |
| 35 config.maximum_swipe_deviation_angle = | |
| 36 GestureConfiguration::max_swipe_deviation_angle(); | |
| 37 config.two_finger_tap_enabled = true; | |
| 38 config.two_finger_tap_max_separation = | |
| 39 GestureConfiguration::max_distance_for_two_finger_tap_in_pixels(); | |
| 40 config.two_finger_tap_timeout = base::TimeDelta::FromMilliseconds( | |
| 41 GestureConfiguration::max_touch_down_duration_in_seconds_for_click() * | |
| 42 1000.); | |
| 43 | |
| 44 return config; | |
| 45 } | |
| 46 | |
| 47 ScaleGestureDetector::Config DefaultScaleGestureDetectorConfig() { | |
| 48 ScaleGestureDetector::Config config; | |
| 49 double min_pinch_update_distance = | |
| 50 CommandLine::ForCurrentProcess()->HasSwitch( | |
| 51 switches::kCompensateForUnstablePinchZoom) | |
| 52 ? GestureConfiguration::min_pinch_update_distance_in_pixels() | |
| 53 : 0; | |
| 54 | |
| 55 config.span_slop = | |
| 56 GestureConfiguration::max_touch_move_in_pixels_for_click() * 2; | |
| 57 config.min_scaling_touch_major = GestureConfiguration::default_radius() * 2; | |
| 58 config.min_scaling_span = GestureConfiguration::min_scaling_span_in_pixels(); | |
| 59 config.min_pinch_update_span_delta = min_pinch_update_distance; | |
| 60 return config; | |
| 61 } | |
| 62 | |
| 63 } // namespace | |
| 64 | |
| 65 GestureProvider::Config DefaultGestureProviderConfig() { | |
| 66 GestureProvider::Config config; | |
| 67 gfx::Screen* screen = gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE); | |
| 68 // |screen| is sometimes NULL during tests. | |
| 69 if (screen) | |
| 70 config.display = screen->GetPrimaryDisplay(); | |
| 71 config.gesture_detector_config = DefaultGestureDetectorConfig(); | |
| 72 config.scale_gesture_detector_config = DefaultScaleGestureDetectorConfig(); | |
| 73 config.gesture_begin_end_types_enabled = true; | |
| 74 // Half the size of the default touch length is a reasonable minimum. | |
| 75 config.min_gesture_bounds_length = GestureConfiguration::default_radius(); | |
| 76 return config; | |
| 77 } | |
| 78 | |
| 79 } // namespace ui | |
| OLD | NEW |