Remove ExtensionPrefs::SetDidExtensionEscalatePermissions.
[chromium-blink-merge.git] / ui / events / gesture_detection / motion_event_generic.h
blob635734208bdbd258e2eb784b5785f9ed8d2ded3e
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.
5 #ifndef UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_GENERIC_H_
6 #define UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_GENERIC_H_
8 #include "base/basictypes.h"
9 #include "base/containers/stack_container.h"
10 #include "base/memory/scoped_vector.h"
11 #include "ui/events/gesture_detection/gesture_detection_export.h"
12 #include "ui/events/gesture_detection/motion_event.h"
14 namespace ui {
16 struct GESTURE_DETECTION_EXPORT PointerProperties {
17 PointerProperties();
18 PointerProperties(float x, float y, float touch_major);
19 PointerProperties(const MotionEvent& event, size_t pointer_index);
21 int id;
22 MotionEvent::ToolType tool_type;
23 float x;
24 float y;
25 float raw_x;
26 float raw_y;
27 float pressure;
28 float touch_major;
29 float touch_minor;
30 float orientation;
31 // source_device_id is only used on Aura.
32 int source_device_id;
35 // A generic MotionEvent implementation.
36 class GESTURE_DETECTION_EXPORT MotionEventGeneric : public MotionEvent {
37 public:
38 MotionEventGeneric(Action action,
39 base::TimeTicks event_time,
40 const PointerProperties& pointer);
41 MotionEventGeneric(const MotionEventGeneric& other);
43 ~MotionEventGeneric() override;
45 // MotionEvent implementation.
46 uint32 GetUniqueEventId() const override;
47 Action GetAction() const override;
48 int GetActionIndex() const override;
49 size_t GetPointerCount() const override;
50 int GetPointerId(size_t pointer_index) const override;
51 float GetX(size_t pointer_index) const override;
52 float GetY(size_t pointer_index) const override;
53 float GetRawX(size_t pointer_index) const override;
54 float GetRawY(size_t pointer_index) const override;
55 float GetTouchMajor(size_t pointer_index) const override;
56 float GetTouchMinor(size_t pointer_index) const override;
57 float GetOrientation(size_t pointer_index) const override;
58 float GetPressure(size_t pointer_index) const override;
59 ToolType GetToolType(size_t pointer_index) const override;
60 int GetButtonState() const override;
61 int GetFlags() const override;
62 base::TimeTicks GetEventTime() const override;
63 size_t GetHistorySize() const override;
64 base::TimeTicks GetHistoricalEventTime(
65 size_t historical_index) const override;
66 float GetHistoricalTouchMajor(size_t pointer_index,
67 size_t historical_index) const override;
68 float GetHistoricalX(size_t pointer_index,
69 size_t historical_index) const override;
70 float GetHistoricalY(size_t pointer_index,
71 size_t historical_index) const override;
73 // Adds |pointer| to the set of pointers returning the index it was added at.
74 size_t PushPointer(const PointerProperties& pointer);
76 // Removes the PointerProperties at |index|.
77 void RemovePointerAt(size_t index);
79 PointerProperties& pointer(size_t index) { return pointers_[index]; }
80 const PointerProperties& pointer(size_t index) const {
81 return pointers_[index];
84 // Add an event to the history. |this| and |event| must have the same pointer
85 // count and must both have an action of ACTION_MOVE.
86 void PushHistoricalEvent(scoped_ptr<MotionEvent> event);
88 void set_action(Action action) { action_ = action; }
89 void set_event_time(base::TimeTicks event_time) { event_time_ = event_time; }
90 void set_unique_event_id(uint32 unique_event_id) {
91 unique_event_id_ = unique_event_id;
93 void set_action_index(int action_index) { action_index_ = action_index; }
94 void set_button_state(int button_state) { button_state_ = button_state; }
95 void set_flags(int flags) { flags_ = flags; }
97 static scoped_ptr<MotionEventGeneric> CloneEvent(const MotionEvent& event);
98 static scoped_ptr<MotionEventGeneric> CancelEvent(const MotionEvent& event);
100 protected:
101 MotionEventGeneric();
102 MotionEventGeneric(const MotionEvent& event, bool with_history);
103 MotionEventGeneric& operator=(const MotionEventGeneric& other);
105 void PopPointer();
107 private:
108 enum { kTypicalMaxPointerCount = 5 };
110 Action action_;
111 base::TimeTicks event_time_;
112 uint32 unique_event_id_;
113 int action_index_;
114 int button_state_;
115 int flags_;
116 base::StackVector<PointerProperties, kTypicalMaxPointerCount> pointers_;
117 ScopedVector<MotionEvent> historical_events_;
120 } // namespace ui
122 #endif // UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_GENERIC_H_