Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / events / gesture_detection / motion_event_generic.h
blob38f4f2c777a26961131dafa846c463ed90142e74
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 "ui/events/gesture_detection/gesture_detection_export.h"
11 #include "ui/events/gesture_detection/motion_event.h"
13 namespace ui {
15 struct GESTURE_DETECTION_EXPORT PointerProperties {
16 PointerProperties();
17 PointerProperties(float x, float y);
19 int id;
20 MotionEvent::ToolType tool_type;
21 float x;
22 float y;
23 float raw_x;
24 float raw_y;
25 float pressure;
26 float touch_major;
29 // A generic MotionEvent implementation.
30 class GESTURE_DETECTION_EXPORT MotionEventGeneric : public MotionEvent {
31 public:
32 MotionEventGeneric(Action action,
33 base::TimeTicks event_time,
34 const PointerProperties& pointer);
35 MotionEventGeneric(const MotionEventGeneric& other);
37 virtual ~MotionEventGeneric();
39 // MotionEvent implementation.
40 virtual int GetId() const OVERRIDE;
41 virtual Action GetAction() const OVERRIDE;
42 virtual int GetActionIndex() const OVERRIDE;
43 virtual size_t GetPointerCount() const OVERRIDE;
44 virtual int GetPointerId(size_t pointer_index) const OVERRIDE;
45 virtual float GetX(size_t pointer_index) const OVERRIDE;
46 virtual float GetY(size_t pointer_index) const OVERRIDE;
47 virtual float GetRawX(size_t pointer_index) const OVERRIDE;
48 virtual float GetRawY(size_t pointer_index) const OVERRIDE;
49 virtual float GetTouchMajor(size_t pointer_index) const OVERRIDE;
50 virtual float GetPressure(size_t pointer_index) const OVERRIDE;
51 virtual ToolType GetToolType(size_t pointer_index) const OVERRIDE;
52 virtual int GetButtonState() const OVERRIDE;
53 virtual base::TimeTicks GetEventTime() const OVERRIDE;
54 virtual scoped_ptr<MotionEvent> Clone() const OVERRIDE;
55 virtual scoped_ptr<MotionEvent> Cancel() const OVERRIDE;
57 void PushPointer(const PointerProperties& pointer);
59 void set_action(Action action) { action_ = action; }
60 void set_event_time(base::TimeTicks event_time) { event_time_ = event_time; }
61 void set_id(int id) { id_ = id; }
62 void set_action_index(int action_index) { action_index_ = action_index; }
63 void set_button_state(int button_state) { button_state_ = button_state; }
65 protected:
66 MotionEventGeneric();
68 void PopPointer();
70 PointerProperties& pointer(size_t index) { return pointers_[index]; }
71 const PointerProperties& pointer(size_t index) const {
72 return pointers_[index];
75 private:
76 enum { kTypicalMaxPointerCount = 5 };
78 Action action_;
79 base::TimeTicks event_time_;
80 int id_;
81 int action_index_;
82 int button_state_;
83 base::StackVector<PointerProperties, kTypicalMaxPointerCount> pointers_;
86 } // namespace ui
88 #endif // UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_GENERIC_H_