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; |
(...skipping 21 matching lines...) Expand all Loading... |
49 float GetRawX(size_t pointer_index) const override; | 51 float GetRawX(size_t pointer_index) const override; |
50 float GetRawY(size_t pointer_index) const override; | 52 float GetRawY(size_t pointer_index) const override; |
51 float GetTouchMajor(size_t pointer_index) const override; | 53 float GetTouchMajor(size_t pointer_index) const override; |
52 float GetTouchMinor(size_t pointer_index) const override; | 54 float GetTouchMinor(size_t pointer_index) const override; |
53 float GetOrientation(size_t pointer_index) const override; | 55 float GetOrientation(size_t pointer_index) const override; |
54 float GetPressure(size_t pointer_index) const override; | 56 float GetPressure(size_t pointer_index) const override; |
55 ToolType GetToolType(size_t pointer_index) const override; | 57 ToolType GetToolType(size_t pointer_index) const override; |
56 int GetButtonState() const override; | 58 int GetButtonState() const override; |
57 int GetFlags() const override; | 59 int GetFlags() const override; |
58 base::TimeTicks GetEventTime() const override; | 60 base::TimeTicks GetEventTime() const override; |
59 scoped_ptr<MotionEvent> Clone() const override; | 61 size_t GetHistorySize() const override; |
60 scoped_ptr<MotionEvent> Cancel() const override; | 62 base::TimeTicks GetHistoricalEventTime( |
| 63 size_t historical_index) const override; |
| 64 float GetHistoricalTouchMajor(size_t pointer_index, |
| 65 size_t historical_index) const override; |
| 66 float GetHistoricalX(size_t pointer_index, |
| 67 size_t historical_index) const override; |
| 68 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. |this| and |event| must have the same pointer |
| 74 // count and must both have an action of ACTION_MOVE. |
| 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 |