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

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

Issue 1216933013: [Android] Expose native ViewConfiguration constants as DIPs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment and add assert Created 5 years, 5 months 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
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
(...skipping 13 matching lines...) Expand all
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 Singleton<GestureConfigurationAndroid>::get();
30 } 30 }
31 31
32 private: 32 private:
33 GestureConfigurationAndroid() : GestureConfiguration() { 33 GestureConfigurationAndroid() : GestureConfiguration() {
34 float raw_pixel_to_dip_ratio = 1.f / gfx::Screen::GetNativeScreen()
35 ->GetPrimaryDisplay()
36 .device_scale_factor();
37 set_double_tap_enabled(true); 34 set_double_tap_enabled(true);
38 set_double_tap_timeout_in_ms(ViewConfiguration::GetDoubleTapTimeoutInMs()); 35 set_double_tap_timeout_in_ms(ViewConfiguration::GetDoubleTapTimeoutInMs());
39 set_gesture_begin_end_types_enabled(false); 36 set_gesture_begin_end_types_enabled(false);
40 set_long_press_time_in_ms(ViewConfiguration::GetLongPressTimeoutInMs()); 37 set_long_press_time_in_ms(ViewConfiguration::GetLongPressTimeoutInMs());
41 set_max_distance_between_taps_for_double_tap( 38 set_max_distance_between_taps_for_double_tap(
42 ViewConfiguration::GetDoubleTapSlopInPixels() * raw_pixel_to_dip_ratio); 39 ViewConfiguration::GetDoubleTapSlopInDips());
43 set_max_fling_velocity( 40 set_max_fling_velocity(
44 ViewConfiguration::GetMaximumFlingVelocityInPixelsPerSecond() * 41 ViewConfiguration::GetMaximumFlingVelocityInDipsPerSecond());
45 raw_pixel_to_dip_ratio);
46 set_max_gesture_bounds_length(kMaxGestureBoundsLengthDips); 42 set_max_gesture_bounds_length(kMaxGestureBoundsLengthDips);
47 set_max_touch_move_in_pixels_for_click( 43 set_max_touch_move_in_pixels_for_click(
48 ViewConfiguration::GetTouchSlopInPixels() * raw_pixel_to_dip_ratio); 44 ViewConfiguration::GetTouchSlopInDips());
49 set_min_fling_velocity( 45 set_min_fling_velocity(
50 ViewConfiguration::GetMinimumFlingVelocityInPixelsPerSecond() * 46 ViewConfiguration::GetMinimumFlingVelocityInDipsPerSecond());
51 raw_pixel_to_dip_ratio);
52 set_min_gesture_bounds_length(kMinGestureBoundsLengthDips); 47 set_min_gesture_bounds_length(kMinGestureBoundsLengthDips);
53 set_min_pinch_update_span_delta(0.f); 48 set_min_pinch_update_span_delta(0.f);
54 set_min_scaling_span_in_pixels( 49 set_min_scaling_span_in_pixels(
55 ViewConfiguration::GetMinScalingSpanInPixels() * 50 ViewConfiguration::GetMinScalingSpanInDips());
56 raw_pixel_to_dip_ratio);
57 set_min_scaling_touch_major( 51 set_min_scaling_touch_major(
58 ViewConfiguration::GetMinScalingTouchMajorInPixels() * 52 ViewConfiguration::GetMinScalingTouchMajorInDips());
59 raw_pixel_to_dip_ratio);
60 set_show_press_delay_in_ms(ViewConfiguration::GetTapTimeoutInMs()); 53 set_show_press_delay_in_ms(ViewConfiguration::GetTapTimeoutInMs());
61 set_span_slop(ViewConfiguration::GetTouchSlopInPixels() * 2.f * 54 set_span_slop(ViewConfiguration::GetTouchSlopInDips() * 2.f);
62 raw_pixel_to_dip_ratio);
63 } 55 }
64 56
65 friend struct DefaultSingletonTraits<GestureConfigurationAndroid>; 57 friend struct DefaultSingletonTraits<GestureConfigurationAndroid>;
66 DISALLOW_COPY_AND_ASSIGN(GestureConfigurationAndroid); 58 DISALLOW_COPY_AND_ASSIGN(GestureConfigurationAndroid);
67 }; 59 };
68 60
69 } // namespace 61 } // namespace
70 62
71 // Create a GestureConfigurationAura singleton instance when using Android. 63 // Create a GestureConfigurationAura singleton instance when using Android.
72 GestureConfiguration* GestureConfiguration::GetPlatformSpecificInstance() { 64 GestureConfiguration* GestureConfiguration::GetPlatformSpecificInstance() {
73 return GestureConfigurationAndroid::GetInstance(); 65 return GestureConfigurationAndroid::GetInstance();
74 } 66 }
75 67
76 } // namespace ui 68 } // namespace ui
OLDNEW
« no previous file with comments | « ui/android/java/src/org/chromium/ui/gfx/ViewConfigurationHelper.java ('k') | ui/gfx/android/view_configuration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698