OLD | NEW |
---|---|
(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_configuration.h" | |
6 | |
7 #include "ui/gfx/android/view_configuration.h" | |
8 #include "ui/gfx/screen.h" | |
9 | |
10 using gfx::ViewConfiguration; | |
11 | |
12 namespace ui { | |
13 namespace { | |
14 // This was the minimum tap/press size used on Android before the new gesture | |
15 // detection pipeline. | |
16 const float kMinGestureBoundsLengthDips = 24.f; | |
17 | |
18 // This value is somewhat arbitrary, but provides a reasonable maximum | |
19 // approximating a large thumb depression. | |
20 const float kMaxGestureBoundsLengthDips = kMinGestureBoundsLengthDips * 4.f; | |
21 | |
22 class GestureConfigurationAndroid : public GestureConfiguration { | |
23 public: | |
24 static GestureConfigurationAndroid* GetInstance() { | |
25 return Singleton<GestureConfigurationAndroid>::get(); | |
26 } | |
27 | |
28 private: | |
29 GestureConfigurationAndroid() : GestureConfiguration() { | |
30 float raw_pixel_to_dip_ratio = 1.f / | |
tdresser
2014/10/23 14:26:22
Looks like this could use re-formatting.
lanwei
2014/10/23 19:54:19
Done.
| |
31 gfx::Screen::GetNativeScreen() | |
32 ->GetPrimaryDisplay() | |
33 .device_scale_factor(); | |
34 set_double_tap_timeout_in_ms(ViewConfiguration::GetDoubleTapTimeoutInMs()); | |
35 set_gesture_begin_end_types_enabled(false); | |
36 set_long_press_time_in_ms(ViewConfiguration::GetLongPressTimeoutInMs()); | |
37 set_max_distance_between_taps_for_double_tap( | |
38 ViewConfiguration::GetDoubleTapSlopInPixels() * raw_pixel_to_dip_ratio); | |
39 set_max_fling_velocity( | |
40 ViewConfiguration::GetMaximumFlingVelocityInPixelsPerSecond() * | |
41 raw_pixel_to_dip_ratio); | |
42 set_max_gesture_bounds_length(kMaxGestureBoundsLengthDips); | |
43 set_max_touch_move_in_pixels_for_click( | |
44 ViewConfiguration::GetTouchSlopInPixels() * raw_pixel_to_dip_ratio); | |
45 set_min_fling_velocity( | |
46 ViewConfiguration::GetMinimumFlingVelocityInPixelsPerSecond() * | |
47 raw_pixel_to_dip_ratio); | |
48 set_min_gesture_bounds_length(kMinGestureBoundsLengthDips); | |
49 set_min_pinch_update_span_delta(0.f); | |
50 set_min_scaling_span_in_pixels( | |
51 ViewConfiguration::GetMinScalingSpanInPixels() * | |
52 raw_pixel_to_dip_ratio); | |
53 set_min_scaling_touch_major( | |
54 ViewConfiguration::GetMinScalingTouchMajorInPixels() * | |
55 raw_pixel_to_dip_ratio); | |
56 set_show_press_delay_in_ms(ViewConfiguration::GetTapTimeoutInMs()); | |
57 set_span_slop(ViewConfiguration::GetTouchSlopInPixels() * 2.f * | |
58 raw_pixel_to_dip_ratio); | |
59 } | |
60 | |
61 friend struct DefaultSingletonTraits<GestureConfigurationAndroid>; | |
62 DISALLOW_COPY_AND_ASSIGN(GestureConfigurationAndroid); | |
63 }; | |
64 | |
65 } // namespace | |
66 | |
67 GestureConfiguration* GestureConfiguration::GetInstance() { | |
68 return GestureConfigurationAndroid::GetInstance(); | |
69 } | |
70 | |
71 GestureProvider::Config DefaultGestureProviderConfig() { | |
72 return GestureConfigurationAndroid::GetInstance() | |
73 ->DefaultGestureProviderConfig(); | |
74 } | |
75 | |
76 } // namespace ui | |
OLD | NEW |