| OLD | NEW |
| 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; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 ScaleGestureDetector::Config DefaultScaleGestureDetectorConfig( | 48 ScaleGestureDetector::Config DefaultScaleGestureDetectorConfig( |
| 49 const gfx::Display& display) { | 49 const gfx::Display& display) { |
| 50 ScaleGestureDetector::Config config; | 50 ScaleGestureDetector::Config config; |
| 51 | 51 |
| 52 config.gesture_detector_config = DefaultGestureDetectorConfig(display); | 52 config.gesture_detector_config = DefaultGestureDetectorConfig(display); |
| 53 config.quick_scale_enabled = true; | 53 config.quick_scale_enabled = true; |
| 54 | 54 |
| 55 const float px_to_dp = 1.f / display.device_scale_factor(); | 55 const float px_to_dp = 1.f / display.device_scale_factor(); |
| 56 config.min_scaling_touch_major = | 56 config.min_scaling_touch_major = |
| 57 ViewConfiguration::GetMinScalingTouchMajorInPixels() * px_to_dp; | 57 ViewConfiguration::GetMinScalingTouchMajorInPixels() * px_to_dp; |
| 58 config.use_touch_major_in_span = | |
| 59 ViewConfiguration::ShouldUseTouchMajorInScalingSpan(); | |
| 60 config.min_scaling_span = | 58 config.min_scaling_span = |
| 61 ViewConfiguration::GetMinScalingSpanInPixels() * px_to_dp; | 59 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 } | |
| 69 | 60 |
| 70 return config; | 61 return config; |
| 71 } | 62 } |
| 72 | 63 |
| 73 } // namespace | 64 } // namespace |
| 74 | 65 |
| 75 GestureProvider::Config DefaultGestureProviderConfig() { | 66 GestureProvider::Config DefaultGestureProviderConfig() { |
| 76 GestureProvider::Config config; | 67 GestureProvider::Config config; |
| 77 config.display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 68 config.display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
| 78 config.gesture_detector_config = DefaultGestureDetectorConfig(config.display); | 69 config.gesture_detector_config = DefaultGestureDetectorConfig(config.display); |
| 79 config.scale_gesture_detector_config = | 70 config.scale_gesture_detector_config = |
| 80 DefaultScaleGestureDetectorConfig(config.display); | 71 DefaultScaleGestureDetectorConfig(config.display); |
| 81 config.gesture_begin_end_types_enabled = false; | 72 config.gesture_begin_end_types_enabled = false; |
| 82 config.min_gesture_bounds_length = kMinGestureBoundsLengthDips; | 73 config.min_gesture_bounds_length = kMinGestureBoundsLengthDips; |
| 83 config.max_gesture_bounds_length = kMaxGestureBoundsLengthDips; | 74 config.max_gesture_bounds_length = kMaxGestureBoundsLengthDips; |
| 84 return config; | 75 return config; |
| 85 } | 76 } |
| 86 | 77 |
| 87 } // namespace ui | 78 } // namespace ui |
| OLD | NEW |