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

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

Issue 340343013: Provide max gesture bounds and option to ignore touch size during pinch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review Created 6 years, 5 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 namespace { 13 namespace {
14 // TODO(jdduke): Adopt GestureConfiguration on Android, crbug/339203. 14 // TODO(jdduke): Adopt GestureConfiguration on Android, crbug/339203.
15 15
16 // This was the minimum tap/press size used on Android before the new gesture 16 // This was the minimum tap/press size used on Android before the new gesture
17 // detection pipeline. 17 // detection pipeline.
18 const float kMinGestureBoundsLengthDips = 24.f; 18 const float kMinGestureBoundsLengthDips = 24.f;
19 19
20 // This value is somewhat arbitrary, but provides a reasonable maximum
21 // approximating a large thumb depression.
22 const float kMaxGestureBoundsLengthDips = kMinGestureBoundsLengthDips * 4.f;
23
20 GestureDetector::Config DefaultGestureDetectorConfig( 24 GestureDetector::Config DefaultGestureDetectorConfig(
21 const gfx::Display& display) { 25 const gfx::Display& display) {
22 GestureDetector::Config config; 26 GestureDetector::Config config;
23 27
24 config.longpress_timeout = base::TimeDelta::FromMilliseconds( 28 config.longpress_timeout = base::TimeDelta::FromMilliseconds(
25 ViewConfiguration::GetLongPressTimeoutInMs()); 29 ViewConfiguration::GetLongPressTimeoutInMs());
26 config.showpress_timeout = 30 config.showpress_timeout =
27 base::TimeDelta::FromMilliseconds(ViewConfiguration::GetTapTimeoutInMs()); 31 base::TimeDelta::FromMilliseconds(ViewConfiguration::GetTapTimeoutInMs());
28 config.double_tap_timeout = base::TimeDelta::FromMilliseconds( 32 config.double_tap_timeout = base::TimeDelta::FromMilliseconds(
29 ViewConfiguration::GetDoubleTapTimeoutInMs()); 33 ViewConfiguration::GetDoubleTapTimeoutInMs());
(...skipping 14 matching lines...) Expand all
44 ScaleGestureDetector::Config DefaultScaleGestureDetectorConfig( 48 ScaleGestureDetector::Config DefaultScaleGestureDetectorConfig(
45 const gfx::Display& display) { 49 const gfx::Display& display) {
46 ScaleGestureDetector::Config config; 50 ScaleGestureDetector::Config config;
47 51
48 config.gesture_detector_config = DefaultGestureDetectorConfig(display); 52 config.gesture_detector_config = DefaultGestureDetectorConfig(display);
49 config.quick_scale_enabled = true; 53 config.quick_scale_enabled = true;
50 54
51 const float px_to_dp = 1.f / display.device_scale_factor(); 55 const float px_to_dp = 1.f / display.device_scale_factor();
52 config.min_scaling_touch_major = 56 config.min_scaling_touch_major =
53 ViewConfiguration::GetMinScalingTouchMajorInPixels() * px_to_dp; 57 ViewConfiguration::GetMinScalingTouchMajorInPixels() * px_to_dp;
58 config.use_touch_major_in_span =
59 ViewConfiguration::ShouldUseTouchMajorInScalingSpan();
54 config.min_scaling_span = 60 config.min_scaling_span =
55 ViewConfiguration::GetMinScalingSpanInPixels() * px_to_dp; 61 ViewConfiguration::GetMinScalingSpanInPixels() * px_to_dp;
62 // As the |min_scaling_span| platform constant assumes that touch major values
63 // are used when computing the span, subtract off a reasonable touch major
64 // value for the case where the touch major values are not used.
65 if (!config.use_touch_major_in_span) {
66 config.min_scaling_span = std::max(
67 0.f, config.min_scaling_span - 2.f * config.min_scaling_touch_major);
68 }
56 69
57 return config; 70 return config;
58 } 71 }
59 72
60 } // namespace 73 } // namespace
61 74
62 GestureProvider::Config DefaultGestureProviderConfig() { 75 GestureProvider::Config DefaultGestureProviderConfig() {
63 GestureProvider::Config config; 76 GestureProvider::Config config;
64 config.display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); 77 config.display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
65 config.gesture_detector_config = DefaultGestureDetectorConfig(config.display); 78 config.gesture_detector_config = DefaultGestureDetectorConfig(config.display);
66 config.scale_gesture_detector_config = 79 config.scale_gesture_detector_config =
67 DefaultScaleGestureDetectorConfig(config.display); 80 DefaultScaleGestureDetectorConfig(config.display);
68 config.gesture_begin_end_types_enabled = false; 81 config.gesture_begin_end_types_enabled = false;
69 config.min_gesture_bounds_length = kMinGestureBoundsLengthDips; 82 config.min_gesture_bounds_length = kMinGestureBoundsLengthDips;
83 config.max_gesture_bounds_length = kMaxGestureBoundsLengthDips;
70 return config; 84 return config;
71 } 85 }
72 86
73 } // namespace ui 87 } // namespace ui
OLDNEW
« no previous file with comments | « ui/android/java/src/org/chromium/ui/gfx/ViewConfigurationHelper.java ('k') | ui/events/gesture_detection/gesture_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698