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_H_ | 5 #ifndef UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_H_ |
6 #define UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_H_ | 6 #define UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "ui/events/event.h" | 12 #include "ui/events/event.h" |
13 #include "ui/events/events_export.h" | 13 #include "ui/events/events_export.h" |
14 #include "ui/events/gesture_detection/motion_event.h" | 14 #include "ui/events/gesture_detection/motion_event.h" |
15 | 15 |
16 namespace ui { | 16 namespace ui { |
17 | 17 |
18 // Implementation of MotionEvent which takes a stream of ui::TouchEvents. | 18 // Implementation of MotionEvent which takes a stream of ui::TouchEvents. |
19 class EVENTS_EXPORT MotionEventAura : public MotionEvent { | 19 class EVENTS_EXPORT MotionEventImpl : public MotionEvent { |
20 public: | 20 public: |
21 MotionEventAura(); | 21 MotionEventImpl(); |
22 virtual ~MotionEventAura(); | 22 virtual ~MotionEventImpl(); |
23 | 23 |
24 void OnTouch(const TouchEvent& touch); | 24 void OnTouch(const TouchEvent& touch); |
25 | 25 |
26 // MotionEvent implementation. | 26 // MotionEvent implementation. |
27 virtual int GetId() const override; | 27 virtual int GetId() const override; |
28 virtual Action GetAction() const override; | 28 virtual Action GetAction() const override; |
29 virtual int GetActionIndex() const override; | 29 virtual int GetActionIndex() const override; |
30 virtual size_t GetPointerCount() const override; | 30 virtual size_t GetPointerCount() const override; |
31 virtual int GetPointerId(size_t pointer_index) const override; | 31 virtual int GetPointerId(size_t pointer_index) const override; |
32 virtual float GetX(size_t pointer_index) const override; | 32 virtual float GetX(size_t pointer_index) const override; |
(...skipping 29 matching lines...) Expand all Loading... |
62 float raw_x; | 62 float raw_x; |
63 float raw_y; | 63 float raw_y; |
64 int touch_id; | 64 int touch_id; |
65 float pressure; | 65 float pressure; |
66 int source_device_id; | 66 int source_device_id; |
67 float touch_major; | 67 float touch_major; |
68 float touch_minor; | 68 float touch_minor; |
69 float orientation; | 69 float orientation; |
70 }; | 70 }; |
71 | 71 |
72 MotionEventAura( | 72 MotionEventImpl( |
73 size_t pointer_count, | 73 size_t pointer_count, |
74 const base::TimeTicks& last_touch_time, | 74 const base::TimeTicks& last_touch_time, |
75 Action cached_action, | 75 Action cached_action, |
76 int cached_action_index, | 76 int cached_action_index, |
77 int flags, | 77 int flags, |
78 const PointData (&active_touches)[MotionEvent::MAX_TOUCH_POINT_COUNT]); | 78 const PointData (&active_touches)[MotionEvent::MAX_TOUCH_POINT_COUNT]); |
79 | 79 |
80 static PointData GetPointDataFromTouchEvent(const TouchEvent& touch); | 80 static PointData GetPointDataFromTouchEvent(const TouchEvent& touch); |
81 void AddTouch(const TouchEvent& touch); | 81 void AddTouch(const TouchEvent& touch); |
82 void UpdateTouch(const TouchEvent& touch); | 82 void UpdateTouch(const TouchEvent& touch); |
83 void UpdateCachedAction(const TouchEvent& touch); | 83 void UpdateCachedAction(const TouchEvent& touch); |
84 size_t GetIndexFromId(int id) const; | 84 size_t GetIndexFromId(int id) const; |
85 | 85 |
86 size_t pointer_count_; | 86 size_t pointer_count_; |
87 base::TimeTicks last_touch_time_; | 87 base::TimeTicks last_touch_time_; |
88 Action cached_action_; | 88 Action cached_action_; |
89 // The index of the touch responsible for last ACTION_POINTER_DOWN or | 89 // The index of the touch responsible for last ACTION_POINTER_DOWN or |
90 // ACTION_POINTER_UP. -1 if no such action has occurred. | 90 // ACTION_POINTER_UP. -1 if no such action has occurred. |
91 int cached_action_index_; | 91 int cached_action_index_; |
92 int flags_; | 92 int flags_; |
93 | 93 |
94 // We want constant time indexing by pointer_index, and fast indexing by id. | 94 // We want constant time indexing by pointer_index, and fast indexing by id. |
95 PointData active_touches_[MotionEvent::MAX_TOUCH_POINT_COUNT]; | 95 PointData active_touches_[MotionEvent::MAX_TOUCH_POINT_COUNT]; |
96 | 96 |
97 DISALLOW_COPY_AND_ASSIGN(MotionEventAura); | 97 DISALLOW_COPY_AND_ASSIGN(MotionEventImpl); |
98 }; | 98 }; |
99 | 99 |
100 } // namespace ui | 100 } // namespace ui |
101 | 101 |
102 #endif // UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_H_ | 102 #endif // UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_H_ |
OLD | NEW |