| 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_PARAMS_H_ | 5 #ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_H_ |
| 6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_PARAMS_H_ | 6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_H_ |
| 7 | 7 |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "ui/events/gesture_detection/gesture_detection_export.h" | 9 #include "ui/events/gesture_detection/gesture_detection_export.h" |
| 10 | 10 |
| 11 namespace ui { | 11 namespace ui { |
| 12 | 12 |
| 13 // TODO(jdduke): Consider adoption of ui::EventType. |
| 13 enum GestureEventType { | 14 enum GestureEventType { |
| 15 GESTURE_TYPE_INVALID = -1, |
| 16 GESTURE_TYPE_FIRST = 0, |
| 17 GESTURE_TAP_DOWN = GESTURE_TYPE_FIRST, |
| 18 GESTURE_TAP_UNCONFIRMED, |
| 19 GESTURE_TAP, |
| 20 GESTURE_DOUBLE_TAP, |
| 21 GESTURE_TAP_CANCEL, |
| 14 GESTURE_SHOW_PRESS, | 22 GESTURE_SHOW_PRESS, |
| 15 GESTURE_DOUBLE_TAP, | 23 GESTURE_LONG_TAP, |
| 16 GESTURE_SINGLE_TAP_CONFIRMED, | |
| 17 GESTURE_SINGLE_TAP_UNCONFIRMED, | |
| 18 GESTURE_LONG_PRESS, | 24 GESTURE_LONG_PRESS, |
| 19 GESTURE_SCROLL_BEGIN, | 25 GESTURE_SCROLL_BEGIN, |
| 20 GESTURE_SCROLL_UPDATE, | 26 GESTURE_SCROLL_UPDATE, |
| 21 GESTURE_SCROLL_END, | 27 GESTURE_SCROLL_END, |
| 22 GESTURE_FLING_START, | 28 GESTURE_FLING_START, |
| 23 GESTURE_FLING_CANCEL, | 29 GESTURE_FLING_CANCEL, |
| 24 GESTURE_PINCH_BEGIN, | 30 GESTURE_PINCH_BEGIN, |
| 25 GESTURE_PINCH_UPDATE, | 31 GESTURE_PINCH_UPDATE, |
| 26 GESTURE_PINCH_END, | 32 GESTURE_PINCH_END, |
| 27 GESTURE_TAP_CANCEL, | 33 GESTURE_TYPE_LAST = GESTURE_PINCH_END, |
| 28 GESTURE_LONG_TAP, | |
| 29 GESTURE_TAP_DOWN | |
| 30 }; | 34 }; |
| 31 | 35 |
| 32 // TODO(jdduke): Convert all (x,y) and (width,height) pairs to their | 36 class GestureEventDataPacket; |
| 33 // corresponding gfx:: geometry types. | 37 |
| 34 struct GESTURE_DETECTION_EXPORT GestureEventParams { | 38 // Simple transport construct for gesture-related event data. |
| 35 struct Data; | 39 // TODO(jdduke): Merge this class with ui::GestureEventDetails. |
| 36 GestureEventParams(GestureEventType type, | 40 struct GESTURE_DETECTION_EXPORT GestureEventData { |
| 37 base::TimeTicks time, | 41 struct Details; |
| 38 float x, | 42 GestureEventData(GestureEventType type, |
| 39 float y, | 43 base::TimeTicks time, |
| 40 const Data& data); | 44 float x, |
| 45 float y, |
| 46 const Details& details); |
| 41 | 47 |
| 42 GestureEventType type; | 48 GestureEventType type; |
| 43 base::TimeTicks time; | 49 base::TimeTicks time; |
| 44 float x; | 50 float x; |
| 45 float y; | 51 float y; |
| 46 | 52 |
| 47 // TODO(jdduke): Determine if we can simply re-use blink::WebGestureEvent, as | 53 // TODO(jdduke): Determine if we can simply re-use blink::WebGestureEvent, as |
| 48 // this is more or less straight up duplication. | 54 // this is more or less straight up duplication. |
| 49 struct Data { | 55 struct GESTURE_DETECTION_EXPORT Details { |
| 50 Data(); | 56 Details(); |
| 51 union { | 57 union { |
| 52 struct { | 58 struct { |
| 53 int tap_count; | 59 int tap_count; |
| 54 float width; | 60 float width; |
| 55 float height; | 61 float height; |
| 56 } tap; | 62 } tap; |
| 57 | 63 |
| 58 struct { | 64 struct { |
| 59 float width; | 65 float width; |
| 60 float height; | 66 float height; |
| 61 } tap_down; | 67 } tap_down; |
| 62 | 68 |
| 63 struct { | 69 struct { |
| 64 float width; | 70 float width; |
| 65 float height; | 71 float height; |
| 66 } show_press; | 72 } show_press; |
| 67 | 73 |
| 68 struct { | 74 struct { |
| 69 float width; | 75 float width; |
| 70 float height; | 76 float height; |
| 71 } long_press; | 77 } long_press; |
| 72 | 78 |
| 73 struct { | 79 struct { |
| 74 // Initial motion that triggered the scroll. | 80 // Initial motion that triggered the scroll. |
| 75 // May be redundant with deltaX/deltaY in the first scrollUpdate. | 81 // May be redundant with delta_x/delta_y in the first scroll_update. |
| 76 float delta_x_hint; | 82 float delta_x_hint; |
| 77 float delta_y_hint; | 83 float delta_y_hint; |
| 78 } scroll_begin; | 84 } scroll_begin; |
| 79 | 85 |
| 80 struct { | 86 struct { |
| 81 float delta_x; | 87 float delta_x; |
| 82 float delta_y; | 88 float delta_y; |
| 83 float velocity_x; | 89 float velocity_x; |
| 84 float velocity_y; | 90 float velocity_y; |
| 85 } scroll_update; | 91 } scroll_update; |
| 86 | 92 |
| 87 struct { | 93 struct { |
| 88 float velocity_x; | 94 float velocity_x; |
| 89 float velocity_y; | 95 float velocity_y; |
| 90 } fling_start; | 96 } fling_start; |
| 91 | 97 |
| 92 struct { | 98 struct { |
| 93 float scale; | 99 float scale; |
| 94 } pinch_update; | 100 } pinch_update; |
| 95 }; | 101 }; |
| 96 } data; | 102 } details; |
| 97 | 103 |
| 98 private: | 104 private: |
| 99 GestureEventParams(); | 105 friend class GestureEventDataPacket; |
| 106 |
| 107 // Initializes type to GESTURE_TYPE_INVALID. |
| 108 GestureEventData(); |
| 100 }; | 109 }; |
| 101 | 110 |
| 102 } // namespace ui | 111 } // namespace ui |
| 103 | 112 |
| 104 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_PARAMS_H_ | 113 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_H_ |
| OLD | NEW |