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 "base/logging.h" | 8 #include "base/logging.h" |
9 #include "ui/events/event_constants.h" | 9 #include "ui/events/event_constants.h" |
10 #include "ui/events/events_base_export.h" | 10 #include "ui/events/events_base_export.h" |
11 #include "ui/gfx/geometry/rect.h" | 11 #include "ui/gfx/geometry/rect.h" |
12 #include "ui/gfx/geometry/rect_conversions.h" | 12 #include "ui/gfx/geometry/rect_conversions.h" |
13 | 13 |
14 namespace ui { | 14 namespace ui { |
15 | 15 |
16 struct EVENTS_BASE_EXPORT GestureEventDetails { | 16 struct EVENTS_BASE_EXPORT GestureEventDetails { |
17 public: | 17 public: |
| 18 enum class ScrollRailState { Vertical, Horizontal, Free }; |
| 19 |
18 GestureEventDetails(); | 20 GestureEventDetails(); |
19 explicit GestureEventDetails(EventType type); | 21 explicit GestureEventDetails(EventType type); |
| 22 GestureEventDetails(EventType type, |
| 23 float delta_x, |
| 24 float delta_y, |
| 25 ScrollRailState scroll_rail_state); |
20 GestureEventDetails(EventType type, float delta_x, float delta_y); | 26 GestureEventDetails(EventType type, float delta_x, float delta_y); |
21 | 27 |
22 // The caller is responsible for ensuring that the gesture data from |other| | 28 // The caller is responsible for ensuring that the gesture data from |other| |
23 // is compatible and sufficient for that expected by gestures of |type|. | 29 // is compatible and sufficient for that expected by gestures of |type|. |
24 GestureEventDetails(EventType type, const GestureEventDetails& other); | 30 GestureEventDetails(EventType type, const GestureEventDetails& other); |
25 | 31 |
26 EventType type() const { return type_; } | 32 EventType type() const { return type_; } |
27 | 33 |
28 int touch_points() const { return touch_points_; } | 34 int touch_points() const { return touch_points_; } |
29 void set_touch_points(int touch_points) { | 35 void set_touch_points(int touch_points) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 return data_.scroll_update.x; | 69 return data_.scroll_update.x; |
64 } | 70 } |
65 | 71 |
66 float scroll_y() const { | 72 float scroll_y() const { |
67 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); | 73 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); |
68 return data_.scroll_update.y; | 74 return data_.scroll_update.y; |
69 } | 75 } |
70 | 76 |
71 float velocity_x() const { | 77 float velocity_x() const { |
72 DCHECK_EQ(ET_SCROLL_FLING_START, type_); | 78 DCHECK_EQ(ET_SCROLL_FLING_START, type_); |
73 return data_.fling_velocity.x; | 79 return data_.fling_start.x; |
74 } | 80 } |
75 | 81 |
76 float velocity_y() const { | 82 float velocity_y() const { |
77 DCHECK_EQ(ET_SCROLL_FLING_START, type_); | 83 DCHECK_EQ(ET_SCROLL_FLING_START, type_); |
78 return data_.fling_velocity.y; | 84 return data_.fling_start.y; |
| 85 } |
| 86 |
| 87 ScrollRailState scroll_rail_state() const { |
| 88 switch(type_) { |
| 89 case ET_GESTURE_SCROLL_UPDATE: |
| 90 return data_.scroll_update.scroll_rail_state; |
| 91 case ET_SCROLL_FLING_START: |
| 92 return data_.fling_start.scroll_rail_state; |
| 93 default: |
| 94 NOTREACHED() << "Can't get scroll rail state for event type " << type_; |
| 95 } |
| 96 return ScrollRailState::Free; |
79 } | 97 } |
80 | 98 |
81 float first_finger_width() const { | 99 float first_finger_width() const { |
82 DCHECK_EQ(ET_GESTURE_TWO_FINGER_TAP, type_); | 100 DCHECK_EQ(ET_GESTURE_TWO_FINGER_TAP, type_); |
83 return data_.first_finger_enclosing_rectangle.width; | 101 return data_.first_finger_enclosing_rectangle.width; |
84 } | 102 } |
85 | 103 |
86 float first_finger_height() const { | 104 float first_finger_height() const { |
87 DCHECK_EQ(ET_GESTURE_TWO_FINGER_TAP, type_); | 105 DCHECK_EQ(ET_GESTURE_TWO_FINGER_TAP, type_); |
88 return data_.first_finger_enclosing_rectangle.height; | 106 return data_.first_finger_enclosing_rectangle.height; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 float x_hint; | 172 float x_hint; |
155 float y_hint; | 173 float y_hint; |
156 } scroll_begin; | 174 } scroll_begin; |
157 | 175 |
158 struct { // SCROLL delta. | 176 struct { // SCROLL delta. |
159 float x; | 177 float x; |
160 float y; | 178 float y; |
161 // Whether any previous scroll update in the current scroll sequence was | 179 // Whether any previous scroll update in the current scroll sequence was |
162 // suppressed because the underlying touch was consumed. | 180 // suppressed because the underlying touch was consumed. |
163 bool previous_update_in_sequence_prevented; | 181 bool previous_update_in_sequence_prevented; |
| 182 ScrollRailState scroll_rail_state; |
164 } scroll_update; | 183 } scroll_update; |
165 | 184 |
166 float scale; // PINCH scale. | 185 float scale; // PINCH scale. |
167 | 186 |
168 struct { // FLING velocity. | 187 struct { // FLING velocity. |
169 float x; | 188 float x; |
170 float y; | 189 float y; |
171 } fling_velocity; | 190 ScrollRailState scroll_rail_state; |
| 191 } fling_start; |
172 | 192 |
173 // Dimensions of the first finger's enclosing rectangle for | 193 // Dimensions of the first finger's enclosing rectangle for |
174 // TWO_FINGER_TAP. | 194 // TWO_FINGER_TAP. |
175 struct { | 195 struct { |
176 float width; | 196 float width; |
177 float height; | 197 float height; |
178 } first_finger_enclosing_rectangle; | 198 } first_finger_enclosing_rectangle; |
179 | 199 |
180 struct { // SWIPE direction. | 200 struct { // SWIPE direction. |
181 bool left; | 201 bool left; |
(...skipping 13 matching lines...) Expand all Loading... |
195 // enclosing rectangles of the touch-points in the gesture. | 215 // enclosing rectangles of the touch-points in the gesture. |
196 gfx::RectF bounding_box_; | 216 gfx::RectF bounding_box_; |
197 | 217 |
198 // The touch id of the oldest touch contributing to the gesture. | 218 // The touch id of the oldest touch contributing to the gesture. |
199 int oldest_touch_id_; | 219 int oldest_touch_id_; |
200 }; | 220 }; |
201 | 221 |
202 } // namespace ui | 222 } // namespace ui |
203 | 223 |
204 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ | 224 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ |
OLD | NEW |