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 #include "ui/events/gesture_detection/motion_event_generic.h" | 5 #include "ui/events/gesture_detection/motion_event_generic.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace ui { | 9 namespace ui { |
10 | 10 |
11 PointerProperties::PointerProperties() | 11 PointerProperties::PointerProperties() |
12 : PointerProperties(0, 0, 0) { | 12 : PointerProperties(0, 0, 0) { |
13 } | 13 } |
14 | 14 |
15 PointerProperties::PointerProperties(float x, float y, float touch_major) | 15 PointerProperties::PointerProperties(float x, float y, float touch_major) |
16 : id(0), | 16 : id(0), |
17 tool_type(MotionEvent::TOOL_TYPE_UNKNOWN), | 17 tool_type(MotionEvent::TOOL_TYPE_UNKNOWN), |
18 x(x), | 18 x(x), |
19 y(y), | 19 y(y), |
20 raw_x(x), | 20 raw_x(x), |
21 raw_y(y), | 21 raw_y(y), |
22 pressure(0), | 22 pressure(0), |
23 touch_major(touch_major), | 23 touch_major(touch_major), |
24 touch_minor(0), | 24 touch_minor(0), |
25 orientation(0), | 25 orientation(0), |
| 26 tilt(0), |
26 source_device_id(0) { | 27 source_device_id(0) { |
27 } | 28 } |
28 | 29 |
29 PointerProperties::PointerProperties(const MotionEvent& event, | 30 PointerProperties::PointerProperties(const MotionEvent& event, |
30 size_t pointer_index) | 31 size_t pointer_index) |
31 : id(event.GetPointerId(pointer_index)), | 32 : id(event.GetPointerId(pointer_index)), |
32 tool_type(event.GetToolType(pointer_index)), | 33 tool_type(event.GetToolType(pointer_index)), |
33 x(event.GetX(pointer_index)), | 34 x(event.GetX(pointer_index)), |
34 y(event.GetY(pointer_index)), | 35 y(event.GetY(pointer_index)), |
35 raw_x(event.GetRawX(pointer_index)), | 36 raw_x(event.GetRawX(pointer_index)), |
36 raw_y(event.GetRawY(pointer_index)), | 37 raw_y(event.GetRawY(pointer_index)), |
37 pressure(event.GetPressure(pointer_index)), | 38 pressure(event.GetPressure(pointer_index)), |
38 touch_major(event.GetTouchMajor(pointer_index)), | 39 touch_major(event.GetTouchMajor(pointer_index)), |
39 touch_minor(event.GetTouchMinor(pointer_index)), | 40 touch_minor(event.GetTouchMinor(pointer_index)), |
40 orientation(event.GetOrientation(pointer_index)), | 41 orientation(event.GetOrientation(pointer_index)), |
| 42 tilt(event.GetTilt(pointer_index)), |
41 source_device_id(0) { | 43 source_device_id(0) { |
42 } | 44 } |
43 | 45 |
44 MotionEventGeneric::MotionEventGeneric(Action action, | 46 MotionEventGeneric::MotionEventGeneric(Action action, |
45 base::TimeTicks event_time, | 47 base::TimeTicks event_time, |
46 const PointerProperties& pointer) | 48 const PointerProperties& pointer) |
47 : action_(action), | 49 : action_(action), |
48 event_time_(event_time), | 50 event_time_(event_time), |
49 id_(0), | 51 id_(0), |
50 action_index_(0), | 52 action_index_(0), |
(...skipping 70 matching lines...) Loading... |
121 float MotionEventGeneric::GetTouchMinor(size_t pointer_index) const { | 123 float MotionEventGeneric::GetTouchMinor(size_t pointer_index) const { |
122 DCHECK_LT(pointer_index, pointers_->size()); | 124 DCHECK_LT(pointer_index, pointers_->size()); |
123 return pointers_[pointer_index].touch_minor; | 125 return pointers_[pointer_index].touch_minor; |
124 } | 126 } |
125 | 127 |
126 float MotionEventGeneric::GetOrientation(size_t pointer_index) const { | 128 float MotionEventGeneric::GetOrientation(size_t pointer_index) const { |
127 DCHECK_LT(pointer_index, pointers_->size()); | 129 DCHECK_LT(pointer_index, pointers_->size()); |
128 return pointers_[pointer_index].orientation; | 130 return pointers_[pointer_index].orientation; |
129 } | 131 } |
130 | 132 |
| 133 float MotionEventGeneric::GetTilt(size_t pointer_index) const { |
| 134 DCHECK_LT(pointer_index, pointers_->size()); |
| 135 return pointers_[pointer_index].tilt; |
| 136 } |
| 137 |
131 float MotionEventGeneric::GetPressure(size_t pointer_index) const { | 138 float MotionEventGeneric::GetPressure(size_t pointer_index) const { |
132 DCHECK_LT(pointer_index, pointers_->size()); | 139 DCHECK_LT(pointer_index, pointers_->size()); |
133 return pointers_[pointer_index].pressure; | 140 return pointers_[pointer_index].pressure; |
134 } | 141 } |
135 | 142 |
136 MotionEvent::ToolType MotionEventGeneric::GetToolType( | 143 MotionEvent::ToolType MotionEventGeneric::GetToolType( |
137 size_t pointer_index) const { | 144 size_t pointer_index) const { |
138 DCHECK_LT(pointer_index, pointers_->size()); | 145 DCHECK_LT(pointer_index, pointers_->size()); |
139 return pointers_[pointer_index].tool_type; | 146 return pointers_[pointer_index].tool_type; |
140 } | 147 } |
(...skipping 122 matching lines...) Loading... |
263 PushHistoricalEvent(other.historical_events_[h]->Clone()); | 270 PushHistoricalEvent(other.historical_events_[h]->Clone()); |
264 return *this; | 271 return *this; |
265 } | 272 } |
266 | 273 |
267 void MotionEventGeneric::PopPointer() { | 274 void MotionEventGeneric::PopPointer() { |
268 DCHECK_GT(pointers_->size(), 0U); | 275 DCHECK_GT(pointers_->size(), 0U); |
269 pointers_->pop_back(); | 276 pointers_->pop_back(); |
270 } | 277 } |
271 | 278 |
272 } // namespace ui | 279 } // namespace ui |
OLD | NEW |