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/gesture_event_data.h" | 5 #include "ui/events/gesture_detection/gesture_event_data.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace ui { | 9 namespace ui { |
10 | 10 |
| 11 namespace { |
| 12 |
| 13 EventPointerType ToEventPointerType(MotionEvent::ToolType tool_type) { |
| 14 switch (tool_type) { |
| 15 case MotionEvent::TOOL_TYPE_UNKNOWN: |
| 16 return EventPointerType::POINTER_TYPE_UNKNOWN; |
| 17 case MotionEvent::TOOL_TYPE_FINGER: |
| 18 return EventPointerType::POINTER_TYPE_TOUCH; |
| 19 case MotionEvent::TOOL_TYPE_STYLUS: |
| 20 return EventPointerType::POINTER_TYPE_PEN; |
| 21 case MotionEvent::TOOL_TYPE_MOUSE: |
| 22 return EventPointerType::POINTER_TYPE_MOUSE; |
| 23 case MotionEvent::TOOL_TYPE_ERASER: |
| 24 return EventPointerType::POINTER_TYPE_ERASER; |
| 25 default: |
| 26 NOTREACHED() << "Invalid ToolType = " << tool_type; |
| 27 return EventPointerType::POINTER_TYPE_UNKNOWN; |
| 28 } |
| 29 } |
| 30 |
| 31 } // anonymous namespace |
| 32 |
11 GestureEventData::GestureEventData(const GestureEventDetails& details, | 33 GestureEventData::GestureEventData(const GestureEventDetails& details, |
12 int motion_event_id, | 34 int motion_event_id, |
13 MotionEvent::ToolType primary_tool_type, | 35 MotionEvent::ToolType primary_tool_type, |
14 base::TimeTicks time, | 36 base::TimeTicks time, |
15 float x, | 37 float x, |
16 float y, | 38 float y, |
17 float raw_x, | 39 float raw_x, |
18 float raw_y, | 40 float raw_y, |
19 size_t touch_point_count, | 41 size_t touch_point_count, |
20 const gfx::RectF& bounding_box, | 42 const gfx::RectF& bounding_box, |
21 int flags, | 43 int flags, |
22 uint32_t unique_touch_event_id) | 44 uint32_t unique_touch_event_id) |
23 : details(details), | 45 : details(details), |
24 motion_event_id(motion_event_id), | 46 motion_event_id(motion_event_id), |
25 primary_tool_type(primary_tool_type), | 47 primary_tool_type(primary_tool_type), |
26 time(time), | 48 time(time), |
27 x(x), | 49 x(x), |
28 y(y), | 50 y(y), |
29 raw_x(raw_x), | 51 raw_x(raw_x), |
30 raw_y(raw_y), | 52 raw_y(raw_y), |
31 flags(flags), | 53 flags(flags), |
32 unique_touch_event_id(unique_touch_event_id) { | 54 unique_touch_event_id(unique_touch_event_id) { |
33 DCHECK_GE(motion_event_id, 0); | 55 DCHECK_GE(motion_event_id, 0); |
34 DCHECK_NE(0U, touch_point_count); | 56 DCHECK_NE(0U, touch_point_count); |
| 57 this->details.set_primary_pointer_type(ToEventPointerType(primary_tool_type)); |
35 this->details.set_touch_points(static_cast<int>(touch_point_count)); | 58 this->details.set_touch_points(static_cast<int>(touch_point_count)); |
36 this->details.set_bounding_box(bounding_box); | 59 this->details.set_bounding_box(bounding_box); |
37 } | 60 } |
38 | 61 |
39 GestureEventData::GestureEventData(EventType type, | 62 GestureEventData::GestureEventData(EventType type, |
40 const GestureEventData& other) | 63 const GestureEventData& other) |
41 : details(type, other.details), | 64 : details(type, other.details), |
42 motion_event_id(other.motion_event_id), | 65 motion_event_id(other.motion_event_id), |
43 primary_tool_type(other.primary_tool_type), | 66 primary_tool_type(other.primary_tool_type), |
44 time(other.time), | 67 time(other.time), |
45 x(other.x), | 68 x(other.x), |
46 y(other.y), | 69 y(other.y), |
47 raw_x(other.raw_x), | 70 raw_x(other.raw_x), |
48 raw_y(other.raw_y), | 71 raw_y(other.raw_y), |
49 flags(other.flags), | 72 flags(other.flags), |
50 unique_touch_event_id(other.unique_touch_event_id) { | 73 unique_touch_event_id(other.unique_touch_event_id) { |
| 74 details.set_primary_pointer_type(other.details.primary_pointer_type()); |
51 details.set_touch_points(other.details.touch_points()); | 75 details.set_touch_points(other.details.touch_points()); |
52 details.set_bounding_box(other.details.bounding_box_f()); | 76 details.set_bounding_box(other.details.bounding_box_f()); |
53 } | 77 } |
54 | 78 |
55 GestureEventData::GestureEventData(const GestureEventData& other) = default; | 79 GestureEventData::GestureEventData(const GestureEventData& other) = default; |
56 | 80 |
57 GestureEventData::GestureEventData() | 81 GestureEventData::GestureEventData() |
58 : motion_event_id(0), | 82 : motion_event_id(0), |
59 primary_tool_type(MotionEvent::TOOL_TYPE_UNKNOWN), | 83 primary_tool_type(MotionEvent::TOOL_TYPE_UNKNOWN), |
60 x(0), | 84 x(0), |
61 y(0), | 85 y(0), |
62 raw_x(0), | 86 raw_x(0), |
63 raw_y(0), | 87 raw_y(0), |
64 flags(EF_NONE), | 88 flags(EF_NONE), |
65 unique_touch_event_id(0U) { | 89 unique_touch_event_id(0U) { |
66 } | 90 } |
67 | 91 |
68 } // namespace ui | 92 } // namespace ui |
OLD | NEW |