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_UI_GESTURE_PROVIDER_H_ | 5 #ifndef UI_EVENTS_GESTURE_DETECTION_UI_GESTURE_PROVIDER_H_ |
6 #define UI_EVENTS_GESTURE_DETECTION_UI_GESTURE_PROVIDER_H_ | 6 #define UI_EVENTS_GESTURE_DETECTION_UI_GESTURE_PROVIDER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "ui/events/event.h" | 10 #include "ui/events/event.h" |
11 #include "ui/events/events_export.h" | 11 #include "ui/events/events_export.h" |
12 #include "ui/events/gesture_detection/filtered_gesture_provider.h" | 12 #include "ui/events/gesture_detection/filtered_gesture_provider.h" |
13 #include "ui/events/gesture_detection/gesture_event_data_packet.h" | 13 #include "ui/events/gesture_detection/gesture_event_data_packet.h" |
14 #include "ui/events/gesture_detection/touch_disposition_gesture_filter.h" | 14 #include "ui/events/gesture_detection/touch_disposition_gesture_filter.h" |
15 #include "ui/events/gestures/motion_event_impl.h" | 15 #include "ui/events/gestures/motion_event_impl.h" |
16 | 16 |
17 namespace ui { | 17 namespace ui { |
18 | 18 |
19 class EVENTS_EXPORT GestureProviderImplClient { | 19 class EVENTS_EXPORT GestureProviderImplClient { |
20 public: | 20 public: |
21 virtual ~GestureProviderImplClient() {} | 21 virtual ~GestureProviderImplClient() {} |
22 virtual void OnGestureEvent(GestureEvent* event) = 0; | 22 virtual void OnGestureEvent(GestureEvent* event) = 0; |
23 }; | 23 }; |
24 | 24 |
25 // Provides gesture detection and dispatch given a sequence of touch events | 25 // Provides gesture detection and dispatch given a sequence of touch events |
26 // and touch event acks. | 26 // and touch event acks. |
27 class EVENTS_EXPORT GestureProviderImpl : public GestureProviderClient { | 27 class EVENTS_EXPORT GestureProviderImpl : public GestureProviderClient { |
28 public: | 28 public: |
29 GestureProviderImpl(GestureProviderImplClient* client); | 29 GestureProviderImpl(GestureProviderImplClient* client); |
30 virtual ~GestureProviderImpl(); | 30 ~GestureProviderImpl() override; |
31 | 31 |
32 bool OnTouchEvent(const TouchEvent& event); | 32 bool OnTouchEvent(const TouchEvent& event); |
33 void OnTouchEventAck(bool event_consumed); | 33 void OnTouchEventAck(bool event_consumed); |
34 const MotionEventImpl& pointer_state() { return pointer_state_; } | 34 const MotionEventImpl& pointer_state() { return pointer_state_; } |
35 ScopedVector<GestureEvent>* GetAndResetPendingGestures(); | 35 ScopedVector<GestureEvent>* GetAndResetPendingGestures(); |
36 | 36 |
37 // GestureProviderClient implementation | 37 // GestureProviderClient implementation |
38 virtual void OnGestureEvent(const GestureEventData& gesture) override; | 38 void OnGestureEvent(const GestureEventData& gesture) override; |
39 | 39 |
40 private: | 40 private: |
41 bool IsConsideredDoubleTap(const GestureEventData& previous_tap, | 41 bool IsConsideredDoubleTap(const GestureEventData& previous_tap, |
42 const GestureEventData& current_tap) const; | 42 const GestureEventData& current_tap) const; |
43 | 43 |
44 scoped_ptr<GestureEventData> previous_tap_; | 44 scoped_ptr<GestureEventData> previous_tap_; |
45 | 45 |
46 GestureProviderImplClient* client_; | 46 GestureProviderImplClient* client_; |
47 MotionEventImpl pointer_state_; | 47 MotionEventImpl pointer_state_; |
48 FilteredGestureProvider filtered_gesture_provider_; | 48 FilteredGestureProvider filtered_gesture_provider_; |
49 | 49 |
50 ui::LatencyInfo last_touch_event_latency_info_; | 50 ui::LatencyInfo last_touch_event_latency_info_; |
51 bool handling_event_; | 51 bool handling_event_; |
52 ScopedVector<GestureEvent> pending_gestures_; | 52 ScopedVector<GestureEvent> pending_gestures_; |
53 | 53 |
54 DISALLOW_COPY_AND_ASSIGN(GestureProviderImpl); | 54 DISALLOW_COPY_AND_ASSIGN(GestureProviderImpl); |
55 }; | 55 }; |
56 | 56 |
57 } // namespace ui | 57 } // namespace ui |
58 | 58 |
59 #endif // UI_EVENTS_GESTURE_DETECTION_UI_GESTURE_PROVIDER_H_ | 59 #endif // UI_EVENTS_GESTURE_DETECTION_UI_GESTURE_PROVIDER_H_ |
OLD | NEW |