| 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 #include "ui/events/base_event_utils.h" | 8 #include "ui/events/base_event_utils.h" |
| 9 | 9 |
| 10 namespace ui { | 10 namespace ui { |
| 11 | 11 |
| 12 PointerProperties::PointerProperties() | 12 PointerProperties::PointerProperties() |
| 13 : PointerProperties(0, 0, 0) { | 13 : PointerProperties(0, 0, 0) { |
| 14 } | 14 } |
| 15 | 15 |
| 16 PointerProperties::PointerProperties(float x, float y, float touch_major) | 16 PointerProperties::PointerProperties(float x, float y, float touch_major) |
| 17 : id(0), | 17 : id(0), |
| 18 tool_type(MotionEvent::TOOL_TYPE_UNKNOWN), | 18 tool_type(MotionEvent::TOOL_TYPE_UNKNOWN), |
| 19 x(x), | 19 x(x), |
| 20 y(y), | 20 y(y), |
| 21 raw_x(x), | 21 raw_x(x), |
| 22 raw_y(y), | 22 raw_y(y), |
| 23 pressure(0), | 23 pressure(0), |
| 24 touch_major(touch_major), | 24 touch_major(touch_major), |
| 25 touch_minor(0), | 25 touch_minor(0), |
| 26 orientation(0), | 26 orientation(0), |
| 27 tilt(0), |
| 28 tilt_orientation(0), |
| 29 tilt_x(0), |
| 30 tilt_y(0), |
| 27 source_device_id(0) { | 31 source_device_id(0) { |
| 28 } | 32 } |
| 29 | 33 |
| 30 PointerProperties::PointerProperties(const MotionEvent& event, | 34 PointerProperties::PointerProperties(const MotionEvent& event, |
| 31 size_t pointer_index) | 35 size_t pointer_index) |
| 32 : id(event.GetPointerId(pointer_index)), | 36 : id(event.GetPointerId(pointer_index)), |
| 33 tool_type(event.GetToolType(pointer_index)), | 37 tool_type(event.GetToolType(pointer_index)), |
| 34 x(event.GetX(pointer_index)), | 38 x(event.GetX(pointer_index)), |
| 35 y(event.GetY(pointer_index)), | 39 y(event.GetY(pointer_index)), |
| 36 raw_x(event.GetRawX(pointer_index)), | 40 raw_x(event.GetRawX(pointer_index)), |
| 37 raw_y(event.GetRawY(pointer_index)), | 41 raw_y(event.GetRawY(pointer_index)), |
| 38 pressure(event.GetPressure(pointer_index)), | 42 pressure(event.GetPressure(pointer_index)), |
| 39 touch_major(event.GetTouchMajor(pointer_index)), | 43 touch_major(event.GetTouchMajor(pointer_index)), |
| 40 touch_minor(event.GetTouchMinor(pointer_index)), | 44 touch_minor(event.GetTouchMinor(pointer_index)), |
| 41 orientation(event.GetOrientation(pointer_index)), | 45 orientation(event.GetOrientation(pointer_index)), |
| 46 tilt(event.GetTilt(pointer_index)), |
| 47 tilt_orientation(event.GetTiltOrientation(pointer_index)), |
| 48 tilt_x(event.GetTiltX(pointer_index)), |
| 49 tilt_y(event.GetTiltY(pointer_index)), |
| 42 source_device_id(0) { | 50 source_device_id(0) { |
| 43 } | 51 } |
| 44 | 52 |
| 45 MotionEventGeneric::MotionEventGeneric(Action action, | 53 MotionEventGeneric::MotionEventGeneric(Action action, |
| 46 base::TimeTicks event_time, | 54 base::TimeTicks event_time, |
| 47 const PointerProperties& pointer) | 55 const PointerProperties& pointer) |
| 48 : action_(action), | 56 : action_(action), |
| 49 event_time_(event_time), | 57 event_time_(event_time), |
| 50 unique_event_id_(ui::GetNextTouchEventId()), | 58 unique_event_id_(ui::GetNextTouchEventId()), |
| 51 action_index_(0), | 59 action_index_(0), |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 float MotionEventGeneric::GetOrientation(size_t pointer_index) const { | 135 float MotionEventGeneric::GetOrientation(size_t pointer_index) const { |
| 128 DCHECK_LT(pointer_index, pointers_->size()); | 136 DCHECK_LT(pointer_index, pointers_->size()); |
| 129 return pointers_[pointer_index].orientation; | 137 return pointers_[pointer_index].orientation; |
| 130 } | 138 } |
| 131 | 139 |
| 132 float MotionEventGeneric::GetPressure(size_t pointer_index) const { | 140 float MotionEventGeneric::GetPressure(size_t pointer_index) const { |
| 133 DCHECK_LT(pointer_index, pointers_->size()); | 141 DCHECK_LT(pointer_index, pointers_->size()); |
| 134 return pointers_[pointer_index].pressure; | 142 return pointers_[pointer_index].pressure; |
| 135 } | 143 } |
| 136 | 144 |
| 145 float MotionEventGeneric::GetTilt(size_t pointer_index) const { |
| 146 DCHECK_LT(pointer_index, pointers_->size()); |
| 147 return pointers_[pointer_index].tilt; |
| 148 } |
| 149 |
| 150 float MotionEventGeneric::GetTiltOrientation(size_t pointer_index) const { |
| 151 DCHECK_LT(pointer_index, pointers_->size()); |
| 152 return pointers_[pointer_index].tilt_orientation; |
| 153 } |
| 154 |
| 155 float MotionEventGeneric::GetTiltX(size_t pointer_index) const { |
| 156 DCHECK_LT(pointer_index, pointers_->size()); |
| 157 return pointers_[pointer_index].tilt_x; |
| 158 } |
| 159 |
| 160 float MotionEventGeneric::GetTiltY(size_t pointer_index) const { |
| 161 DCHECK_LT(pointer_index, pointers_->size()); |
| 162 return pointers_[pointer_index].tilt_y; |
| 163 } |
| 164 |
| 137 MotionEvent::ToolType MotionEventGeneric::GetToolType( | 165 MotionEvent::ToolType MotionEventGeneric::GetToolType( |
| 138 size_t pointer_index) const { | 166 size_t pointer_index) const { |
| 139 DCHECK_LT(pointer_index, pointers_->size()); | 167 DCHECK_LT(pointer_index, pointers_->size()); |
| 140 return pointers_[pointer_index].tool_type; | 168 return pointers_[pointer_index].tool_type; |
| 141 } | 169 } |
| 142 | 170 |
| 143 int MotionEventGeneric::GetButtonState() const { | 171 int MotionEventGeneric::GetButtonState() const { |
| 144 return button_state_; | 172 return button_state_; |
| 145 } | 173 } |
| 146 | 174 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 PushHistoricalEvent(other.historical_events_[h]->Clone()); | 302 PushHistoricalEvent(other.historical_events_[h]->Clone()); |
| 275 return *this; | 303 return *this; |
| 276 } | 304 } |
| 277 | 305 |
| 278 void MotionEventGeneric::PopPointer() { | 306 void MotionEventGeneric::PopPointer() { |
| 279 DCHECK_GT(pointers_->size(), 0U); | 307 DCHECK_GT(pointers_->size(), 0U); |
| 280 pointers_->pop_back(); | 308 pointers_->pop_back(); |
| 281 } | 309 } |
| 282 | 310 |
| 283 } // namespace ui | 311 } // namespace ui |
| OLD | NEW |