Support GestureBegin and GestureEnd in ui::GestureProvider
[chromium-blink-merge.git] / ui / events / gesture_detection / gesture_config_helper_aura.cc
blob25cce58ee290e35655aa62c18f9019a3f2f344f2
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"
10 namespace ui {
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.showpress_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();
30 return config;
33 ScaleGestureDetector::Config DefaultScaleGestureDetectorConfig() {
34 ScaleGestureDetector::Config config;
36 config.gesture_detector_config = DefaultGestureDetectorConfig();
37 config.min_scaling_touch_major = GestureConfiguration::default_radius() / 2;
38 config.min_scaling_span =
39 GestureConfiguration::min_distance_for_pinch_scroll_in_pixels();
40 return config;
43 SnapScrollController::Config DefaultSnapScrollControllerConfig() {
44 SnapScrollController::Config config;
46 const gfx::Display& display =
47 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
49 config.screen_width_pixels = display.GetSizeInPixel().width();
50 config.screen_height_pixels = display.GetSizeInPixel().height();
51 config.device_scale_factor = display.device_scale_factor();
53 return config;
56 GestureProvider::Config DefaultGestureProviderConfig() {
57 GestureProvider::Config config;
58 config.gesture_detector_config = DefaultGestureDetectorConfig();
59 config.scale_gesture_detector_config = DefaultScaleGestureDetectorConfig();
60 config.snap_scroll_controller_config = DefaultSnapScrollControllerConfig();
61 config.gesture_begin_end_types_enabled = true;
62 return config;
65 } // namespace ui