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

Unified Diff: ui/events/gesture_detection/motion_event.h

Issue 128613003: [Tracking Patch] Unified gesture detection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address tdresser@ comments and run clang-format on everything Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: ui/events/gesture_detection/motion_event.h
diff --git a/ui/events/gesture_detection/motion_event.h b/ui/events/gesture_detection/motion_event.h
new file mode 100644
index 0000000000000000000000000000000000000000..9f5dd49aa3c98413abe14a0f6747cbe3a9354285
--- /dev/null
+++ b/ui/events/gesture_detection/motion_event.h
@@ -0,0 +1,61 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_EVENTS_GESTURE_DETECTION_MOTION_EVENT_H_
+#define UI_EVENTS_GESTURE_DETECTION_MOTION_EVENT_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "base/time/time.h"
+#include "ui/events/gesture_detection/gesture_detection_export.h"
+
+namespace ui {
+
+// Abstract class for a generic motion-related event, patterned after that
+// subset of Android's MotionEvent API used in gesture detection.
+class GESTURE_DETECTION_EXPORT MotionEvent {
+ public:
+ enum Action {
+ ACTION_POINTER_DOWN,
+ ACTION_POINTER_UP,
+ ACTION_DOWN,
+ ACTION_UP,
+ ACTION_CANCEL,
+ ACTION_MOVE
+ };
+
+ virtual ~MotionEvent() {}
+
+ virtual Action GetAction() const = 0;
+ virtual int GetActionIndex() const = 0;
+ virtual size_t GetPointerCount() const = 0;
+ virtual int GetPointerId(size_t pointer_index) const = 0;
+ virtual float GetX(size_t pointer_index) const = 0;
+ virtual float GetY(size_t pointer_index) const = 0;
+ virtual float GetTouchMajor(size_t pointer_index) const = 0;
+ virtual base::TimeTicks GetEventTime() const = 0;
+
+ virtual size_t GetHistorySize() const = 0;
+ virtual base::TimeTicks GetHistoricalEventTime(
+ size_t historical_index) const = 0;
+ virtual float GetHistoricalTouchMajor(size_t pointer_index,
+ size_t historical_index) const = 0;
+ virtual float GetHistoricalX(size_t pointer_index,
+ size_t historical_index) const = 0;
+ virtual float GetHistoricalY(size_t pointer_index,
+ size_t historical_index) const = 0;
+
+ virtual scoped_ptr<MotionEvent> Clone() const = 0;
+ virtual scoped_ptr<MotionEvent> Cancel() const = 0;
+
+ // Utility accessor methods for convenience.
+ float GetX() const { return GetX(0); }
+ float GetY() const { return GetY(0); }
+ float GetRawX() const { return GetX(); }
+ float GetRawY() const { return GetY(); }
+ float GetTouchMajor() const { return GetTouchMajor(0); }
+};
+
+} // namespace ui
+
+#endif // UI_EVENTS_GESTURE_DETECTION_MOTION_EVENT_H_

Powered by Google App Engine
This is Rietveld 408576698