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> | 8 #include <string.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "ui/events/event_constants.h" | 11 #include "ui/events/event_constants.h" |
12 #include "ui/events/events_base_export.h" | 12 #include "ui/events/events_base_export.h" |
13 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
14 #include "ui/gfx/geometry/rect_conversions.h" | 14 #include "ui/gfx/geometry/rect_conversions.h" |
15 | 15 |
16 namespace ui { | 16 namespace ui { |
17 | 17 |
18 struct EVENTS_BASE_EXPORT GestureEventDetails { | 18 struct EVENTS_BASE_EXPORT GestureEventDetails { |
19 public: | 19 public: |
20 enum ScrollUnits { PrecisePixels = 0, Pixels, Page }; | |
sky
2017/02/17 18:00:25
chrome style is ALL_CAPS. Also, use enum class.
A
chengx
2017/02/17 20:52:46
I copied this enum definition from WebGestureEvent
| |
20 GestureEventDetails(); | 21 GestureEventDetails(); |
21 explicit GestureEventDetails(EventType type); | 22 explicit GestureEventDetails(EventType type); |
22 GestureEventDetails(EventType type, float delta_x, float delta_y); | 23 GestureEventDetails(EventType type, |
24 float delta_x, | |
25 float delta_y, | |
26 ScrollUnits units = PrecisePixels); | |
23 | 27 |
24 // 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| |
25 // is compatible and sufficient for that expected by gestures of |type|. | 29 // is compatible and sufficient for that expected by gestures of |type|. |
26 GestureEventDetails(EventType type, const GestureEventDetails& other); | 30 GestureEventDetails(EventType type, const GestureEventDetails& other); |
27 | 31 |
28 EventType type() const { return type_; } | 32 EventType type() const { return type_; } |
29 | 33 |
30 GestureDeviceType device_type() const { return device_type_; } | 34 GestureDeviceType device_type() const { return device_type_; } |
31 void set_device_type(GestureDeviceType device_type) { | 35 void set_device_type(GestureDeviceType device_type) { |
32 device_type_ = device_type; | 36 device_type_ = device_type; |
(...skipping 18 matching lines...) Expand all Loading... | |
51 float scroll_x_hint() const { | 55 float scroll_x_hint() const { |
52 DCHECK_EQ(ET_GESTURE_SCROLL_BEGIN, type_); | 56 DCHECK_EQ(ET_GESTURE_SCROLL_BEGIN, type_); |
53 return data_.scroll_begin.x_hint; | 57 return data_.scroll_begin.x_hint; |
54 } | 58 } |
55 | 59 |
56 float scroll_y_hint() const { | 60 float scroll_y_hint() const { |
57 DCHECK_EQ(ET_GESTURE_SCROLL_BEGIN, type_); | 61 DCHECK_EQ(ET_GESTURE_SCROLL_BEGIN, type_); |
58 return data_.scroll_begin.y_hint; | 62 return data_.scroll_begin.y_hint; |
59 } | 63 } |
60 | 64 |
65 ScrollUnits scroll_units_hint() const { | |
sky
2017/02/17 18:00:25
scroll_begin_units?
chengx
2017/02/17 20:52:46
Done.
| |
66 DCHECK_EQ(ET_GESTURE_SCROLL_BEGIN, type_); | |
67 return data_.scroll_begin.deltaHintUnits; | |
68 } | |
69 | |
61 float scroll_x() const { | 70 float scroll_x() const { |
62 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); | 71 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); |
63 return data_.scroll_update.x; | 72 return data_.scroll_update.x; |
64 } | 73 } |
65 | 74 |
66 float scroll_y() const { | 75 float scroll_y() const { |
67 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); | 76 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); |
68 return data_.scroll_update.y; | 77 return data_.scroll_update.y; |
69 } | 78 } |
70 | 79 |
80 ScrollUnits scroll_units() const { | |
sky
2017/02/17 18:00:25
scroll_update_units?
chengx
2017/02/17 20:52:46
Done.
| |
81 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); | |
82 return data_.scroll_update.deltaUnits; | |
83 } | |
84 | |
71 float velocity_x() const { | 85 float velocity_x() const { |
72 DCHECK_EQ(ET_SCROLL_FLING_START, type_); | 86 DCHECK_EQ(ET_SCROLL_FLING_START, type_); |
73 return data_.fling_velocity.x; | 87 return data_.fling_velocity.x; |
74 } | 88 } |
75 | 89 |
76 float velocity_y() const { | 90 float velocity_y() const { |
77 DCHECK_EQ(ET_SCROLL_FLING_START, type_); | 91 DCHECK_EQ(ET_SCROLL_FLING_START, type_); |
78 return data_.fling_velocity.y; | 92 return data_.fling_velocity.y; |
79 } | 93 } |
80 | 94 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 | 169 |
156 private: | 170 private: |
157 EventType type_; | 171 EventType type_; |
158 union Details { | 172 union Details { |
159 Details(); | 173 Details(); |
160 struct { // SCROLL start details. | 174 struct { // SCROLL start details. |
161 // Distance that caused the scroll to start. Generally redundant with | 175 // Distance that caused the scroll to start. Generally redundant with |
162 // the x/y values from the first scroll_update. | 176 // the x/y values from the first scroll_update. |
163 float x_hint; | 177 float x_hint; |
164 float y_hint; | 178 float y_hint; |
179 ScrollUnits deltaHintUnits; | |
sky
2017/02/17 18:00:25
delta_hint_units.
chengx
2017/02/17 20:52:46
Done.
| |
165 } scroll_begin; | 180 } scroll_begin; |
166 | 181 |
167 struct { // SCROLL delta. | 182 struct { // SCROLL delta. |
168 float x; | 183 float x; |
169 float y; | 184 float y; |
185 ScrollUnits deltaUnits; | |
sky
2017/02/17 18:00:25
delta_units.
chengx
2017/02/17 20:52:46
Done.
| |
170 // Whether any previous scroll update in the current scroll sequence was | 186 // Whether any previous scroll update in the current scroll sequence was |
171 // suppressed because the underlying touch was consumed. | 187 // suppressed because the underlying touch was consumed. |
172 bool previous_update_in_sequence_prevented; | 188 bool previous_update_in_sequence_prevented; |
173 } scroll_update; | 189 } scroll_update; |
174 | 190 |
175 float scale; // PINCH scale. | 191 float scale; // PINCH scale. |
176 | 192 |
177 struct { // FLING velocity. | 193 struct { // FLING velocity. |
178 float x; | 194 float x; |
179 float y; | 195 float y; |
(...skipping 23 matching lines...) Expand all Loading... | |
203 int touch_points_; // Number of active touch points in the gesture. | 219 int touch_points_; // Number of active touch points in the gesture. |
204 | 220 |
205 // Bounding box is an axis-aligned rectangle that contains all the | 221 // Bounding box is an axis-aligned rectangle that contains all the |
206 // enclosing rectangles of the touch-points in the gesture. | 222 // enclosing rectangles of the touch-points in the gesture. |
207 gfx::RectF bounding_box_; | 223 gfx::RectF bounding_box_; |
208 }; | 224 }; |
209 | 225 |
210 } // namespace ui | 226 } // namespace ui |
211 | 227 |
212 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ | 228 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ |
OLD | NEW |