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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // Optional historical data, default implementation provides an empty history. | 69 // Optional historical data, default implementation provides an empty history. |
70 virtual size_t GetHistorySize() const; | 70 virtual size_t GetHistorySize() const; |
71 virtual base::TimeTicks GetHistoricalEventTime(size_t historical_index) const; | 71 virtual base::TimeTicks GetHistoricalEventTime(size_t historical_index) const; |
72 virtual float GetHistoricalTouchMajor(size_t pointer_index, | 72 virtual float GetHistoricalTouchMajor(size_t pointer_index, |
73 size_t historical_index) const; | 73 size_t historical_index) const; |
74 virtual float GetHistoricalX(size_t pointer_index, | 74 virtual float GetHistoricalX(size_t pointer_index, |
75 size_t historical_index) const; | 75 size_t historical_index) const; |
76 virtual float GetHistoricalY(size_t pointer_index, | 76 virtual float GetHistoricalY(size_t pointer_index, |
77 size_t historical_index) const; | 77 size_t historical_index) const; |
78 | 78 |
79 virtual scoped_ptr<MotionEvent> Clone() const = 0; | 79 // Utility accessor methods for convenience. |
80 virtual scoped_ptr<MotionEvent> Cancel() const = 0; | |
81 | |
82 float GetX() const { return GetX(0); } | 80 float GetX() const { return GetX(0); } |
83 float GetY() const { return GetY(0); } | 81 float GetY() const { return GetY(0); } |
84 float GetRawX() const { return GetRawX(0); } | 82 float GetRawX() const { return GetRawX(0); } |
85 float GetRawY() const { return GetRawY(0); } | 83 float GetRawY() const { return GetRawY(0); } |
86 float GetRawOffsetX() const { return GetRawX() - GetX(); } | 84 float GetRawOffsetX() const { return GetRawX() - GetX(); } |
87 float GetRawOffsetY() const { return GetRawY() - GetY(); } | 85 float GetRawOffsetY() const { return GetRawY() - GetY(); } |
88 | 86 |
89 float GetTouchMajor() const { return GetTouchMajor(0); } | 87 float GetTouchMajor() const { return GetTouchMajor(0); } |
90 float GetTouchMinor() const { return GetTouchMinor(0); } | 88 float GetTouchMinor() const { return GetTouchMinor(0); } |
91 | 89 |
92 // Returns the orientation of the major axis clockwise from vertical, in | 90 // Returns the orientation of the major axis clockwise from vertical, in |
93 // radians. The return value lies in [-PI/2, PI/2]. | 91 // radians. The return value lies in [-PI/2, PI/2]. |
94 float GetOrientation() const { return GetOrientation(0); } | 92 float GetOrientation() const { return GetOrientation(0); } |
95 | 93 |
96 float GetPressure() const { return GetPressure(0); } | 94 float GetPressure() const { return GetPressure(0); } |
97 ToolType GetToolType() const { return GetToolType(0); } | 95 ToolType GetToolType() const { return GetToolType(0); } |
98 | 96 |
99 // O(N) search of pointers (use sparingly!). Returns -1 if |id| nonexistent. | 97 // O(N) search of pointers (use sparingly!). Returns -1 if |id| nonexistent. |
100 int FindPointerIndexOfId(int id) const; | 98 int FindPointerIndexOfId(int id) const; |
| 99 |
| 100 // Note that these methods perform shallow copies of the originating events. |
| 101 // They guarantee only that the returned type will reflect the same |
| 102 // data exposed by the MotionEvent interface; no guarantees are made that the |
| 103 // underlying implementation is identical to the source implementation. |
| 104 scoped_ptr<MotionEvent> Clone() const; |
| 105 scoped_ptr<MotionEvent> Cancel() const; |
101 }; | 106 }; |
102 | 107 |
103 GESTURE_DETECTION_EXPORT bool operator==(const MotionEvent& lhs, | |
104 const MotionEvent& rhs); | |
105 GESTURE_DETECTION_EXPORT bool operator!=(const MotionEvent& lhs, | |
106 const MotionEvent& rhs); | |
107 | |
108 } // namespace ui | 108 } // namespace ui |
109 | 109 |
110 #endif // UI_EVENTS_GESTURE_DETECTION_MOTION_EVENT_H_ | 110 #endif // UI_EVENTS_GESTURE_DETECTION_MOTION_EVENT_H_ |
OLD | NEW |