Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: ui/events/gestures/gesture_recognizer.h

Issue 1287103004: Sync ui/events to chromium @ https://codereview.chromium.org/1210203002 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 10 matching lines...) Expand all
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 before event dispatch. If the event is invalid given the current 30 // Invoked before event dispatch. If the event is invalid given the current
31 // touch sequence, marks it as handled. 31 // touch sequence, returns false.
32 virtual bool ProcessTouchEventPreDispatch(const TouchEvent& event, 32 virtual bool ProcessTouchEventPreDispatch(TouchEvent* event,
33 GestureConsumer* consumer) = 0; 33 GestureConsumer* consumer) = 0;
34
34 // Returns a list of zero or more GestureEvents. The caller is responsible for 35 // Returns a list of zero or more GestureEvents. The caller is responsible for
35 // freeing the returned events. Called synchronously after event dispatch. 36 // freeing the returned events. Acks the gesture packet in the queue which
36 virtual Gestures* ProcessTouchEventPostDispatch( 37 // matches with unique_event_id.
37 const TouchEvent& event, 38 virtual Gestures* AckTouchEvent(uint32 unique_event_id,
38 ui::EventResult result, 39 ui::EventResult result,
39 GestureConsumer* consumer) = 0; 40 GestureConsumer* consumer) = 0;
40 // Returns a list of zero or more GestureEvents. The caller is responsible for
41 // freeing the returned events. Called when a touch event receives an
42 // asynchronous ack.
43 virtual Gestures* ProcessTouchEventOnAsyncAck(const TouchEvent& event,
44 ui::EventResult result,
45 GestureConsumer* consumer) = 0;
46 41
47 // 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
48 // internal state maintained for |consumer|. Returns true iff there was 43 // internal state maintained for |consumer|. Returns true iff there was
49 // state relating to |consumer| to clean up. 44 // state relating to |consumer| to clean up.
50 virtual bool CleanupStateForConsumer(GestureConsumer* consumer) = 0; 45 virtual bool CleanupStateForConsumer(GestureConsumer* consumer) = 0;
51 46
52 // 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
53 // the touch is already associated with a target. 48 // the touch is already associated with a target.
54 // Otherwise, returns null. 49 // Otherwise, returns null.
55 virtual GestureConsumer* GetTouchLockedTarget(const TouchEvent& event) = 0; 50 virtual GestureConsumer* GetTouchLockedTarget(const TouchEvent& event) = 0;
56 51
57 // Return the window which should handle this GestureEvent. 52 // Return the window which should handle this GestureEvent.
58 virtual GestureConsumer* GetTargetForGestureEvent( 53 virtual GestureConsumer* GetTargetForGestureEvent(
59 const GestureEvent& event) = 0; 54 const GestureEvent& event) = 0;
60 55
61 // Returns the target of the nearest active touch with source device of 56 // Returns the target of the nearest active touch with source device of
62 // |source_device_id|, within 57 // |source_device_id|, within
63 // GestureConfiguration::max_separation_for_gesture_touches_in_pixels of 58 // GestureConfiguration::max_separation_for_gesture_touches_in_pixels of
64 // |location|, or NULL if no such point exists. 59 // |location|, or NULL if no such point exists.
65 virtual GestureConsumer* GetTargetForLocation( 60 virtual GestureConsumer* GetTargetForLocation(
66 const gfx::PointF& location, int source_device_id) = 0; 61 const gfx::PointF& location, int source_device_id) = 0;
67 62
63 // Cancels all touches except those targeted to |not_cancelled|. If
64 // |not_cancelled| == nullptr, cancels all touches.
65 virtual void CancelActiveTouchesExcept(GestureConsumer* not_cancelled) = 0;
66
68 // Makes |new_consumer| the target for events previously targeting 67 // Makes |new_consumer| the target for events previously targeting
69 // |current_consumer|. All other targets are canceled. 68 // |current_consumer|. Touches targeting all other targets are
70 // The caller is responsible for updating the state of the consumers to 69 // canceled. The caller is responsible for updating the state of the
71 // be aware of this transfer of control (there are no ENTERED/EXITED events). 70 // consumers to be aware of this transfer of control (there are no
72 // If |new_consumer| is NULL, all events are canceled. 71 // ENTERED/EXITED events).
73 // If |old_consumer| is NULL, all events not already targeting |new_consumer|
74 // are canceled.
75 virtual void TransferEventsTo(GestureConsumer* current_consumer, 72 virtual void TransferEventsTo(GestureConsumer* current_consumer,
76 GestureConsumer* new_consumer) = 0; 73 GestureConsumer* new_consumer) = 0;
77 74
78 // If a gesture is underway for |consumer| |point| is set to the last touch 75 // If a gesture is underway for |consumer| |point| is set to the last touch
79 // point and true is returned. If no touch events have been processed for 76 // point and true is returned. If no touch events have been processed for
80 // |consumer| false is returned and |point| is untouched. 77 // |consumer| false is returned and |point| is untouched.
81 virtual bool GetLastTouchPointForTarget(GestureConsumer* consumer, 78 virtual bool GetLastTouchPointForTarget(GestureConsumer* consumer,
82 gfx::PointF* point) = 0; 79 gfx::PointF* point) = 0;
83 80
84 // Sends a touch cancel event for every active touch. Returns true iff any 81 // Sends a touch cancel event for every active touch. Returns true iff any
85 // touch cancels were sent. 82 // touch cancels were sent.
86 virtual bool CancelActiveTouches(GestureConsumer* consumer) = 0; 83 virtual bool CancelActiveTouches(GestureConsumer* consumer) = 0;
87 84
88 // Subscribes |helper| for dispatching async gestures such as long press. 85 // Subscribes |helper| for dispatching async gestures such as long press.
89 // The Gesture Recognizer does NOT take ownership of |helper| and it is the 86 // The Gesture Recognizer does NOT take ownership of |helper| and it is the
90 // responsibility of the |helper| to call |RemoveGestureEventHelper()| on 87 // responsibility of the |helper| to call |RemoveGestureEventHelper()| on
91 // destruction. 88 // destruction.
92 virtual void AddGestureEventHelper(GestureEventHelper* helper) = 0; 89 virtual void AddGestureEventHelper(GestureEventHelper* helper) = 0;
93 90
94 // Unsubscribes |helper| from async gesture dispatch. 91 // Unsubscribes |helper| from async gesture dispatch.
95 // Since the GestureRecognizer does not own the |helper|, it is not deleted 92 // Since the GestureRecognizer does not own the |helper|, it is not deleted
96 // and must be cleaned up appropriately by the caller. 93 // and must be cleaned up appropriately by the caller.
97 virtual void RemoveGestureEventHelper(GestureEventHelper* helper) = 0; 94 virtual void RemoveGestureEventHelper(GestureEventHelper* helper) = 0;
98 }; 95 };
99 96
100 } // namespace ui 97 } // namespace ui
101 98
102 #endif // UI_EVENTS_GESTURES_GESTURE_RECOGNIZER_H_ 99 #endif // UI_EVENTS_GESTURES_GESTURE_RECOGNIZER_H_
OLDNEW
« no previous file with comments | « ui/events/gestures/gesture_provider_impl_unittest.cc ('k') | ui/events/gestures/gesture_recognizer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698