Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Side by Side Diff: ui/events/gestures/motion_event_aura.h

Issue 251543003: Unified Gesture Recognizer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address jdduke comments. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_H_
6 #define UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_H_
7
8 #include "ui/events/gesture_detection/motion_event.h"
9
10 #include <map>
11
12 #include "base/memory/scoped_ptr.h"
13 #include "base/time/time.h"
14 #include "ui/events/event.h"
15 #include "ui/events/events_export.h"
16 #include "ui/events/gestures/gesture_sequence.h"
17
18 namespace ui {
19
20 // Implementation of MotionEvent which takes a stream of ui::TouchEvents.
21 class EVENTS_EXPORT MotionEventAura : public MotionEvent {
22 public:
23 MotionEventAura();
24 virtual ~MotionEventAura();
25
26 void OnTouch(const TouchEvent& touch);
27
28 // MotionEventAura implementation.
jdduke (slow) 2014/05/05 16:57:09 Hmm, think this get the rename treatment, "MotionE
tdresser 2014/05/05 17:45:14 Done.
29 virtual int GetId() const OVERRIDE;
30 virtual Action GetAction() const OVERRIDE;
31 virtual int GetActionIndex() const OVERRIDE;
32 virtual size_t GetPointerCount() const OVERRIDE;
33 virtual int GetPointerId(size_t pointer_index) const OVERRIDE;
34 virtual float GetX(size_t pointer_index) const OVERRIDE;
35 virtual float GetY(size_t pointer_index) const OVERRIDE;
36 virtual float GetTouchMajor(size_t pointer_index) const OVERRIDE;
37 virtual float GetPressure(size_t pointer_index) const OVERRIDE;
38 virtual base::TimeTicks GetEventTime() const OVERRIDE;
39
40 virtual size_t GetHistorySize() const OVERRIDE;
41 virtual base::TimeTicks GetHistoricalEventTime(size_t historical_index) const
42 OVERRIDE;
43 virtual float GetHistoricalTouchMajor(size_t pointer_index,
44 size_t historical_index) const OVERRIDE;
45 virtual float GetHistoricalX(size_t pointer_index,
46 size_t historical_index) const OVERRIDE;
47 virtual float GetHistoricalY(size_t pointer_index,
48 size_t historical_index) const OVERRIDE;
49
50 virtual scoped_ptr<MotionEvent> Clone() const OVERRIDE;
51 virtual scoped_ptr<MotionEvent> Cancel() const OVERRIDE;
52
53 int GetSourceDeviceId(size_t pointer_index) const;
54
55 // We can't cleanup removed touch points immediately upon receipt of a
56 // TouchCancel or TouchRelease, as the MotionEvent needs to be able to report
57 // information about those touch events. Once the MotionEvent has been
58 // processed, we call CleanupRemovedTouchPoints to do the required
59 // book-keeping.
60 void CleanupRemovedTouchPoints(const TouchEvent& event);
61
62 private:
63 struct PointData {
64 PointData() {
jdduke (slow) 2014/05/05 16:57:09 Nit: Constructor implementation in the .cc file, a
tdresser 2014/05/05 17:45:14 Done.
65 x = 0;
66 y = 0;
67 touch_id = 0;
68 pressure = 0;
69 source_device_id = 0;
70 major_radius = 0;
71 }
72 float x;
73 float y;
74 int touch_id;
75 float pressure;
76 int source_device_id;
77 float major_radius;
78 };
79
80 MotionEventAura(
81 size_t pointer_count,
82 const base::TimeDelta& last_touch_time,
83 Action cached_action,
84 int cached_action_index,
85 const PointData (&active_touches)[GestureSequence::kMaxGesturePoints]);
86
87 static PointData GetPointDataFromTouchEvent(const TouchEvent& touch);
88 void AddTouch(const TouchEvent& touch);
89 void UpdateTouch(const TouchEvent& touch);
90 void UpdateCachedAction(const TouchEvent& touch);
91 size_t GetIndexFromId(int id);
jdduke (slow) 2014/05/05 16:57:09 Nit: const method.
tdresser 2014/05/05 17:45:14 Done.
92
93 size_t pointer_count_;
94 base::TimeTicks last_touch_time_;
95 Action cached_action_;
96 // The index of the touch responsible for last ACTION_POINTER_DOWN or
97 // ACTION_POINTER_UP. -1 if no such action has occurred.
98 int cached_action_index_;
99
100 // We want constant time indexing by pointer_index, and fast indexing by id.
101 // TODO(tdresser): figure out which constant to use here.
102 PointData active_touches_[GestureSequence::kMaxGesturePoints];
103 };
104
105 } // namespace ui
106
107 #endif // UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698