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 "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" |
| 11 | 11 |
| 12 namespace ui { | 12 namespace ui { |
| 13 | 13 |
| 14 // Abstract class for a generic motion-related event, patterned after that | 14 // Abstract class for a generic motion-related event, patterned after that |
| 15 // subset of Android's MotionEvent API used in gesture detection. | 15 // subset of Android's MotionEvent API used in gesture detection. |
| 16 class GESTURE_DETECTION_EXPORT MotionEvent { | 16 class GESTURE_DETECTION_EXPORT MotionEvent { |
| 17 public: | 17 public: |
| 18 enum Action { | 18 enum Action { |
| 19 ACTION_DOWN, | 19 ACTION_DOWN = 100, |
|
jdduke (slow)
2014/06/20 15:33:25
Any reason for the 100/200?
Changwan Ryu
2014/06/20 21:00:34
No specific reason. I just wanted to assign SOME d
jdduke (slow)
2014/06/20 21:19:41
I see, let's stick with not assigning them specifi
Changwan Ryu
2014/06/20 21:32:01
Done.
| |
| 20 ACTION_UP, | 20 ACTION_UP, |
| 21 ACTION_MOVE, | 21 ACTION_MOVE, |
| 22 ACTION_CANCEL, | 22 ACTION_CANCEL, |
| 23 ACTION_POINTER_DOWN, | 23 ACTION_POINTER_DOWN, |
| 24 ACTION_POINTER_UP, | 24 ACTION_POINTER_UP, |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 enum ToolType { | |
| 28 TOOL_TYPE_UNKNOWN = 200, | |
| 29 TOOL_TYPE_FINGER, | |
| 30 TOOL_TYPE_STYLUS, | |
| 31 TOOL_TYPE_MOUSE, | |
| 32 }; | |
| 33 | |
| 34 const static int BUTTON_NONE = 0; | |
|
jdduke (slow)
2014/06/20 15:33:25
I would go ahead and use an enum bit mask here, e.
Changwan Ryu
2014/06/20 21:00:34
Done.
| |
| 35 const static int BUTTON_PRIMARY = 1; | |
| 36 const static int BUTTON_SECONDARY = 2; | |
| 37 const static int BUTTON_TERTIARY = 4; | |
| 38 const static int BUTTON_BACK = 8; | |
| 39 const static int BUTTON_FORWARD = 16; | |
| 40 | |
| 27 // The implementer promises that |GetPointerId()| will never exceed this. | 41 // The implementer promises that |GetPointerId()| will never exceed this. |
| 28 enum { MAX_POINTER_ID = 31 }; | 42 enum { MAX_POINTER_ID = 31 }; |
| 29 | 43 |
| 30 virtual ~MotionEvent() {} | 44 virtual ~MotionEvent() {} |
| 31 | 45 |
| 32 virtual int GetId() const = 0; | 46 virtual int GetId() const = 0; |
| 33 virtual Action GetAction() const = 0; | 47 virtual Action GetAction() const = 0; |
| 34 // Only valid if |GetAction()| returns ACTION_POINTER_UP or | 48 // Only valid if |GetAction()| returns ACTION_POINTER_UP or |
| 35 // ACTION_POINTER_DOWN. | 49 // ACTION_POINTER_DOWN. |
| 36 virtual int GetActionIndex() const = 0; | 50 virtual int GetActionIndex() const = 0; |
| 37 virtual size_t GetPointerCount() const = 0; | 51 virtual size_t GetPointerCount() const = 0; |
| 38 virtual int GetPointerId(size_t pointer_index) const = 0; | 52 virtual int GetPointerId(size_t pointer_index) const = 0; |
| 39 virtual float GetX(size_t pointer_index) const = 0; | 53 virtual float GetX(size_t pointer_index) const = 0; |
| 40 virtual float GetY(size_t pointer_index) const = 0; | 54 virtual float GetY(size_t pointer_index) const = 0; |
| 41 virtual float GetRawX(size_t pointer_index) const = 0; | 55 virtual float GetRawX(size_t pointer_index) const = 0; |
| 42 virtual float GetRawY(size_t pointer_index) const = 0; | 56 virtual float GetRawY(size_t pointer_index) const = 0; |
| 43 virtual float GetTouchMajor(size_t pointer_index) const = 0; | 57 virtual float GetTouchMajor(size_t pointer_index) const = 0; |
| 44 virtual float GetPressure(size_t pointer_index) const = 0; | 58 virtual float GetPressure(size_t pointer_index) const = 0; |
| 45 virtual base::TimeTicks GetEventTime() const = 0; | 59 virtual base::TimeTicks GetEventTime() const = 0; |
| 46 | 60 |
| 47 virtual size_t GetHistorySize() const = 0; | 61 virtual size_t GetHistorySize() const = 0; |
| 48 virtual base::TimeTicks GetHistoricalEventTime( | 62 virtual base::TimeTicks GetHistoricalEventTime( |
| 49 size_t historical_index) const = 0; | 63 size_t historical_index) const = 0; |
| 50 virtual float GetHistoricalTouchMajor(size_t pointer_index, | 64 virtual float GetHistoricalTouchMajor(size_t pointer_index, |
| 51 size_t historical_index) const = 0; | 65 size_t historical_index) const = 0; |
| 52 virtual float GetHistoricalX(size_t pointer_index, | 66 virtual float GetHistoricalX(size_t pointer_index, |
| 53 size_t historical_index) const = 0; | 67 size_t historical_index) const = 0; |
| 54 virtual float GetHistoricalY(size_t pointer_index, | 68 virtual float GetHistoricalY(size_t pointer_index, |
| 55 size_t historical_index) const = 0; | 69 size_t historical_index) const = 0; |
| 70 virtual ToolType GetToolType(size_t pointer_index) const = 0; | |
| 71 virtual int GetButtonState() const = 0; | |
| 56 | 72 |
| 57 virtual scoped_ptr<MotionEvent> Clone() const = 0; | 73 virtual scoped_ptr<MotionEvent> Clone() const = 0; |
| 58 virtual scoped_ptr<MotionEvent> Cancel() const = 0; | 74 virtual scoped_ptr<MotionEvent> Cancel() const = 0; |
| 59 | 75 |
| 60 // Utility accessor methods for convenience. | 76 // Utility accessor methods for convenience. |
| 61 float GetX() const { return GetX(0); } | 77 float GetX() const { return GetX(0); } |
| 62 float GetY() const { return GetY(0); } | 78 float GetY() const { return GetY(0); } |
| 63 float GetRawX() const { return GetRawX(0); } | 79 float GetRawX() const { return GetRawX(0); } |
| 64 float GetRawY() const { return GetRawY(0); } | 80 float GetRawY() const { return GetRawY(0); } |
| 65 float GetTouchMajor() const { return GetTouchMajor(0); } | 81 float GetTouchMajor() const { return GetTouchMajor(0); } |
| 66 float GetPressure() const { return GetPressure(0); } | 82 float GetPressure() const { return GetPressure(0); } |
| 67 }; | 83 }; |
| 68 | 84 |
| 69 } // namespace ui | 85 } // namespace ui |
| 70 | 86 |
| 71 #endif // UI_EVENTS_GESTURE_DETECTION_MOTION_EVENT_H_ | 87 #endif // UI_EVENTS_GESTURE_DETECTION_MOTION_EVENT_H_ |
| OLD | NEW |