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

Side by Side Diff: ui/events/gesture_detection/motion_event_generic.h

Issue 407313002: Add a MotionEventGeneric implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review Created 6 years, 5 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
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_GENERIC_H_
6 #define UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_GENERIC_H_
7
8 #include <vector>
9
10 #include "base/basictypes.h"
11 #include "ui/events/gesture_detection/gesture_detection_export.h"
12 #include "ui/events/gesture_detection/motion_event.h"
13
14 namespace ui {
15
16 struct GESTURE_DETECTION_EXPORT PointerProperties {
17 PointerProperties();
18 PointerProperties(float x, float y);
19
20 int id;
21 MotionEvent::ToolType tool_type;
22 float x;
23 float y;
24 float raw_x;
25 float raw_y;
26 float pressure;
27 float touch_major;
28 };
29
30 // A generic MotionEvent implementation.
31 class GESTURE_DETECTION_EXPORT MotionEventGeneric : public MotionEvent {
32 public:
33 MotionEventGeneric(Action action,
34 base::TimeTicks event_time,
35 const PointerProperties& pointer);
36 MotionEventGeneric(const MotionEventGeneric& other);
37
38 virtual ~MotionEventGeneric();
39
40 // MotionEvent implementation.
41 virtual int GetId() const OVERRIDE;
42 virtual Action GetAction() const OVERRIDE;
43 virtual int GetActionIndex() const OVERRIDE;
44 virtual size_t GetPointerCount() const OVERRIDE;
45 virtual int GetPointerId(size_t pointer_index) const OVERRIDE;
46 virtual float GetX(size_t pointer_index) const OVERRIDE;
47 virtual float GetY(size_t pointer_index) const OVERRIDE;
48 virtual float GetRawX(size_t pointer_index) const OVERRIDE;
49 virtual float GetRawY(size_t pointer_index) const OVERRIDE;
50 virtual float GetTouchMajor(size_t pointer_index) const OVERRIDE;
51 virtual float GetPressure(size_t pointer_index) const OVERRIDE;
52 virtual ToolType GetToolType(size_t pointer_index) const OVERRIDE;
53 virtual int GetButtonState() const OVERRIDE;
54 virtual base::TimeTicks GetEventTime() const OVERRIDE;
55 virtual scoped_ptr<MotionEvent> Clone() const OVERRIDE;
56 virtual scoped_ptr<MotionEvent> Cancel() const OVERRIDE;
57
58 void PushPointer(const PointerProperties& pointer);
59
60 void set_action(Action action) { action_ = action; }
61 void set_event_time(base::TimeTicks event_time) { event_time_ = event_time; }
62 void set_id(int id) { id_ = id; }
63 void set_action_index(int action_index) { action_index_ = action_index; }
64 void set_button_state(int button_state) { button_state_ = button_state; }
65
66 protected:
67 MotionEventGeneric();
68
69 void PopPointer();
70
71 PointerProperties& pointer(size_t index) { return pointers_[index]; }
72 const PointerProperties& pointer(size_t index) const {
73 return pointers_[index];
74 }
75
76 Action action_;
77 base::TimeTicks event_time_;
78 int id_;
79 int action_index_;
80 int button_state_;
81 std::vector<PointerProperties> pointers_;
82 };
83
84 } // namespace ui
85
86 #endif // UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_GENERIC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698