Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: ui/events/gesture_detection/gesture_config_helper_aura.cc

Issue 613373004: Adopt ui::GestureConfiguration on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Copyright Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_ms());
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_ms());
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_for_click_in_ms());
42
43 return config;
44 }
45
46 ScaleGestureDetector::Config DefaultScaleGestureDetectorConfig() {
47 ScaleGestureDetector::Config config;
48 config.span_slop =
49 GestureConfiguration::max_touch_move_in_pixels_for_click() * 2;
50 config.min_scaling_touch_major = GestureConfiguration::default_radius() * 2;
51 config.min_scaling_span = GestureConfiguration::min_scaling_span_in_pixels();
52 config.min_pinch_update_span_delta =
53 CommandLine::ForCurrentProcess()->HasSwitch(
54 switches::kCompensateForUnstablePinchZoom) ?
55 GestureConfiguration::min_pinch_update_distance_in_pixels() : 0;
56 return config;
57 }
58
59 } // namespace
60
61 GestureProvider::Config DefaultGestureProviderConfig() {
62 GestureProvider::Config config;
63 gfx::Screen* screen = gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE);
64 // |screen| is sometimes NULL during tests.
65 if (screen)
66 config.display = screen->GetPrimaryDisplay();
67 config.gesture_detector_config = DefaultGestureDetectorConfig();
68 config.scale_gesture_detector_config = DefaultScaleGestureDetectorConfig();
69 config.gesture_begin_end_types_enabled = true;
70 // Half the size of the default touch length is a reasonable minimum.
71 config.min_gesture_bounds_length = GestureConfiguration::default_radius();
72 return config;
73 }
74
75 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/gesture_detection/gesture_config_helper_android.cc ('k') | ui/events/gesture_detection/gesture_configuration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698