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_MOTION_EVENT_H_ | 5 #ifndef UI_EVENTS_GESTURE_DETECTION_MOTION_EVENT_H_ |
6 #define UI_EVENTS_GESTURE_DETECTION_MOTION_EVENT_H_ | 6 #define UI_EVENTS_GESTURE_DETECTION_MOTION_EVENT_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "ui/events/gesture_detection/gesture_detection_export.h" | 10 #include "ui/events/gesture_detection/gesture_detection_export.h" |
(...skipping 28 matching lines...) Expand all Loading... | |
39 BUTTON_BACK = 1 << 3, | 39 BUTTON_BACK = 1 << 3, |
40 BUTTON_FORWARD = 1 << 4, | 40 BUTTON_FORWARD = 1 << 4, |
41 }; | 41 }; |
42 | 42 |
43 // The implementer promises that |GetPointerId()| will never exceed | 43 // The implementer promises that |GetPointerId()| will never exceed |
44 // MAX_POINTER_ID. | 44 // MAX_POINTER_ID. |
45 enum { MAX_POINTER_ID = 31, MAX_TOUCH_POINT_COUNT = 16 }; | 45 enum { MAX_POINTER_ID = 31, MAX_TOUCH_POINT_COUNT = 16 }; |
46 | 46 |
47 virtual ~MotionEvent() {} | 47 virtual ~MotionEvent() {} |
48 | 48 |
49 virtual int GetId() const = 0; | 49 |
50 // An unique identifier this motion event. | |
51 virtual uint64 GetUniqueEventId() const = 0; | |
50 virtual Action GetAction() const = 0; | 52 virtual Action GetAction() const = 0; |
51 // Only valid if |GetAction()| returns ACTION_POINTER_UP or | 53 // Only valid if |GetAction()| returns ACTION_POINTER_UP or |
52 // ACTION_POINTER_DOWN. | 54 // ACTION_POINTER_DOWN. |
53 virtual int GetActionIndex() const = 0; | 55 virtual int GetActionIndex() const = 0; |
54 virtual size_t GetPointerCount() const = 0; | 56 virtual size_t GetPointerCount() const = 0; |
55 virtual int GetPointerId(size_t pointer_index) const = 0; | 57 virtual int GetPointerId(size_t pointer_index) const = 0; |
56 virtual float GetX(size_t pointer_index) const = 0; | 58 virtual float GetX(size_t pointer_index) const = 0; |
57 virtual float GetY(size_t pointer_index) const = 0; | 59 virtual float GetY(size_t pointer_index) const = 0; |
58 virtual float GetRawX(size_t pointer_index) const = 0; | 60 virtual float GetRawX(size_t pointer_index) const = 0; |
59 virtual float GetRawY(size_t pointer_index) const = 0; | 61 virtual float GetRawY(size_t pointer_index) const = 0; |
(...skipping 13 matching lines...) Expand all Loading... | |
73 size_t historical_index) const; | 75 size_t historical_index) const; |
74 virtual float GetHistoricalX(size_t pointer_index, | 76 virtual float GetHistoricalX(size_t pointer_index, |
75 size_t historical_index) const; | 77 size_t historical_index) const; |
76 virtual float GetHistoricalY(size_t pointer_index, | 78 virtual float GetHistoricalY(size_t pointer_index, |
77 size_t historical_index) const; | 79 size_t historical_index) const; |
78 | 80 |
79 // Get the id of the device which created the event. Currently Aura only. | 81 // Get the id of the device which created the event. Currently Aura only. |
80 virtual int GetSourceDeviceId(size_t pointer_index) const; | 82 virtual int GetSourceDeviceId(size_t pointer_index) const; |
81 | 83 |
82 // Utility accessor methods for convenience. | 84 // Utility accessor methods for convenience. |
85 int GetPointerId() const { return GetPointerId(0); } | |
83 float GetX() const { return GetX(0); } | 86 float GetX() const { return GetX(0); } |
84 float GetY() const { return GetY(0); } | 87 float GetY() const { return GetY(0); } |
85 float GetRawX() const { return GetRawX(0); } | 88 float GetRawX() const { return GetRawX(0); } |
86 float GetRawY() const { return GetRawY(0); } | 89 float GetRawY() const { return GetRawY(0); } |
87 float GetRawOffsetX() const { return GetRawX() - GetX(); } | 90 float GetRawOffsetX() const { return GetRawX() - GetX(); } |
88 float GetRawOffsetY() const { return GetRawY() - GetY(); } | 91 float GetRawOffsetY() const { return GetRawY() - GetY(); } |
89 | 92 |
90 float GetTouchMajor() const { return GetTouchMajor(0); } | 93 float GetTouchMajor() const { return GetTouchMajor(0); } |
91 float GetTouchMinor() const { return GetTouchMinor(0); } | 94 float GetTouchMinor() const { return GetTouchMinor(0); } |
92 | 95 |
93 // Returns the orientation of the major axis clockwise from vertical, in | 96 // Returns the orientation of the major axis clockwise from vertical, in |
94 // radians. The return value lies in [-PI/2, PI/2]. | 97 // radians. The return value lies in [-PI/2, PI/2]. |
95 float GetOrientation() const { return GetOrientation(0); } | 98 float GetOrientation() const { return GetOrientation(0); } |
96 | 99 |
97 float GetPressure() const { return GetPressure(0); } | 100 float GetPressure() const { return GetPressure(0); } |
98 ToolType GetToolType() const { return GetToolType(0); } | 101 ToolType GetToolType() const { return GetToolType(0); } |
99 | 102 |
100 // O(N) search of pointers (use sparingly!). Returns -1 if |id| nonexistent. | 103 // O(N) search of pointers (use sparingly!). Returns -1 if |id| nonexistent. |
101 int FindPointerIndexOfId(int id) const; | 104 int FindPointerIndexOfId(int id) const; |
102 | 105 |
103 // Note that these methods perform shallow copies of the originating events. | 106 // Note that these methods perform shallow copies of the originating events. |
104 // They guarantee only that the returned type will reflect the same | 107 // They guarantee only that the returned type will reflect the same |
105 // data exposed by the MotionEvent interface; no guarantees are made that the | 108 // data exposed by the MotionEvent interface; no guarantees are made that the |
106 // underlying implementation is identical to the source implementation. | 109 // underlying implementation is identical to the source implementation. |
107 scoped_ptr<MotionEvent> Clone() const; | 110 scoped_ptr<MotionEvent> Clone() const; |
jdduke (slow)
2015/04/17 20:30:01
So what's the right thing to do if/when we Clone t
lanwei
2015/04/20 19:58:59
We can just copy the unique_event_id when we clone
| |
108 scoped_ptr<MotionEvent> Cancel() const; | 111 scoped_ptr<MotionEvent> Cancel() const; |
109 }; | 112 }; |
110 | 113 |
111 } // namespace ui | 114 } // namespace ui |
112 | 115 |
113 #endif // UI_EVENTS_GESTURE_DETECTION_MOTION_EVENT_H_ | 116 #endif // UI_EVENTS_GESTURE_DETECTION_MOTION_EVENT_H_ |
OLD | NEW |