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

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: Move all the methods to superclass 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
14 namespace {
15
16 class GestureConfigurationAndroid : public GestureConfiguration {
17 public:
18 static GestureConfigurationAndroid* GetInstance() {
19 return Singleton<GestureConfigurationAndroid>::get();
20 }
21
22 private:
23 GestureConfigurationAndroid()
24 : GestureConfiguration(),
25 raw_pixel_to_dip_ratio_(1.f /
26 gfx::Screen::GetNativeScreen()
27 ->GetPrimaryDisplay()
28 .device_scale_factor()) {
29 set_fling_velocity_cap(
30 ViewConfiguration::GetMaximumFlingVelocityInPixelsPerSecond() *
31 raw_pixel_to_dip_ratio_);
32 set_gesture_begin_end_types_enabled(false);
33 set_long_press_time_in_ms(ViewConfiguration::GetLongPressTimeoutInMs());
34 set_max_distance_between_taps_for_double_tap(
jdduke (slow) 2014/10/22 17:31:34 Should we also explicitly disable two_finger_tap a
lanwei 2014/10/23 01:26:18 I feel if we already set false in the superclass,
35 ViewConfiguration::GetDoubleTapSlopInPixels() *
36 raw_pixel_to_dip_ratio_);
37 set_max_gesture_bounds_length(kMaxGestureBoundsLengthDips);
38 set_max_touch_move_in_pixels_for_click(
39 ViewConfiguration::GetTouchSlopInPixels() * raw_pixel_to_dip_ratio_);
40 set_min_gesture_bounds_length(kMinGestureBoundsLengthDips);
41 set_min_pinch_update_span_delta(0.f);
42 set_min_scaling_span_in_pixels(
43 ViewConfiguration::GetMinScalingSpanInPixels() *
44 raw_pixel_to_dip_ratio_);
45 set_min_scaling_touch_major(
46 ViewConfiguration::GetMinScalingTouchMajorInPixels() *
47 raw_pixel_to_dip_ratio_);
48 set_min_scroll_velocity(
49 ViewConfiguration::GetMinimumFlingVelocityInPixelsPerSecond() *
50 raw_pixel_to_dip_ratio_);
51 set_semi_long_press_time_in_ms(
jdduke (slow) 2014/10/22 17:31:34 Hmm, it seems a little odd to use the DoubleTap ti
lanwei 2014/10/23 01:26:18 Done.
52 ViewConfiguration::GetDoubleTapTimeoutInMs());
53 set_show_press_delay_in_ms(ViewConfiguration::GetTapTimeoutInMs());
54 set_span_slop(ViewConfiguration::GetTouchSlopInPixels() * 2.f *
55 raw_pixel_to_dip_ratio_);
56 set_display(gfx::Screen::GetNativeScreen()->GetPrimaryDisplay());
jdduke (slow) 2014/10/22 17:31:34 Yeah, I think we should avoid caching the Display,
lanwei 2014/10/23 01:26:18 Done.
57 }
58
59 float raw_pixel_to_dip_ratio_;
jdduke (slow) 2014/10/22 17:31:34 Looks like this doesn't need to be a member variab
lanwei 2014/10/23 01:26:18 Done.
60
61 // This was the minimum tap/press size used on Android before the new gesture
62 // detection pipeline.
63 const float kMinGestureBoundsLengthDips = 24.f;
jdduke (slow) 2014/10/22 17:31:34 These constants should be pulled out of the class
lanwei 2014/10/23 01:26:18 Done.
64
65 // This value is somewhat arbitrary, but provides a reasonable maximum
66 // approximating a large thumb depression.
67 const float kMaxGestureBoundsLengthDips = kMinGestureBoundsLengthDips * 4.f;
68
69 friend struct DefaultSingletonTraits<GestureConfigurationAndroid>;
70 DISALLOW_COPY_AND_ASSIGN(GestureConfigurationAndroid);
71 };
72
73 } // namespace
74
75 GestureConfiguration* GestureConfiguration::GetInstance() {
76 return GestureConfigurationAndroid::GetInstance();
77 }
78
79 GestureProvider::Config DefaultGestureProviderConfig() {
80 return GestureConfigurationAndroid::GetInstance()
81 ->DefaultGestureProviderConfig();
82 }
83
84 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698