Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / ui / events / gesture_detection / motion_event.h
index b69a38f..10f7b85 100644 (file)
@@ -29,6 +29,7 @@ class GESTURE_DETECTION_EXPORT MotionEvent {
     TOOL_TYPE_FINGER,
     TOOL_TYPE_STYLUS,
     TOOL_TYPE_MOUSE,
+    TOOL_TYPE_ERASER
   };
 
   enum ButtonType {
@@ -57,19 +58,19 @@ class GESTURE_DETECTION_EXPORT MotionEvent {
   virtual float GetRawY(size_t pointer_index) const = 0;
   virtual float GetTouchMajor(size_t pointer_index) const = 0;
   virtual float GetPressure(size_t pointer_index) const = 0;
+  virtual ToolType GetToolType(size_t pointer_index) const = 0;
+  virtual int GetButtonState() const = 0;
   virtual base::TimeTicks GetEventTime() const = 0;
 
-  virtual size_t GetHistorySize() const = 0;
-  virtual base::TimeTicks GetHistoricalEventTime(
-      size_t historical_index) const = 0;
+  // Optional historical data, default implementation provides an empty history.
+  virtual size_t GetHistorySize() const;
+  virtual base::TimeTicks GetHistoricalEventTime(size_t historical_index) const;
   virtual float GetHistoricalTouchMajor(size_t pointer_index,
-                                        size_t historical_index) const = 0;
+                                        size_t historical_index) const;
   virtual float GetHistoricalX(size_t pointer_index,
-                               size_t historical_index) const = 0;
+                               size_t historical_index) const;
   virtual float GetHistoricalY(size_t pointer_index,
-                               size_t historical_index) const = 0;
-  virtual ToolType GetToolType(size_t pointer_index) const = 0;
-  virtual int GetButtonState() const = 0;
+                               size_t historical_index) const;
 
   virtual scoped_ptr<MotionEvent> Clone() const = 0;
   virtual scoped_ptr<MotionEvent> Cancel() const = 0;
@@ -83,8 +84,17 @@ class GESTURE_DETECTION_EXPORT MotionEvent {
   float GetRawOffsetY() const { return GetRawY() - GetY(); }
   float GetTouchMajor() const { return GetTouchMajor(0); }
   float GetPressure() const { return GetPressure(0); }
+  ToolType GetToolType() const { return GetToolType(0); }
+
+  // O(N) search of pointers (use sparingly!). Returns -1 if |id| nonexistent.
+  int FindPointerIndexOfId(int id) const;
 };
 
+GESTURE_DETECTION_EXPORT bool operator==(const MotionEvent& lhs,
+                                         const MotionEvent& rhs);
+GESTURE_DETECTION_EXPORT bool operator!=(const MotionEvent& lhs,
+                                         const MotionEvent& rhs);
+
 }  // namespace ui
 
 #endif  // UI_EVENTS_GESTURE_DETECTION_MOTION_EVENT_H_