Chromium Code Reviews| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 virtual size_t GetPointerCount() const = 0; | 69 virtual size_t GetPointerCount() const = 0; |
| 70 virtual int GetPointerId(size_t pointer_index) const = 0; | 70 virtual int GetPointerId(size_t pointer_index) const = 0; |
| 71 virtual float GetX(size_t pointer_index) const = 0; | 71 virtual float GetX(size_t pointer_index) const = 0; |
| 72 virtual float GetY(size_t pointer_index) const = 0; | 72 virtual float GetY(size_t pointer_index) const = 0; |
| 73 virtual float GetRawX(size_t pointer_index) const = 0; | 73 virtual float GetRawX(size_t pointer_index) const = 0; |
| 74 virtual float GetRawY(size_t pointer_index) const = 0; | 74 virtual float GetRawY(size_t pointer_index) const = 0; |
| 75 virtual float GetTouchMajor(size_t pointer_index) const = 0; | 75 virtual float GetTouchMajor(size_t pointer_index) const = 0; |
| 76 virtual float GetTouchMinor(size_t pointer_index) const = 0; | 76 virtual float GetTouchMinor(size_t pointer_index) const = 0; |
| 77 virtual float GetOrientation(size_t pointer_index) const = 0; | 77 virtual float GetOrientation(size_t pointer_index) const = 0; |
| 78 virtual float GetPressure(size_t pointer_index) const = 0; | 78 virtual float GetPressure(size_t pointer_index) const = 0; |
| 79 virtual float GetTilt(size_t pointer_index) const = 0; | 79 virtual float GetTiltX(size_t pointer_index) const = 0; |
| 80 virtual float GetTiltY(size_t pointer_index) const = 0; | |
| 80 virtual ToolType GetToolType(size_t pointer_index) const = 0; | 81 virtual ToolType GetToolType(size_t pointer_index) const = 0; |
| 81 virtual int GetButtonState() const = 0; | 82 virtual int GetButtonState() const = 0; |
| 82 virtual int GetFlags() const = 0; | 83 virtual int GetFlags() const = 0; |
| 83 virtual base::TimeTicks GetEventTime() const = 0; | 84 virtual base::TimeTicks GetEventTime() const = 0; |
| 84 | 85 |
| 85 // Optional historical data, default implementation provides an empty history. | 86 // Optional historical data, default implementation provides an empty history. |
| 86 virtual size_t GetHistorySize() const; | 87 virtual size_t GetHistorySize() const; |
| 87 virtual base::TimeTicks GetHistoricalEventTime(size_t historical_index) const; | 88 virtual base::TimeTicks GetHistoricalEventTime(size_t historical_index) const; |
| 88 virtual float GetHistoricalTouchMajor(size_t pointer_index, | 89 virtual float GetHistoricalTouchMajor(size_t pointer_index, |
| 89 size_t historical_index) const; | 90 size_t historical_index) const; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 105 float GetRawOffsetY() const { return GetRawY() - GetY(); } | 106 float GetRawOffsetY() const { return GetRawY() - GetY(); } |
| 106 | 107 |
| 107 float GetTouchMajor() const { return GetTouchMajor(0); } | 108 float GetTouchMajor() const { return GetTouchMajor(0); } |
| 108 float GetTouchMinor() const { return GetTouchMinor(0); } | 109 float GetTouchMinor() const { return GetTouchMinor(0); } |
| 109 | 110 |
| 110 // Returns the orientation in radians. The meaning is overloaded: | 111 // Returns the orientation in radians. The meaning is overloaded: |
| 111 // * For a touch screen or pad, it's the orientation of the major axis | 112 // * For a touch screen or pad, it's the orientation of the major axis |
| 112 // clockwise from vertical. The return value lies in [-PI/2, PI/2]. | 113 // clockwise from vertical. The return value lies in [-PI/2, PI/2]. |
| 113 // * For a stylus, it indicates the direction in which the stylus is pointing. | 114 // * For a stylus, it indicates the direction in which the stylus is pointing. |
| 114 // The return value lies in [-PI, PI]. | 115 // The return value lies in [-PI, PI]. |
| 116 // Stylus 3D orientation is returned in GetTiltX/Y. TODO: | |
|
sadrul
2017/05/16 19:21:57
Can you assign an owner for the TODO here?
| |
| 117 // Cleanup the stylus comment & usage here. | |
| 115 float GetOrientation() const { return GetOrientation(0); } | 118 float GetOrientation() const { return GetOrientation(0); } |
| 116 | 119 |
| 117 float GetPressure() const { return GetPressure(0); } | 120 float GetPressure() const { return GetPressure(0); } |
| 118 float GetTilt() const { return GetTilt(0); } | 121 // We have GetTiltX/Y here instead of GetTilt because MotionEvent spec is not |
| 122 // expressive enough for both 2D touch-surface geometry and 3D pen-orientation | |
| 123 // geometry, as needed for PointerEvents: | |
| 124 // https://w3c.github.io/pointerevents | |
| 125 // Both GetTiltX and GetTiltY return angles in **degrees**, in the range | |
| 126 // [-90,90]. See the PointerEvent spec link above for details | |
| 127 float GetTiltX() const { return GetTiltX(0); } | |
| 128 float GetTiltY() const { return GetTiltY(0); } | |
| 119 ToolType GetToolType() const { return GetToolType(0); } | 129 ToolType GetToolType() const { return GetToolType(0); } |
| 120 | 130 |
| 121 // O(N) search of pointers (use sparingly!). Returns -1 if |id| nonexistent. | 131 // O(N) search of pointers (use sparingly!). Returns -1 if |id| nonexistent. |
| 122 int FindPointerIndexOfId(int id) const; | 132 int FindPointerIndexOfId(int id) const; |
| 123 | 133 |
| 124 // Note that these methods perform shallow copies of the originating events. | 134 // Note that these methods perform shallow copies of the originating events. |
| 125 // They guarantee only that the returned type will reflect the same | 135 // They guarantee only that the returned type will reflect the same |
| 126 // data exposed by the MotionEvent interface; no guarantees are made that the | 136 // data exposed by the MotionEvent interface; no guarantees are made that the |
| 127 // underlying implementation is identical to the source implementation. | 137 // underlying implementation is identical to the source implementation. |
| 128 std::unique_ptr<MotionEvent> Clone() const; | 138 std::unique_ptr<MotionEvent> Clone() const; |
| 129 std::unique_ptr<MotionEvent> Cancel() const; | 139 std::unique_ptr<MotionEvent> Cancel() const; |
| 130 }; | 140 }; |
| 131 | 141 |
| 132 } // namespace ui | 142 } // namespace ui |
| 133 | 143 |
| 134 #endif // UI_EVENTS_GESTURE_DETECTION_MOTION_EVENT_H_ | 144 #endif // UI_EVENTS_GESTURE_DETECTION_MOTION_EVENT_H_ |
| OLD | NEW |