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

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

Issue 220063002: [Android] Use DIP coordinates with MotionEventAndroid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes Created 6 years, 8 months 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/events/gesture_detection/gesture_config_helper.h" 5 #include "ui/events/gesture_detection/gesture_config_helper.h"
6 6
7 #include "ui/gfx/android/view_configuration.h" 7 #include "ui/gfx/android/view_configuration.h"
8 #include "ui/gfx/screen.h" 8 #include "ui/gfx/screen.h"
9 9
10 using gfx::ViewConfiguration; 10 using gfx::ViewConfiguration;
11 11
12 namespace ui { 12 namespace ui {
13 13 namespace {
14 // TODO(jdduke): Adopt GestureConfiguration on Android, crbug/339203. 14 // TODO(jdduke): Adopt GestureConfiguration on Android, crbug/339203.
15 15
16 GestureDetector::Config DefaultGestureDetectorConfig() { 16 GestureDetector::Config DefaultGestureDetectorConfig(
17 const gfx::Display& display) {
17 GestureDetector::Config config; 18 GestureDetector::Config config;
18 19
19 config.longpress_timeout = base::TimeDelta::FromMilliseconds( 20 config.longpress_timeout = base::TimeDelta::FromMilliseconds(
20 ViewConfiguration::GetLongPressTimeoutInMs()); 21 ViewConfiguration::GetLongPressTimeoutInMs());
21 config.showpress_timeout = base::TimeDelta::FromMilliseconds( 22 config.showpress_timeout =
22 ViewConfiguration::GetTapTimeoutInMs()); 23 base::TimeDelta::FromMilliseconds(ViewConfiguration::GetTapTimeoutInMs());
23 config.double_tap_timeout = base::TimeDelta::FromMilliseconds( 24 config.double_tap_timeout = base::TimeDelta::FromMilliseconds(
24 ViewConfiguration::GetDoubleTapTimeoutInMs()); 25 ViewConfiguration::GetDoubleTapTimeoutInMs());
25 26
26 config.scaled_touch_slop = ViewConfiguration::GetTouchSlopInPixels(); 27 const float px_to_dp = 1.f / display.device_scale_factor();
27 config.scaled_double_tap_slop = ViewConfiguration::GetDoubleTapSlopInPixels(); 28 config.touch_slop =
28 config.scaled_minimum_fling_velocity = 29 ViewConfiguration::GetTouchSlopInPixels() * px_to_dp;
29 ViewConfiguration::GetMinimumFlingVelocityInPixelsPerSecond(); 30 config.double_tap_slop =
30 config.scaled_maximum_fling_velocity = 31 ViewConfiguration::GetDoubleTapSlopInPixels() * px_to_dp;
31 ViewConfiguration::GetMaximumFlingVelocityInPixelsPerSecond(); 32 config.minimum_fling_velocity =
33 ViewConfiguration::GetMinimumFlingVelocityInPixelsPerSecond() * px_to_dp;
34 config.maximum_fling_velocity =
35 ViewConfiguration::GetMaximumFlingVelocityInPixelsPerSecond() * px_to_dp;
32 36
33 return config; 37 return config;
34 } 38 }
35 39
36 ScaleGestureDetector::Config DefaultScaleGestureDetectorConfig() { 40 ScaleGestureDetector::Config DefaultScaleGestureDetectorConfig(
41 const gfx::Display& display) {
37 ScaleGestureDetector::Config config; 42 ScaleGestureDetector::Config config;
38 43
39 config.gesture_detector_config = DefaultGestureDetectorConfig(); 44 config.gesture_detector_config = DefaultGestureDetectorConfig(display);
40 config.quick_scale_enabled = true; 45 config.quick_scale_enabled = true;
46
47 const float px_to_dp = 1.f / display.device_scale_factor();
41 config.min_scaling_touch_major = 48 config.min_scaling_touch_major =
42 ViewConfiguration::GetMinScalingTouchMajorInPixels(); 49 ViewConfiguration::GetMinScalingTouchMajorInPixels() * px_to_dp;
43 config.min_scaling_span = ViewConfiguration::GetMinScalingSpanInPixels(); 50 config.min_scaling_span =
51 ViewConfiguration::GetMinScalingSpanInPixels() * px_to_dp;
44 52
45 return config; 53 return config;
46 } 54 }
47 55
48 SnapScrollController::Config DefaultSnapScrollControllerConfig() { 56 } // namespace
49 SnapScrollController::Config config;
50
51 const gfx::Display& display =
52 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
53
54 config.screen_width_pixels = display.GetSizeInPixel().width();
55 config.screen_height_pixels = display.GetSizeInPixel().height();
56 config.device_scale_factor = display.device_scale_factor();
57
58 return config;
59 }
60 57
61 GestureProvider::Config DefaultGestureProviderConfig() { 58 GestureProvider::Config DefaultGestureProviderConfig() {
62 GestureProvider::Config config; 59 GestureProvider::Config config;
63 config.gesture_detector_config = DefaultGestureDetectorConfig(); 60 config.display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
64 config.scale_gesture_detector_config = DefaultScaleGestureDetectorConfig(); 61 config.gesture_detector_config = DefaultGestureDetectorConfig(config.display);
65 config.snap_scroll_controller_config = DefaultSnapScrollControllerConfig(); 62 config.scale_gesture_detector_config =
63 DefaultScaleGestureDetectorConfig(config.display);
66 config.gesture_begin_end_types_enabled = false; 64 config.gesture_begin_end_types_enabled = false;
67 return config; 65 return config;
68 } 66 }
69 67
70 } // namespace ui 68 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/gesture_detection/gesture_config_helper.cc ('k') | ui/events/gesture_detection/gesture_config_helper_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698