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_configuration.h" | 5 #include "ui/events/gesture_detection/gesture_configuration.h" |
6 | 6 |
7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
8 #include "ui/gfx/android/view_configuration.h" | 8 #include "ui/gfx/android/view_configuration.h" |
9 #include "ui/gfx/screen.h" | 9 #include "ui/gfx/screen.h" |
10 | 10 |
11 using gfx::ViewConfiguration; | 11 using gfx::ViewConfiguration; |
12 | 12 |
13 namespace ui { | 13 namespace ui { |
14 namespace { | 14 namespace { |
15 | 15 |
16 // Touch radii on Android can be both noisy and inaccurate. The old Java | 16 // Touch radii on Android can be both noisy and inaccurate. The old Java |
17 // gesture detection pipeline used a fixed value of 24 as the gesture bounds. | 17 // gesture detection pipeline used a fixed value of 24 as the gesture bounds. |
18 // We relax that value somewhat, but not by much; there's a fairly small window | 18 // We relax that value somewhat, but not by much; there's a fairly small window |
19 // within which gesture bounds are useful for features like touch adjustment. | 19 // within which gesture bounds are useful for features like touch adjustment. |
20 const float kMinGestureBoundsLengthDips = 20.f; | 20 const float kMinGestureBoundsLengthDips = 20.f; |
21 const float kMaxGestureBoundsLengthDips = 32.f; | 21 const float kMaxGestureBoundsLengthDips = 32.f; |
22 | 22 |
23 class GestureConfigurationAndroid : public GestureConfiguration { | 23 class GestureConfigurationAndroid : public GestureConfiguration { |
24 public: | 24 public: |
25 ~GestureConfigurationAndroid() override { | 25 ~GestureConfigurationAndroid() override { |
26 } | 26 } |
27 | 27 |
28 static GestureConfigurationAndroid* GetInstance() { | 28 static GestureConfigurationAndroid* GetInstance() { |
29 return Singleton<GestureConfigurationAndroid>::get(); | 29 return base::Singleton<GestureConfigurationAndroid>::get(); |
30 } | 30 } |
31 | 31 |
32 private: | 32 private: |
33 GestureConfigurationAndroid() : GestureConfiguration() { | 33 GestureConfigurationAndroid() : GestureConfiguration() { |
34 set_double_tap_enabled(true); | 34 set_double_tap_enabled(true); |
35 set_double_tap_timeout_in_ms(ViewConfiguration::GetDoubleTapTimeoutInMs()); | 35 set_double_tap_timeout_in_ms(ViewConfiguration::GetDoubleTapTimeoutInMs()); |
36 set_gesture_begin_end_types_enabled(false); | 36 set_gesture_begin_end_types_enabled(false); |
37 set_long_press_time_in_ms(ViewConfiguration::GetLongPressTimeoutInMs()); | 37 set_long_press_time_in_ms(ViewConfiguration::GetLongPressTimeoutInMs()); |
38 set_max_distance_between_taps_for_double_tap( | 38 set_max_distance_between_taps_for_double_tap( |
39 ViewConfiguration::GetDoubleTapSlopInDips()); | 39 ViewConfiguration::GetDoubleTapSlopInDips()); |
(...skipping 13 matching lines...) Expand all Loading... |
53 set_show_press_delay_in_ms(ViewConfiguration::GetTapTimeoutInMs()); | 53 set_show_press_delay_in_ms(ViewConfiguration::GetTapTimeoutInMs()); |
54 set_span_slop(ViewConfiguration::GetTouchSlopInDips() * 2.f); | 54 set_span_slop(ViewConfiguration::GetTouchSlopInDips() * 2.f); |
55 set_fling_touchscreen_tap_suppression_enabled(true); | 55 set_fling_touchscreen_tap_suppression_enabled(true); |
56 set_fling_touchpad_tap_suppression_enabled(false); | 56 set_fling_touchpad_tap_suppression_enabled(false); |
57 set_fling_max_cancel_to_down_time_in_ms( | 57 set_fling_max_cancel_to_down_time_in_ms( |
58 ViewConfiguration::GetTapTimeoutInMs()); | 58 ViewConfiguration::GetTapTimeoutInMs()); |
59 set_fling_max_tap_gap_time_in_ms( | 59 set_fling_max_tap_gap_time_in_ms( |
60 ViewConfiguration::GetLongPressTimeoutInMs()); | 60 ViewConfiguration::GetLongPressTimeoutInMs()); |
61 } | 61 } |
62 | 62 |
63 friend struct DefaultSingletonTraits<GestureConfigurationAndroid>; | 63 friend struct base::DefaultSingletonTraits<GestureConfigurationAndroid>; |
64 DISALLOW_COPY_AND_ASSIGN(GestureConfigurationAndroid); | 64 DISALLOW_COPY_AND_ASSIGN(GestureConfigurationAndroid); |
65 }; | 65 }; |
66 | 66 |
67 } // namespace | 67 } // namespace |
68 | 68 |
69 // Create a GestureConfigurationAura singleton instance when using Android. | 69 // Create a GestureConfigurationAura singleton instance when using Android. |
70 GestureConfiguration* GestureConfiguration::GetPlatformSpecificInstance() { | 70 GestureConfiguration* GestureConfiguration::GetPlatformSpecificInstance() { |
71 return GestureConfigurationAndroid::GetInstance(); | 71 return GestureConfigurationAndroid::GetInstance(); |
72 } | 72 } |
73 | 73 |
74 } // namespace ui | 74 } // namespace ui |
OLD | NEW |