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.
5 #include "ui/events/gesture_detection/gesture_config_helper.h"
7 #include "ui/events/gestures/gesture_configuration.h"
8 #include "ui/gfx/screen.h"
12 GestureDetector::Config
DefaultGestureDetectorConfig() {
13 GestureDetector::Config config
;
15 config
.longpress_timeout
= base::TimeDelta::FromMilliseconds(
16 GestureConfiguration::long_press_time_in_seconds() * 1000.);
17 config
.tap_timeout
= base::TimeDelta::FromMilliseconds(
18 GestureConfiguration::show_press_delay_in_ms());
19 config
.double_tap_timeout
= base::TimeDelta::FromMilliseconds(
20 GestureConfiguration::semi_long_press_time_in_seconds() * 1000.);
21 config
.scaled_touch_slop
=
22 GestureConfiguration::max_touch_move_in_pixels_for_click();
23 config
.scaled_double_tap_slop
=
24 GestureConfiguration::max_distance_between_taps_for_double_tap();
25 config
.scaled_minimum_fling_velocity
=
26 GestureConfiguration::min_scroll_velocity();
27 config
.scaled_maximum_fling_velocity
=
28 GestureConfiguration::fling_velocity_cap();
33 ScaleGestureDetector::Config
DefaultScaleGestureDetectorConfig() {
34 ScaleGestureDetector::Config config
;
36 config
.gesture_detector_config
= DefaultGestureDetectorConfig();
37 config
.quick_scale_enabled
= false;
38 config
.min_scaling_touch_major
= GestureConfiguration::default_radius() / 2;
39 config
.min_scaling_span
=
40 GestureConfiguration::min_distance_for_pinch_scroll_in_pixels();
44 SnapScrollController::Config
DefaultSnapScrollControllerConfig() {
45 SnapScrollController::Config config
;
47 const gfx::Display
& display
=
48 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
50 config
.screen_width_pixels
= display
.GetSizeInPixel().width();
51 config
.screen_height_pixels
= display
.GetSizeInPixel().height();
52 config
.device_scale_factor
= display
.device_scale_factor();
57 GestureProvider::Config
DefaultGestureHandlerConfig() {
58 GestureProvider::Config config
;
59 config
.gesture_detector_config
= DefaultGestureDetectorConfig();
60 config
.scale_gesture_detector_config
= DefaultScaleGestureDetectorConfig();
61 config
.snap_scroll_controller_config
= DefaultSnapScrollControllerConfig();