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_GESTURE_EVENT_DATA_PACKET_H_
6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_
8 #include "ui/events/gesture_detection/gesture_detection_export.h"
9 #include "ui/events/gesture_detection/gesture_event_data.h"
15 // Acts as a transport container for gestures created (directly or indirectly)
17 class GESTURE_DETECTION_EXPORT GestureEventDataPacket {
20 UNDEFINED = -1, // Used only for a default-constructed packet.
21 INVALID, // The source of the gesture was invalid.
22 TOUCH_SEQUENCE_START, // The start of a new gesture sequence.
23 TOUCH_SEQUENCE_END, // The end of a gesture sequence.
24 TOUCH_SEQUENCE_CANCEL, // The gesture sequence was cancelled.
25 TOUCH_START, // A touch down occured during a gesture sequence.
26 TOUCH_MOVE, // A touch move occured during a gesture sequence.
27 TOUCH_END, // A touch up occured during a gesture sequence.
28 TOUCH_TIMEOUT, // Timeout from an existing gesture sequence.
31 GestureEventDataPacket();
32 GestureEventDataPacket(const GestureEventDataPacket& other);
33 ~GestureEventDataPacket();
34 GestureEventDataPacket& operator=(const GestureEventDataPacket& other);
36 // Factory methods for creating a packet from a particular event.
37 static GestureEventDataPacket FromTouch(const ui::MotionEvent& touch);
38 static GestureEventDataPacket FromTouchTimeout(
39 const GestureEventData& gesture);
41 void Push(const GestureEventData& gesture);
43 const base::TimeTicks& timestamp() const { return timestamp_; }
44 const GestureEventData& gesture(size_t i) const { return gestures_[i]; }
45 size_t gesture_count() const { return gesture_count_; }
46 GestureSource gesture_source() const { return gesture_source_; }
47 const gfx::PointF& touch_location() const { return touch_location_; }
48 const gfx::PointF& raw_touch_location() const { return raw_touch_location_; }
51 GestureEventDataPacket(base::TimeTicks timestamp,
53 const gfx::PointF& touch_location,
54 const gfx::PointF& raw_touch_location);
56 enum { kMaxGesturesPerTouch = 5 };
57 base::TimeTicks timestamp_;
58 GestureEventData gestures_[kMaxGesturesPerTouch];
59 size_t gesture_count_;
60 gfx::PointF touch_location_;
61 gfx::PointF raw_touch_location_;
62 GestureSource gesture_source_;
67 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_