Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_ | 5 #ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_ |
| 6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_ | 6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_ |
| 7 | 7 |
| 8 #include "base/containers/stack_container.h" | 8 #include "base/containers/stack_container.h" |
| 9 #include "ui/events/gesture_detection/gesture_detection_export.h" | 9 #include "ui/events/gesture_detection/gesture_detection_export.h" |
| 10 #include "ui/events/gesture_detection/gesture_event_data.h" | 10 #include "ui/events/gesture_detection/gesture_event_data.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 INVALID, // The source of the gesture was invalid. | 22 INVALID, // The source of the gesture was invalid. |
| 23 TOUCH_SEQUENCE_START, // The start of a new gesture sequence. | 23 TOUCH_SEQUENCE_START, // The start of a new gesture sequence. |
| 24 TOUCH_SEQUENCE_END, // The end of a gesture sequence. | 24 TOUCH_SEQUENCE_END, // The end of a gesture sequence. |
| 25 TOUCH_SEQUENCE_CANCEL, // The gesture sequence was cancelled. | 25 TOUCH_SEQUENCE_CANCEL, // The gesture sequence was cancelled. |
| 26 TOUCH_START, // A touch down occured during a gesture sequence. | 26 TOUCH_START, // A touch down occured during a gesture sequence. |
| 27 TOUCH_MOVE, // A touch move occured during a gesture sequence. | 27 TOUCH_MOVE, // A touch move occured during a gesture sequence. |
| 28 TOUCH_END, // A touch up occured during a gesture sequence. | 28 TOUCH_END, // A touch up occured during a gesture sequence. |
| 29 TOUCH_TIMEOUT, // Timeout from an existing gesture sequence. | 29 TOUCH_TIMEOUT, // Timeout from an existing gesture sequence. |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 enum class AckState : int { | |
| 33 PENDING, | |
| 34 CONSUMED, | |
| 35 UNCONSUMED, | |
| 36 }; | |
| 37 | |
| 32 GestureEventDataPacket(); | 38 GestureEventDataPacket(); |
| 33 GestureEventDataPacket(const GestureEventDataPacket& other); | 39 GestureEventDataPacket(const GestureEventDataPacket& other); |
| 34 ~GestureEventDataPacket(); | 40 ~GestureEventDataPacket(); |
| 35 GestureEventDataPacket& operator=(const GestureEventDataPacket& other); | 41 GestureEventDataPacket& operator=(const GestureEventDataPacket& other); |
| 36 | 42 |
| 37 // Factory methods for creating a packet from a particular event. | 43 // Factory methods for creating a packet from a particular event. |
| 38 static GestureEventDataPacket FromTouch(const ui::MotionEvent& touch); | 44 static GestureEventDataPacket FromTouch(const ui::MotionEvent& touch); |
| 39 static GestureEventDataPacket FromTouchTimeout( | 45 static GestureEventDataPacket FromTouchTimeout( |
| 40 const GestureEventData& gesture); | 46 const GestureEventData& gesture); |
| 41 | 47 |
| 42 void Push(const GestureEventData& gesture); | 48 void Push(const GestureEventData& gesture); |
| 43 | 49 |
| 44 const base::TimeTicks& timestamp() const { return timestamp_; } | 50 const base::TimeTicks& timestamp() const { return timestamp_; } |
| 45 const GestureEventData& gesture(size_t i) const { return gestures_[i]; } | 51 const GestureEventData& gesture(size_t i) const { return gestures_[i]; } |
| 46 size_t gesture_count() const { return gestures_->size(); } | 52 size_t gesture_count() const { return gestures_->size(); } |
| 47 GestureSource gesture_source() const { return gesture_source_; } | 53 GestureSource gesture_source() const { return gesture_source_; } |
| 48 const gfx::PointF& touch_location() const { return touch_location_; } | 54 const gfx::PointF& touch_location() const { return touch_location_; } |
| 49 const gfx::PointF& raw_touch_location() const { return raw_touch_location_; } | 55 const gfx::PointF& raw_touch_location() const { return raw_touch_location_; } |
| 50 | 56 |
| 57 // If we receive an ack for a packet before it reaches the head of the | |
| 58 // queue, we store the ack with the packet. | |
| 59 void ack(bool event_consumed); | |
|
jdduke (slow)
2014/11/26 16:07:09
Nit: Uppercase. Also, the comment is a little uncl
tdresser
2014/11/27 18:26:24
Done.
| |
| 60 AckState ack_state() { return ack_state_; } | |
| 61 | |
| 51 private: | 62 private: |
| 52 GestureEventDataPacket(base::TimeTicks timestamp, | 63 GestureEventDataPacket(base::TimeTicks timestamp, |
| 53 GestureSource source, | 64 GestureSource source, |
| 54 const gfx::PointF& touch_location, | 65 const gfx::PointF& touch_location, |
| 55 const gfx::PointF& raw_touch_location); | 66 const gfx::PointF& raw_touch_location); |
| 56 | 67 |
| 57 enum { kTypicalMaxGesturesPerTouch = 5 }; | 68 enum { kTypicalMaxGesturesPerTouch = 5 }; |
| 58 base::TimeTicks timestamp_; | 69 base::TimeTicks timestamp_; |
| 59 base::StackVector<GestureEventData, kTypicalMaxGesturesPerTouch> gestures_; | 70 base::StackVector<GestureEventData, kTypicalMaxGesturesPerTouch> gestures_; |
| 60 gfx::PointF touch_location_; | 71 gfx::PointF touch_location_; |
| 61 gfx::PointF raw_touch_location_; | 72 gfx::PointF raw_touch_location_; |
| 62 GestureSource gesture_source_; | 73 GestureSource gesture_source_; |
| 74 AckState ack_state_; | |
| 63 }; | 75 }; |
| 64 | 76 |
| 65 } // namespace ui | 77 } // namespace ui |
| 66 | 78 |
| 67 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_ | 79 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_ |
| OLD | NEW |