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_DETAILS_H_ | 5 #ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ |
6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ | 6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ |
7 | 7 |
8 #include <string.h> | |
9 | |
10 #include "base/logging.h" | 8 #include "base/logging.h" |
11 #include "ui/events/event_constants.h" | 9 #include "ui/events/event_constants.h" |
12 #include "ui/events/events_base_export.h" | 10 #include "ui/events/events_base_export.h" |
13 #include "ui/gfx/geometry/rect.h" | 11 #include "ui/gfx/geometry/rect.h" |
14 #include "ui/gfx/geometry/rect_conversions.h" | 12 #include "ui/gfx/geometry/rect_conversions.h" |
15 | 13 |
16 namespace IPC { | |
17 template <class P> struct ParamTraits; | |
18 } | |
19 | |
20 namespace ui { | 14 namespace ui { |
21 | 15 |
22 struct EVENTS_BASE_EXPORT GestureEventDetails { | 16 struct EVENTS_BASE_EXPORT GestureEventDetails { |
23 public: | 17 public: |
24 GestureEventDetails(); | 18 GestureEventDetails(); |
25 explicit GestureEventDetails(EventType type); | 19 explicit GestureEventDetails(EventType type); |
26 GestureEventDetails(EventType type, float delta_x, float delta_y); | 20 GestureEventDetails(EventType type, float delta_x, float delta_y); |
27 | 21 |
28 // The caller is responsible for ensuring that the gesture data from |other| | 22 // The caller is responsible for ensuring that the gesture data from |other| |
29 // is compatible and sufficient for that expected by gestures of |type|. | 23 // is compatible and sufficient for that expected by gestures of |type|. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 void mark_previous_scroll_update_in_sequence_prevented() { | 130 void mark_previous_scroll_update_in_sequence_prevented() { |
137 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); | 131 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); |
138 data_.scroll_update.previous_update_in_sequence_prevented = true; | 132 data_.scroll_update.previous_update_in_sequence_prevented = true; |
139 } | 133 } |
140 | 134 |
141 bool previous_scroll_update_in_sequence_prevented() const { | 135 bool previous_scroll_update_in_sequence_prevented() const { |
142 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); | 136 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); |
143 return data_.scroll_update.previous_update_in_sequence_prevented; | 137 return data_.scroll_update.previous_update_in_sequence_prevented; |
144 } | 138 } |
145 | 139 |
146 // Supports comparison over internal structures for testing. | |
147 bool operator==(const GestureEventDetails& other) const { | |
148 return type_ == other.type_ && | |
149 !memcmp(&data_, &other.data_, sizeof(Details)) && | |
150 touch_points_ == other.touch_points_ && | |
151 bounding_box_ == other.bounding_box_; | |
152 } | |
153 | |
154 private: | 140 private: |
155 EventType type_; | 141 EventType type_; |
156 union Details { | 142 union Details { |
157 Details(); | 143 Details(); |
158 struct { // SCROLL start details. | 144 struct { // SCROLL start details. |
159 // Distance that caused the scroll to start. Generally redundant with | 145 // Distance that caused the scroll to start. Generally redundant with |
160 // the x/y values from the first scroll_update. | 146 // the x/y values from the first scroll_update. |
161 float x_hint; | 147 float x_hint; |
162 float y_hint; | 148 float y_hint; |
163 } scroll_begin; | 149 } scroll_begin; |
(...skipping 25 matching lines...) Expand all Loading... |
189 bool right; | 175 bool right; |
190 bool up; | 176 bool up; |
191 bool down; | 177 bool down; |
192 } swipe; | 178 } swipe; |
193 | 179 |
194 // Tap information must be set for ET_GESTURE_TAP, | 180 // Tap information must be set for ET_GESTURE_TAP, |
195 // ET_GESTURE_TAP_UNCONFIRMED, and ET_GESTURE_DOUBLE_TAP events. | 181 // ET_GESTURE_TAP_UNCONFIRMED, and ET_GESTURE_DOUBLE_TAP events. |
196 int tap_count; // TAP repeat count. | 182 int tap_count; // TAP repeat count. |
197 } data_; | 183 } data_; |
198 | 184 |
199 // For mojo native implementation of (de)serialization. | |
200 friend struct IPC::ParamTraits<ui::GestureEventDetails>; | |
201 friend struct IPC::ParamTraits<ui::GestureEventDetails::Details>; | |
202 | |
203 int touch_points_; // Number of active touch points in the gesture. | 185 int touch_points_; // Number of active touch points in the gesture. |
204 | 186 |
205 // Bounding box is an axis-aligned rectangle that contains all the | 187 // Bounding box is an axis-aligned rectangle that contains all the |
206 // enclosing rectangles of the touch-points in the gesture. | 188 // enclosing rectangles of the touch-points in the gesture. |
207 gfx::RectF bounding_box_; | 189 gfx::RectF bounding_box_; |
208 }; | 190 }; |
209 | 191 |
210 } // namespace ui | 192 } // namespace ui |
211 | 193 |
212 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ | 194 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ |
OLD | NEW |