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_UI_MOTION_EVENT_GENERIC_H_ | 5 #ifndef UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_GENERIC_H_ |
6 #define UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_GENERIC_H_ | 6 #define UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_GENERIC_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/containers/stack_container.h" | 9 #include "base/containers/stack_container.h" |
10 #include "base/memory/scoped_vector.h" | |
10 #include "ui/events/gesture_detection/gesture_detection_export.h" | 11 #include "ui/events/gesture_detection/gesture_detection_export.h" |
11 #include "ui/events/gesture_detection/motion_event.h" | 12 #include "ui/events/gesture_detection/motion_event.h" |
12 | 13 |
13 namespace ui { | 14 namespace ui { |
14 | 15 |
15 struct GESTURE_DETECTION_EXPORT PointerProperties { | 16 struct GESTURE_DETECTION_EXPORT PointerProperties { |
16 PointerProperties(); | 17 PointerProperties(); |
17 PointerProperties(float x, float y); | 18 PointerProperties(float x, float y, float touch_major); |
19 PointerProperties(const MotionEvent& event, size_t pointer_index); | |
18 | 20 |
19 int id; | 21 int id; |
20 MotionEvent::ToolType tool_type; | 22 MotionEvent::ToolType tool_type; |
21 float x; | 23 float x; |
22 float y; | 24 float y; |
23 float raw_x; | 25 float raw_x; |
24 float raw_y; | 26 float raw_y; |
25 float pressure; | 27 float pressure; |
26 float touch_major; | 28 float touch_major; |
27 float touch_minor; | 29 float touch_minor; |
28 float orientation; | 30 float orientation; |
29 }; | 31 }; |
30 | 32 |
31 // A generic MotionEvent implementation. | 33 // A generic MotionEvent implementation. |
32 class GESTURE_DETECTION_EXPORT MotionEventGeneric : public MotionEvent { | 34 class GESTURE_DETECTION_EXPORT MotionEventGeneric : public MotionEvent { |
33 public: | 35 public: |
34 MotionEventGeneric(Action action, | 36 MotionEventGeneric(Action action, |
35 base::TimeTicks event_time, | 37 base::TimeTicks event_time, |
36 const PointerProperties& pointer); | 38 const PointerProperties& pointer); |
37 MotionEventGeneric(const MotionEventGeneric& other); | 39 MotionEventGeneric(const MotionEventGeneric& event); |
38 | 40 |
39 virtual ~MotionEventGeneric(); | 41 virtual ~MotionEventGeneric(); |
40 | 42 |
41 // MotionEvent implementation. | 43 // MotionEvent implementation. |
42 virtual int GetId() const override; | 44 virtual int GetId() const override; |
43 virtual Action GetAction() const override; | 45 virtual Action GetAction() const override; |
44 virtual int GetActionIndex() const override; | 46 virtual int GetActionIndex() const override; |
45 virtual size_t GetPointerCount() const override; | 47 virtual size_t GetPointerCount() const override; |
46 virtual int GetPointerId(size_t pointer_index) const override; | 48 virtual int GetPointerId(size_t pointer_index) const override; |
47 virtual float GetX(size_t pointer_index) const override; | 49 virtual float GetX(size_t pointer_index) const override; |
48 virtual float GetY(size_t pointer_index) const override; | 50 virtual float GetY(size_t pointer_index) const override; |
49 virtual float GetRawX(size_t pointer_index) const override; | 51 virtual float GetRawX(size_t pointer_index) const override; |
50 virtual float GetRawY(size_t pointer_index) const override; | 52 virtual float GetRawY(size_t pointer_index) const override; |
51 virtual float GetTouchMajor(size_t pointer_index) const override; | 53 virtual float GetTouchMajor(size_t pointer_index) const override; |
52 virtual float GetTouchMinor(size_t pointer_index) const override; | 54 virtual float GetTouchMinor(size_t pointer_index) const override; |
53 virtual float GetOrientation(size_t pointer_index) const override; | 55 virtual float GetOrientation(size_t pointer_index) const override; |
54 virtual float GetPressure(size_t pointer_index) const override; | 56 virtual float GetPressure(size_t pointer_index) const override; |
55 virtual ToolType GetToolType(size_t pointer_index) const override; | 57 virtual ToolType GetToolType(size_t pointer_index) const override; |
56 virtual int GetButtonState() const override; | 58 virtual int GetButtonState() const override; |
57 virtual int GetFlags() const override; | 59 virtual int GetFlags() const override; |
58 virtual base::TimeTicks GetEventTime() const override; | 60 virtual base::TimeTicks GetEventTime() const override; |
59 virtual scoped_ptr<MotionEvent> Clone() const override; | 61 virtual size_t GetHistorySize() const override; |
60 virtual scoped_ptr<MotionEvent> Cancel() const override; | 62 virtual base::TimeTicks GetHistoricalEventTime( |
63 size_t historical_index) const override; | |
64 virtual float GetHistoricalTouchMajor(size_t pointer_index, | |
65 size_t historical_index) const override; | |
66 virtual float GetHistoricalX(size_t pointer_index, | |
67 size_t historical_index) const override; | |
68 virtual float GetHistoricalY(size_t pointer_index, | |
69 size_t historical_index) const override; | |
61 | 70 |
62 void PushPointer(const PointerProperties& pointer); | 71 void PushPointer(const PointerProperties& pointer); |
63 | 72 |
73 // Add an event to the history. Note that |event| must have the same | |
74 // pointer count, and must be of the same type (ACTION_MOVE), as this event. | |
tdresser
2014/10/20 15:19:15
This is a little confusing.
Based on the code, pe
jdduke (slow)
2014/10/21 22:19:58
Done.
| |
75 void PushHistoricalEvent(scoped_ptr<MotionEvent> event); | |
76 | |
64 void set_action(Action action) { action_ = action; } | 77 void set_action(Action action) { action_ = action; } |
65 void set_event_time(base::TimeTicks event_time) { event_time_ = event_time; } | 78 void set_event_time(base::TimeTicks event_time) { event_time_ = event_time; } |
66 void set_id(int id) { id_ = id; } | 79 void set_id(int id) { id_ = id; } |
67 void set_action_index(int action_index) { action_index_ = action_index; } | 80 void set_action_index(int action_index) { action_index_ = action_index; } |
68 void set_button_state(int button_state) { button_state_ = button_state; } | 81 void set_button_state(int button_state) { button_state_ = button_state; } |
69 void set_flags(int flags) { flags_ = flags; } | 82 void set_flags(int flags) { flags_ = flags; } |
70 | 83 |
84 static scoped_ptr<MotionEventGeneric> CloneEvent(const MotionEvent& event); | |
85 static scoped_ptr<MotionEventGeneric> CancelEvent(const MotionEvent& event); | |
86 | |
71 protected: | 87 protected: |
72 MotionEventGeneric(); | 88 MotionEventGeneric(); |
89 MotionEventGeneric(const MotionEvent& event, bool with_history); | |
90 MotionEventGeneric& operator=(const MotionEventGeneric& other); | |
73 | 91 |
74 void PopPointer(); | 92 void PopPointer(); |
75 | 93 |
76 PointerProperties& pointer(size_t index) { return pointers_[index]; } | 94 PointerProperties& pointer(size_t index) { return pointers_[index]; } |
77 const PointerProperties& pointer(size_t index) const { | 95 const PointerProperties& pointer(size_t index) const { |
78 return pointers_[index]; | 96 return pointers_[index]; |
79 } | 97 } |
80 | 98 |
81 private: | 99 private: |
82 enum { kTypicalMaxPointerCount = 5 }; | 100 enum { kTypicalMaxPointerCount = 5 }; |
83 | 101 |
84 Action action_; | 102 Action action_; |
85 base::TimeTicks event_time_; | 103 base::TimeTicks event_time_; |
86 int id_; | 104 int id_; |
87 int action_index_; | 105 int action_index_; |
88 int button_state_; | 106 int button_state_; |
89 int flags_; | 107 int flags_; |
90 base::StackVector<PointerProperties, kTypicalMaxPointerCount> pointers_; | 108 base::StackVector<PointerProperties, kTypicalMaxPointerCount> pointers_; |
109 ScopedVector<MotionEvent> historical_events_; | |
91 }; | 110 }; |
92 | 111 |
93 } // namespace ui | 112 } // namespace ui |
94 | 113 |
95 #endif // UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_GENERIC_H_ | 114 #endif // UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_GENERIC_H_ |
OLD | NEW |