OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_GESTURES_GESTURE_RECOGNIZER_H_ | 5 #ifndef UI_EVENTS_GESTURES_GESTURE_RECOGNIZER_H_ |
6 #define UI_EVENTS_GESTURES_GESTURE_RECOGNIZER_H_ | 6 #define UI_EVENTS_GESTURES_GESTURE_RECOGNIZER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
11 #include "ui/events/event_constants.h" | 11 #include "ui/events/event_constants.h" |
12 #include "ui/events/events_export.h" | 12 #include "ui/events/events_export.h" |
13 #include "ui/events/gestures/gesture_types.h" | 13 #include "ui/events/gestures/gesture_types.h" |
14 #include "ui/gfx/geometry/point_f.h" | 14 #include "ui/gfx/geometry/point_f.h" |
15 | 15 |
16 namespace ui { | 16 namespace ui { |
17 // A GestureRecognizer is an abstract base class for conversion of touch events | 17 // A GestureRecognizer is an abstract base class for conversion of touch events |
18 // into gestures. | 18 // into gestures. |
19 class EVENTS_EXPORT GestureRecognizer { | 19 class EVENTS_EXPORT GestureRecognizer { |
20 public: | 20 public: |
21 static GestureRecognizer* Create(); | 21 static GestureRecognizer* Create(); |
22 static GestureRecognizer* Get(); | 22 static GestureRecognizer* Get(); |
23 static void Reset(); | 23 static void Reset(); |
24 | 24 |
25 // List of GestureEvent*. | 25 // List of GestureEvent*. |
26 typedef ScopedVector<GestureEvent> Gestures; | 26 typedef ScopedVector<GestureEvent> Gestures; |
27 | 27 |
28 virtual ~GestureRecognizer() {} | 28 virtual ~GestureRecognizer() {} |
29 | 29 |
30 // Invoked for each touch event that could contribute to the current gesture. | 30 virtual bool ProcessTouchEventPreDispatch(const TouchEvent& event, |
31 // Returns list of zero or more GestureEvents identified after processing | 31 GestureConsumer* consumer) = 0; |
32 // TouchEvent. | 32 virtual Gestures* ProcessTouchEventPostDispatch(const TouchEvent& event, |
jdduke (slow)
2014/08/01 14:27:22
This is great! Probably worth keeping the comment
tdresser
2014/08/01 18:54:00
Done.
| |
33 // Caller would be responsible for freeing up Gestures. | 33 ui::EventResult result, |
34 virtual Gestures* ProcessTouchEventForGesture(const TouchEvent& event, | 34 GestureConsumer* consumer) = 0; |
35 ui::EventResult result, | 35 virtual Gestures* ProcessTouchEventOnAsyncAck(const TouchEvent& event, |
36 GestureConsumer* consumer) = 0; | 36 ui::EventResult result, |
37 GestureConsumer* consumer) = 0; | |
37 | 38 |
38 // This is called when the consumer is destroyed. So this should cleanup any | 39 // This is called when the consumer is destroyed. So this should cleanup any |
39 // internal state maintained for |consumer|. Returns true iff there was | 40 // internal state maintained for |consumer|. Returns true iff there was |
40 // state relating to |consumer| to clean up. | 41 // state relating to |consumer| to clean up. |
41 virtual bool CleanupStateForConsumer(GestureConsumer* consumer) = 0; | 42 virtual bool CleanupStateForConsumer(GestureConsumer* consumer) = 0; |
42 | 43 |
43 // Return the window which should handle this TouchEvent, in the case where | 44 // Return the window which should handle this TouchEvent, in the case where |
44 // the touch is already associated with a target. | 45 // the touch is already associated with a target. |
45 // Otherwise, returns null. | 46 // Otherwise, returns null. |
46 virtual GestureConsumer* GetTouchLockedTarget(const TouchEvent& event) = 0; | 47 virtual GestureConsumer* GetTouchLockedTarget(const TouchEvent& event) = 0; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 | 85 |
85 // Unsubscribes |helper| from async gesture dispatch. | 86 // Unsubscribes |helper| from async gesture dispatch. |
86 // Since the GestureRecognizer does not own the |helper|, it is not deleted | 87 // Since the GestureRecognizer does not own the |helper|, it is not deleted |
87 // and must be cleaned up appropriately by the caller. | 88 // and must be cleaned up appropriately by the caller. |
88 virtual void RemoveGestureEventHelper(GestureEventHelper* helper) = 0; | 89 virtual void RemoveGestureEventHelper(GestureEventHelper* helper) = 0; |
89 }; | 90 }; |
90 | 91 |
91 } // namespace ui | 92 } // namespace ui |
92 | 93 |
93 #endif // UI_EVENTS_GESTURES_GESTURE_RECOGNIZER_H_ | 94 #endif // UI_EVENTS_GESTURES_GESTURE_RECOGNIZER_H_ |
OLD | NEW |