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_BASE_GESTURES_GESTURE_RECOGNIZER_IMPL_H_ | 5 #ifndef UI_BASE_GESTURES_GESTURE_RECOGNIZER_IMPL_H_ |
6 #define UI_BASE_GESTURES_GESTURE_RECOGNIZER_IMPL_H_ | 6 #define UI_BASE_GESTURES_GESTURE_RECOGNIZER_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <queue> | |
10 #include <vector> | 9 #include <vector> |
11 | 10 |
12 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
13 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
14 #include "ui/base/events/event_constants.h" | 13 #include "ui/base/events/event_constants.h" |
15 #include "ui/base/gestures/gesture_recognizer.h" | 14 #include "ui/base/gestures/gesture_recognizer.h" |
16 #include "ui/base/ui_export.h" | 15 #include "ui/base/ui_export.h" |
17 #include "ui/gfx/point.h" | 16 #include "ui/gfx/point.h" |
18 | 17 |
19 namespace ui { | 18 namespace ui { |
(...skipping 22 matching lines...) Expand all Loading... |
42 gfx::Point* point) OVERRIDE; | 41 gfx::Point* point) OVERRIDE; |
43 | 42 |
44 protected: | 43 protected: |
45 virtual GestureSequence* CreateSequence(GestureEventHelper* helper); | 44 virtual GestureSequence* CreateSequence(GestureEventHelper* helper); |
46 virtual GestureSequence* GetGestureSequenceForConsumer(GestureConsumer* c); | 45 virtual GestureSequence* GetGestureSequenceForConsumer(GestureConsumer* c); |
47 | 46 |
48 private: | 47 private: |
49 // Sets up the target consumer for gestures based on the touch-event. | 48 // Sets up the target consumer for gestures based on the touch-event. |
50 void SetupTargets(const TouchEvent& event, GestureConsumer* consumer); | 49 void SetupTargets(const TouchEvent& event, GestureConsumer* consumer); |
51 | 50 |
52 // Processes the next queued touch-event (and discards the touch-event). The | |
53 // called must take ownership of the returned gestures and free them when they | |
54 // are not needed anymore. | |
55 Gestures* AdvanceTouchQueueByOne(GestureConsumer* consumer, | |
56 ui::EventResult result); | |
57 | |
58 // Overridden from GestureRecognizer | 51 // Overridden from GestureRecognizer |
59 virtual Gestures* ProcessTouchEventForGesture( | 52 virtual Gestures* ProcessTouchEventForGesture( |
60 const TouchEvent& event, | 53 const TouchEvent& event, |
61 ui::EventResult result, | 54 ui::EventResult result, |
62 GestureConsumer* target) OVERRIDE; | 55 GestureConsumer* target) OVERRIDE; |
63 virtual void QueueTouchEventForGesture(GestureConsumer* consumer, | 56 virtual void CleanupStateForConsumer(GestureConsumer* consumer) OVERRIDE; |
64 const TouchEvent& event) OVERRIDE; | |
65 virtual Gestures* AdvanceTouchQueue(GestureConsumer* consumer, | |
66 bool processed) OVERRIDE; | |
67 virtual void FlushTouchQueue(GestureConsumer* consumer) OVERRIDE; | |
68 | 57 |
69 typedef std::queue<TouchEvent*> TouchEventQueue; | |
70 std::map<GestureConsumer*, TouchEventQueue*> event_queue_; | |
71 std::map<GestureConsumer*, GestureSequence*> consumer_sequence_; | 58 std::map<GestureConsumer*, GestureSequence*> consumer_sequence_; |
72 | 59 |
73 // Both |touch_id_target_| and |touch_id_target_for_gestures_| map a touch-id | 60 // Both |touch_id_target_| and |touch_id_target_for_gestures_| map a touch-id |
74 // to its target window. touch-ids are removed from |touch_id_target_| on | 61 // to its target window. touch-ids are removed from |touch_id_target_| on |
75 // ET_TOUCH_RELEASE and ET_TOUCH_CANCEL. |touch_id_target_for_gestures_| are | 62 // ET_TOUCH_RELEASE and ET_TOUCH_CANCEL. |touch_id_target_for_gestures_| are |
76 // removed in FlushTouchQueue(). | 63 // removed in ConsumerDestroyed(). |
77 TouchIdToConsumerMap touch_id_target_; | 64 TouchIdToConsumerMap touch_id_target_; |
78 TouchIdToConsumerMap touch_id_target_for_gestures_; | 65 TouchIdToConsumerMap touch_id_target_for_gestures_; |
79 | 66 |
80 // Touches cancelled by touch capture are routed to the | 67 // Touches cancelled by touch capture are routed to the |
81 // gesture_consumer_ignorer_. | 68 // gesture_consumer_ignorer_. |
82 scoped_ptr<GestureConsumer> gesture_consumer_ignorer_; | 69 scoped_ptr<GestureConsumer> gesture_consumer_ignorer_; |
83 GestureEventHelper* helper_; | 70 GestureEventHelper* helper_; |
84 | 71 |
85 DISALLOW_COPY_AND_ASSIGN(GestureRecognizerImpl); | 72 DISALLOW_COPY_AND_ASSIGN(GestureRecognizerImpl); |
86 }; | 73 }; |
87 | 74 |
88 } // namespace ui | 75 } // namespace ui |
89 | 76 |
90 #endif // UI_BASE_GESTURES_GESTURE_RECOGNIZER_IMPL_H_ | 77 #endif // UI_BASE_GESTURES_GESTURE_RECOGNIZER_IMPL_H_ |
OLD | NEW |