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

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

Issue 613373004: Adopt ui::GestureConfiguration on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
(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 / gfx::Screen::GetNativeScreen()
31 ->GetPrimaryDisplay()
32 .device_scale_factor();
33 set_double_tap_timeout_in_ms(ViewConfiguration::GetDoubleTapTimeoutInMs());
34 set_gesture_begin_end_types_enabled(false);
35 set_long_press_time_in_ms(ViewConfiguration::GetLongPressTimeoutInMs());
36 set_max_distance_between_taps_for_double_tap(
37 ViewConfiguration::GetDoubleTapSlopInPixels() * raw_pixel_to_dip_ratio);
38 set_max_fling_velocity(
39 ViewConfiguration::GetMaximumFlingVelocityInPixelsPerSecond() *
40 raw_pixel_to_dip_ratio);
41 set_max_gesture_bounds_length(kMaxGestureBoundsLengthDips);
42 set_max_touch_move_in_pixels_for_click(
43 ViewConfiguration::GetTouchSlopInPixels() * raw_pixel_to_dip_ratio);
44 set_min_fling_velocity(
45 ViewConfiguration::GetMinimumFlingVelocityInPixelsPerSecond() *
46 raw_pixel_to_dip_ratio);
47 set_min_gesture_bounds_length(kMinGestureBoundsLengthDips);
48 set_min_pinch_update_span_delta(0.f);
49 set_min_scaling_span_in_pixels(
50 ViewConfiguration::GetMinScalingSpanInPixels() *
51 raw_pixel_to_dip_ratio);
52 set_min_scaling_touch_major(
53 ViewConfiguration::GetMinScalingTouchMajorInPixels() *
54 raw_pixel_to_dip_ratio);
55 set_show_press_delay_in_ms(ViewConfiguration::GetTapTimeoutInMs());
56 set_span_slop(ViewConfiguration::GetTouchSlopInPixels() * 2.f *
57 raw_pixel_to_dip_ratio);
58 }
59
60 friend struct DefaultSingletonTraits<GestureConfigurationAndroid>;
61 DISALLOW_COPY_AND_ASSIGN(GestureConfigurationAndroid);
62 };
63
64 } // namespace
65
66 GestureConfiguration* GestureConfiguration::GetInstance() {
67 return GestureConfigurationAndroid::GetInstance();
jdduke (slow) 2014/10/23 20:17:00 Can this just be Singleton<GestureConfigurationAnd
lanwei 2014/10/23 20:50:48 I tried before, it gave me this error error: 'get
68 }
69
70 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698