| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/memory/scoped_vector.h" | |
| 13 #include "ui/events/event_constants.h" | 13 #include "ui/events/event_constants.h" |
| 14 #include "ui/events/events_export.h" | 14 #include "ui/events/events_export.h" |
| 15 #include "ui/events/gestures/gesture_types.h" | 15 #include "ui/events/gestures/gesture_types.h" |
| 16 #include "ui/gfx/geometry/point_f.h" | 16 #include "ui/gfx/geometry/point_f.h" |
| 17 | 17 |
| 18 namespace ui { | 18 namespace ui { |
| 19 // A GestureRecognizer is an abstract base class for conversion of touch events | 19 // A GestureRecognizer is an abstract base class for conversion of touch events |
| 20 // into gestures. | 20 // into gestures. |
| 21 class EVENTS_EXPORT GestureRecognizer { | 21 class EVENTS_EXPORT GestureRecognizer { |
| 22 public: | 22 public: |
| 23 static GestureRecognizer* Create(); | 23 static GestureRecognizer* Create(); |
| 24 static GestureRecognizer* Get(); | 24 static GestureRecognizer* Get(); |
| 25 static void Reset(); | 25 static void Reset(); |
| 26 | 26 |
| 27 // List of GestureEvent*. | 27 using Gestures = std::vector<std::unique_ptr<GestureEvent>>; |
| 28 typedef ScopedVector<GestureEvent> Gestures; | |
| 29 | 28 |
| 30 virtual ~GestureRecognizer() {} | 29 virtual ~GestureRecognizer() {} |
| 31 | 30 |
| 32 // Invoked before event dispatch. If the event is invalid given the current | 31 // Invoked before event dispatch. If the event is invalid given the current |
| 33 // touch sequence, returns false. | 32 // touch sequence, returns false. |
| 34 virtual bool ProcessTouchEventPreDispatch(TouchEvent* event, | 33 virtual bool ProcessTouchEventPreDispatch(TouchEvent* event, |
| 35 GestureConsumer* consumer) = 0; | 34 GestureConsumer* consumer) = 0; |
| 36 | 35 |
| 37 // Returns a list of zero or more GestureEvents. The caller is responsible for | 36 // Returns a list of zero or more GestureEvents. Acks the gesture packet in |
| 38 // freeing the returned events. Acks the gesture packet in the queue which | 37 // the queue which matches with unique_event_id. |
| 39 // matches with unique_event_id. | 38 virtual Gestures AckTouchEvent(uint32_t unique_event_id, |
| 40 virtual Gestures* AckTouchEvent(uint32_t unique_event_id, | 39 ui::EventResult result, |
| 41 ui::EventResult result, | 40 GestureConsumer* consumer) = 0; |
| 42 GestureConsumer* consumer) = 0; | |
| 43 | 41 |
| 44 // This is called when the consumer is destroyed. So this should cleanup any | 42 // This is called when the consumer is destroyed. So this should cleanup any |
| 45 // internal state maintained for |consumer|. Returns true iff there was | 43 // internal state maintained for |consumer|. Returns true iff there was |
| 46 // state relating to |consumer| to clean up. | 44 // state relating to |consumer| to clean up. |
| 47 virtual bool CleanupStateForConsumer(GestureConsumer* consumer) = 0; | 45 virtual bool CleanupStateForConsumer(GestureConsumer* consumer) = 0; |
| 48 | 46 |
| 49 // Return the window which should handle this TouchEvent, in the case where | 47 // Return the window which should handle this TouchEvent, in the case where |
| 50 // the touch is already associated with a target. | 48 // the touch is already associated with a target. |
| 51 // Otherwise, returns null. | 49 // Otherwise, returns null. |
| 52 virtual GestureConsumer* GetTouchLockedTarget(const TouchEvent& event) = 0; | 50 virtual GestureConsumer* GetTouchLockedTarget(const TouchEvent& event) = 0; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 88 |
| 91 // Unsubscribes |helper| from async gesture dispatch. | 89 // Unsubscribes |helper| from async gesture dispatch. |
| 92 // Since the GestureRecognizer does not own the |helper|, it is not deleted | 90 // Since the GestureRecognizer does not own the |helper|, it is not deleted |
| 93 // and must be cleaned up appropriately by the caller. | 91 // and must be cleaned up appropriately by the caller. |
| 94 virtual void RemoveGestureEventHelper(GestureEventHelper* helper) = 0; | 92 virtual void RemoveGestureEventHelper(GestureEventHelper* helper) = 0; |
| 95 }; | 93 }; |
| 96 | 94 |
| 97 } // namespace ui | 95 } // namespace ui |
| 98 | 96 |
| 99 #endif // UI_EVENTS_GESTURES_GESTURE_RECOGNIZER_H_ | 97 #endif // UI_EVENTS_GESTURES_GESTURE_RECOGNIZER_H_ |
| OLD | NEW |