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/rect.h" | 11 #include "ui/gfx/rect.h" |
12 #include "ui/gfx/rect_conversions.h" | 12 #include "ui/gfx/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 GestureEventDetails(); | 18 GestureEventDetails(); |
19 GestureEventDetails(EventType type, float delta_x, float delta_y); | 19 GestureEventDetails(EventType type, float delta_x, float delta_y); |
20 GestureEventDetails(EventType type, | |
21 float delta_x, float delta_y, | |
22 float delta_x_ordinal, float delta_y_ordinal); | |
23 | 20 |
24 EventType type() const { return type_; } | 21 EventType type() const { return type_; } |
25 | 22 |
26 int touch_points() const { return touch_points_; } | 23 int touch_points() const { return touch_points_; } |
27 void set_touch_points(int touch_points) { touch_points_ = touch_points; } | 24 void set_touch_points(int touch_points) { touch_points_ = touch_points; } |
28 | 25 |
29 // TODO(tdresser): Return RectF. See crbug.com/337824. | 26 // TODO(tdresser): Return RectF. See crbug.com/337824. |
30 const gfx::Rect bounding_box() const { | 27 const gfx::Rect bounding_box() const { |
31 return ToEnclosingRect(bounding_box_); | 28 return ToEnclosingRect(bounding_box_); |
32 } | 29 } |
(...skipping 27 matching lines...) Expand all Loading... |
60 float velocity_x() const { | 57 float velocity_x() const { |
61 DCHECK(type_ == ui::ET_SCROLL_FLING_START); | 58 DCHECK(type_ == ui::ET_SCROLL_FLING_START); |
62 return data.fling_velocity.x; | 59 return data.fling_velocity.x; |
63 } | 60 } |
64 | 61 |
65 float velocity_y() const { | 62 float velocity_y() const { |
66 DCHECK(type_ == ui::ET_SCROLL_FLING_START); | 63 DCHECK(type_ == ui::ET_SCROLL_FLING_START); |
67 return data.fling_velocity.y; | 64 return data.fling_velocity.y; |
68 } | 65 } |
69 | 66 |
70 // *_ordinal values are unmodified by rail based clamping. | |
71 float scroll_x_ordinal() const { | |
72 DCHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_); | |
73 return data.scroll_update.x_ordinal; | |
74 } | |
75 | |
76 float scroll_y_ordinal() const { | |
77 DCHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_); | |
78 return data.scroll_update.y_ordinal; | |
79 } | |
80 | |
81 float velocity_x_ordinal() const { | |
82 DCHECK(type_ == ui::ET_SCROLL_FLING_START); | |
83 return data.fling_velocity.x_ordinal; | |
84 } | |
85 | |
86 float velocity_y_ordinal() const { | |
87 DCHECK(type_ == ui::ET_SCROLL_FLING_START); | |
88 return data.fling_velocity.y_ordinal; | |
89 } | |
90 | |
91 float first_finger_width() const { | 67 float first_finger_width() const { |
92 DCHECK_EQ(ui::ET_GESTURE_TWO_FINGER_TAP, type_); | 68 DCHECK_EQ(ui::ET_GESTURE_TWO_FINGER_TAP, type_); |
93 return data.first_finger_enclosing_rectangle.width; | 69 return data.first_finger_enclosing_rectangle.width; |
94 } | 70 } |
95 | 71 |
96 float first_finger_height() const { | 72 float first_finger_height() const { |
97 DCHECK_EQ(ui::ET_GESTURE_TWO_FINGER_TAP, type_); | 73 DCHECK_EQ(ui::ET_GESTURE_TWO_FINGER_TAP, type_); |
98 return data.first_finger_enclosing_rectangle.height; | 74 return data.first_finger_enclosing_rectangle.height; |
99 } | 75 } |
100 | 76 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 struct { // SCROLL start details. | 113 struct { // SCROLL start details. |
138 // Distance that caused the scroll to start. Generally redundant with | 114 // Distance that caused the scroll to start. Generally redundant with |
139 // the x/y values from the first scroll_update. | 115 // the x/y values from the first scroll_update. |
140 float x_hint; | 116 float x_hint; |
141 float y_hint; | 117 float y_hint; |
142 } scroll_begin; | 118 } scroll_begin; |
143 | 119 |
144 struct { // SCROLL delta. | 120 struct { // SCROLL delta. |
145 float x; | 121 float x; |
146 float y; | 122 float y; |
147 float x_ordinal; | |
148 float y_ordinal; | |
149 } scroll_update; | 123 } scroll_update; |
150 | 124 |
151 float scale; // PINCH scale. | 125 float scale; // PINCH scale. |
152 | 126 |
153 struct { // FLING velocity. | 127 struct { // FLING velocity. |
154 float x; | 128 float x; |
155 float y; | 129 float y; |
156 float x_ordinal; | |
157 float y_ordinal; | |
158 } fling_velocity; | 130 } fling_velocity; |
159 | 131 |
160 // Dimensions of the first finger's enclosing rectangle for | 132 // Dimensions of the first finger's enclosing rectangle for |
161 // TWO_FINGER_TAP. | 133 // TWO_FINGER_TAP. |
162 struct { | 134 struct { |
163 float width; | 135 float width; |
164 float height; | 136 float height; |
165 } first_finger_enclosing_rectangle; | 137 } first_finger_enclosing_rectangle; |
166 | 138 |
167 struct { // SWIPE direction. | 139 struct { // SWIPE direction. |
(...skipping 11 matching lines...) Expand all Loading... |
179 int touch_points_; // Number of active touch points in the gesture. | 151 int touch_points_; // Number of active touch points in the gesture. |
180 | 152 |
181 // Bounding box is an axis-aligned rectangle that contains all the | 153 // Bounding box is an axis-aligned rectangle that contains all the |
182 // enclosing rectangles of the touch-points in the gesture. | 154 // enclosing rectangles of the touch-points in the gesture. |
183 gfx::RectF bounding_box_; | 155 gfx::RectF bounding_box_; |
184 }; | 156 }; |
185 | 157 |
186 } // namespace ui | 158 } // namespace ui |
187 | 159 |
188 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ | 160 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ |
OLD | NEW |