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_MOTION_EVENT_H_
6 #define UI_EVENTS_GESTURE_DETECTION_MOTION_EVENT_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/time/time.h"
10 #include "ui/events/gesture_detection/gesture_detection_export.h"
14 // Abstract class for a generic motion-related event, patterned after that
15 // subset of Android's MotionEvent API used in gesture detection.
16 class GESTURE_DETECTION_EXPORT MotionEvent {
27 // The implementer promises that |GetPointerId()| will never exceed this.
28 enum { MAX_POINTER_ID = 31 };
30 virtual ~MotionEvent() {}
32 virtual int GetId() const = 0;
33 virtual Action GetAction() const = 0;
34 // Only valid if |GetAction()| returns ACTION_POINTER_UP or
35 // ACTION_POINTER_DOWN.
36 virtual int GetActionIndex() const = 0;
37 virtual size_t GetPointerCount() const = 0;
38 virtual int GetPointerId(size_t pointer_index) const = 0;
39 virtual float GetX(size_t pointer_index) const = 0;
40 virtual float GetY(size_t pointer_index) const = 0;
41 virtual float GetTouchMajor(size_t pointer_index) const = 0;
42 virtual float GetPressure(size_t pointer_index) const = 0;
43 virtual base::TimeTicks GetEventTime() const = 0;
45 virtual size_t GetHistorySize() const = 0;
46 virtual base::TimeTicks GetHistoricalEventTime(
47 size_t historical_index) const = 0;
48 virtual float GetHistoricalTouchMajor(size_t pointer_index,
49 size_t historical_index) const = 0;
50 virtual float GetHistoricalX(size_t pointer_index,
51 size_t historical_index) const = 0;
52 virtual float GetHistoricalY(size_t pointer_index,
53 size_t historical_index) const = 0;
55 virtual scoped_ptr<MotionEvent> Clone() const = 0;
56 virtual scoped_ptr<MotionEvent> Cancel() const = 0;
58 // Utility accessor methods for convenience.
59 float GetX() const { return GetX(0); }
60 float GetY() const { return GetY(0); }
61 float GetRawX() const { return GetX(); }
62 float GetRawY() const { return GetY(); }
63 float GetTouchMajor() const { return GetTouchMajor(0); }
64 float GetPressure() const { return GetPressure(0); }
69 #endif // UI_EVENTS_GESTURE_DETECTION_MOTION_EVENT_H_