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

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

Issue 613373004: Adopt ui::GestureConfiguration on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add dependencies Created 6 years, 2 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
(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 <cmath>
8
9 #include "ui/gfx/screen.h"
10
11 namespace ui {
12
13 class GESTURE_DETECTION_EXPORT GestureConfigurationAura
14 : public GestureConfiguration {
15 public:
16 static GestureConfigurationAura* GetInstance() {
17 return Singleton<GestureConfigurationAura>::get();
18 }
19
20 GestureProvider::Config DefaultGestureProviderConfig() {
21 GestureProvider::Config config;
22 gfx::Screen* screen = gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE);
23 // |screen| is sometimes NULL during tests.
24 if (screen)
25 config.display = screen->GetPrimaryDisplay();
26 config.gesture_detector_config = DefaultGestureDetectorConfig();
27 config.scale_gesture_detector_config = DefaultScaleGestureDetectorConfig();
28 config.gesture_begin_end_types_enabled = true;
29 // Half the size of the default touch length is a reasonable minimum.
30 config.min_gesture_bounds_length = default_radius();
31 return config;
32 }
33
34 virtual GestureDetector::Config DefaultGestureDetectorConfig() override {
35 GestureDetector::Config config =
36 GestureConfiguration::DefaultGestureDetectorConfig();
37 config.swipe_enabled = true;
jdduke (slow) 2014/10/22 00:45:12 If we add |swipe_enabled|, |two_finger_tap_enabled
38 config.minimum_swipe_velocity = min_swipe_speed();
39 config.maximum_swipe_deviation_angle = max_swipe_deviation_angle();
40 config.two_finger_tap_enabled = true;
41 config.two_finger_tap_max_separation =
42 max_distance_for_two_finger_tap_in_pixels();
43 config.two_finger_tap_timeout = base::TimeDelta::FromMilliseconds(
44 max_touch_down_duration_for_click_in_ms());
45 return config;
46 }
47
48 private:
49 GestureConfigurationAura() : GestureConfiguration() {
50 set_span_slop(max_touch_move_in_pixels_for_click() * 2);
51 set_min_scaling_touch_major(default_radius() * 2);
52 set_min_pinch_update_span_delta(
53 CommandLine::ForCurrentProcess()->HasSwitch(
54 switches::kCompensateForUnstablePinchZoom)
55 ? min_pinch_update_distance_in_pixels()
56 : 0);
57 }
58 friend struct DefaultSingletonTraits<GestureConfigurationAura>;
59 DISALLOW_COPY_AND_ASSIGN(GestureConfigurationAura);
60 };
61
62 GestureConfiguration* GestureConfiguration::GetInstance() {
63 return GestureConfigurationAura::GetInstance();
64 }
65
66 GestureProvider::Config DefaultGestureProviderConfig() {
67 return GestureConfigurationAura::GetInstance()
68 ->DefaultGestureProviderConfig();
69 }
70
71 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698