| 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 #ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_PROVIDER_H_ | 5 #ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_PROVIDER_H_ |
| 6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_PROVIDER_H_ | 6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_PROVIDER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "ui/events/gesture_detection/gesture_detection_export.h" | 10 #include "ui/events/gesture_detection/gesture_detection_export.h" |
| 11 #include "ui/events/gesture_detection/gesture_detector.h" | 11 #include "ui/events/gesture_detection/gesture_detector.h" |
| 12 #include "ui/events/gesture_detection/gesture_event_data.h" |
| 12 #include "ui/events/gesture_detection/scale_gesture_detector.h" | 13 #include "ui/events/gesture_detection/scale_gesture_detector.h" |
| 13 #include "ui/events/gesture_detection/snap_scroll_controller.h" | 14 #include "ui/events/gesture_detection/snap_scroll_controller.h" |
| 14 #include "ui/gfx/display.h" | 15 #include "ui/gfx/display.h" |
| 15 | 16 |
| 16 namespace ui { | 17 namespace ui { |
| 17 | 18 |
| 18 struct GestureEventData; | |
| 19 | |
| 20 class GESTURE_DETECTION_EXPORT GestureProviderClient { | 19 class GESTURE_DETECTION_EXPORT GestureProviderClient { |
| 21 public: | 20 public: |
| 22 virtual ~GestureProviderClient() {} | 21 virtual ~GestureProviderClient() {} |
| 23 virtual void OnGestureEvent(const GestureEventData& gesture) = 0; | 22 virtual void OnGestureEvent(const GestureEventData& gesture) = 0; |
| 24 }; | 23 }; |
| 25 | 24 |
| 26 // Given a stream of |MotionEvent|'s, provides gesture detection and gesture | 25 // Given a stream of |MotionEvent|'s, provides gesture detection and gesture |
| 27 // event dispatch. | 26 // event dispatch. |
| 28 class GESTURE_DETECTION_EXPORT GestureProvider { | 27 class GESTURE_DETECTION_EXPORT GestureProvider { |
| 29 public: | 28 public: |
| 30 struct GESTURE_DETECTION_EXPORT Config { | 29 struct GESTURE_DETECTION_EXPORT Config { |
| 31 Config(); | 30 Config(); |
| 32 ~Config(); | 31 ~Config(); |
| 33 gfx::Display display; | 32 gfx::Display display; |
| 34 GestureDetector::Config gesture_detector_config; | 33 GestureDetector::Config gesture_detector_config; |
| 35 ScaleGestureDetector::Config scale_gesture_detector_config; | 34 ScaleGestureDetector::Config scale_gesture_detector_config; |
| 36 | 35 |
| 37 // If |disable_click_delay| is true and double-tap support is disabled, | 36 // If |disable_click_delay| is true and double-tap support is disabled, |
| 38 // there will be no delay before tap events. When double-tap support is | 37 // there will be no delay before tap events. When double-tap support is |
| 39 // enabled, there will always be a delay before a tap event is fired, in | 38 // enabled, there will always be a delay before a tap event is fired, in |
| 40 // order to allow the double tap gesture to occur without firing any tap | 39 // order to allow the double tap gesture to occur without firing any tap |
| 41 // events. | 40 // events. |
| 42 bool disable_click_delay; | 41 bool disable_click_delay; |
| 43 | 42 |
| 44 // If |gesture_begin_end_types_enabled| is true, fire an ET_GESTURE_BEGIN | 43 // If |gesture_begin_end_types_enabled| is true, fire an ET_GESTURE_BEGIN |
| 45 // event for every added touch point, and an ET_GESTURE_END event for every | 44 // event for every added touch point, and an ET_GESTURE_END event for every |
| 46 // removed touch point. Defaults to false. | 45 // removed touch point. Defaults to false. |
| 47 bool gesture_begin_end_types_enabled; | 46 bool gesture_begin_end_types_enabled; |
| 47 |
| 48 // The minimum size (both length and width, in dips) of the generated |
| 49 // bounding box for all gesture types. This is useful for touch streams |
| 50 // that may report zero or unreasonably small touch sizes. |
| 51 // Defaults to 0. |
| 52 float min_gesture_bounds_length; |
| 48 }; | 53 }; |
| 49 | 54 |
| 50 GestureProvider(const Config& config, GestureProviderClient* client); | 55 GestureProvider(const Config& config, GestureProviderClient* client); |
| 51 ~GestureProvider(); | 56 ~GestureProvider(); |
| 52 | 57 |
| 53 // Handle the incoming MotionEvent, returning false if the event could not | 58 // Handle the incoming MotionEvent, returning false if the event could not |
| 54 // be handled. | 59 // be handled. |
| 55 bool OnTouchEvent(const MotionEvent& event); | 60 bool OnTouchEvent(const MotionEvent& event); |
| 56 | 61 |
| 57 // Update whether multi-touch pinch zoom is supported by the platform. | 62 // Update whether multi-touch pinch zoom is supported by the platform. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 80 const ui::MotionEvent* current_down_event() const { | 85 const ui::MotionEvent* current_down_event() const { |
| 81 return current_down_event_.get(); | 86 return current_down_event_.get(); |
| 82 } | 87 } |
| 83 | 88 |
| 84 private: | 89 private: |
| 85 void InitGestureDetectors(const Config& config); | 90 void InitGestureDetectors(const Config& config); |
| 86 | 91 |
| 87 bool CanHandle(const MotionEvent& event) const; | 92 bool CanHandle(const MotionEvent& event) const; |
| 88 | 93 |
| 89 void Fling(const MotionEvent& e, float velocity_x, float velocity_y); | 94 void Fling(const MotionEvent& e, float velocity_x, float velocity_y); |
| 90 void Send(const GestureEventData& gesture); | 95 void Send(GestureEventData gesture); |
| 91 bool SendLongTapIfNecessary(const MotionEvent& event); | 96 bool SendLongTapIfNecessary(const MotionEvent& event); |
| 92 void EndTouchScrollIfNecessary(const MotionEvent& event, | 97 void EndTouchScrollIfNecessary(const MotionEvent& event, |
| 93 bool send_scroll_end_event); | 98 bool send_scroll_end_event); |
| 94 void OnTouchEventHandlingBegin(const MotionEvent& event); | 99 void OnTouchEventHandlingBegin(const MotionEvent& event); |
| 95 void OnTouchEventHandlingEnd(const MotionEvent& event); | 100 void OnTouchEventHandlingEnd(const MotionEvent& event); |
| 96 void UpdateDoubleTapDetectionSupport(); | 101 void UpdateDoubleTapDetectionSupport(); |
| 97 | 102 |
| 98 GestureProviderClient* const client_; | 103 GestureProviderClient* const client_; |
| 99 | 104 |
| 100 class GestureListenerImpl; | 105 class GestureListenerImpl; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 114 | 119 |
| 115 // Whether double-tap gesture detection is currently supported. | 120 // Whether double-tap gesture detection is currently supported. |
| 116 bool double_tap_support_for_page_; | 121 bool double_tap_support_for_page_; |
| 117 bool double_tap_support_for_platform_; | 122 bool double_tap_support_for_platform_; |
| 118 | 123 |
| 119 // Keeps track of the current GESTURE_LONG_PRESS event. If a context menu is | 124 // Keeps track of the current GESTURE_LONG_PRESS event. If a context menu is |
| 120 // opened after a GESTURE_LONG_PRESS, this is used to insert a | 125 // opened after a GESTURE_LONG_PRESS, this is used to insert a |
| 121 // GESTURE_TAP_CANCEL for removing any ::active styling. | 126 // GESTURE_TAP_CANCEL for removing any ::active styling. |
| 122 base::TimeTicks current_longpress_time_; | 127 base::TimeTicks current_longpress_time_; |
| 123 | 128 |
| 124 bool gesture_begin_end_types_enabled_; | 129 const bool gesture_begin_end_types_enabled_; |
| 130 |
| 131 const float min_gesture_bounds_length_; |
| 125 }; | 132 }; |
| 126 | 133 |
| 127 } // namespace ui | 134 } // namespace ui |
| 128 | 135 |
| 129 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_PROVIDER_H_ | 136 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_PROVIDER_H_ |
| OLD | NEW |