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

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

Issue 613373004: Adopt ui::GestureConfiguration on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move DefaultGestureProviderConfig function to gesture_provider_config_helper class 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_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
OLDNEW
« no previous file with comments | « ui/events/gesture_detection/gesture_provider_config_helper.h ('k') | ui/events/gestures/gesture_configuration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698