OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "ui/aura/gestures/gesture_sequence.h" | 5 #include "ui/aura/gestures/gesture_sequence.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "ui/aura/event.h" | 9 #include "ui/aura/event.h" |
10 #include "ui/base/events.h" | 10 #include "ui/base/events.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 break; | 92 break; |
93 } | 93 } |
94 | 94 |
95 if (event.type() == ui::ET_TOUCH_RELEASED) | 95 if (event.type() == ui::ET_TOUCH_RELEASED) |
96 --point_count_; | 96 --point_count_; |
97 | 97 |
98 return gestures.release(); | 98 return gestures.release(); |
99 } | 99 } |
100 | 100 |
101 void GestureSequence::Reset() { | 101 void GestureSequence::Reset() { |
102 state_ = GS_NO_GESTURE; | 102 set_state(GS_NO_GESTURE); |
103 for (int i = 0; i < point_count_; ++i) | 103 for (int i = 0; i < point_count_; ++i) |
104 points_[i].Reset(); | 104 points_[i].Reset(); |
105 } | 105 } |
106 | 106 |
107 //////////////////////////////////////////////////////////////////////////////// | 107 //////////////////////////////////////////////////////////////////////////////// |
108 // GestureSequence Private: | 108 // GestureSequence Private: |
109 | 109 |
110 unsigned int GestureSequence::Signature(GestureState gesture_state, | 110 unsigned int GestureSequence::Signature(GestureState gesture_state, |
111 unsigned int touch_id, | 111 unsigned int touch_id, |
112 ui::EventType type, | 112 ui::EventType type, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 base::Time::FromDoubleT(point.last_touch_time()), | 189 base::Time::FromDoubleT(point.last_touch_time()), |
190 point.x_delta(), point.y_delta()))); | 190 point.x_delta(), point.y_delta()))); |
191 } | 191 } |
192 | 192 |
193 bool GestureSequence::Click(const TouchEvent& event, | 193 bool GestureSequence::Click(const TouchEvent& event, |
194 const GesturePoint& point, Gestures* gestures) { | 194 const GesturePoint& point, Gestures* gestures) { |
195 if (point.IsInClickWindow(event)) { | 195 if (point.IsInClickWindow(event)) { |
196 AppendClickGestureEvent(point, gestures); | 196 AppendClickGestureEvent(point, gestures); |
197 if (point.IsInDoubleClickWindow(event)) | 197 if (point.IsInDoubleClickWindow(event)) |
198 AppendDoubleClickGestureEvent(point, gestures); | 198 AppendDoubleClickGestureEvent(point, gestures); |
| 199 set_state(GS_NO_GESTURE); |
199 return true; | 200 return true; |
200 } | 201 } |
201 return false; | 202 return false; |
202 } | 203 } |
203 | 204 |
204 bool GestureSequence::InClickOrScroll(const TouchEvent& event, | 205 bool GestureSequence::InClickOrScroll(const TouchEvent& event, |
205 const GesturePoint& point, Gestures* gestures) { | 206 const GesturePoint& point, Gestures* gestures) { |
206 if (point.IsInClickWindow(event)) { | 207 if (point.IsInClickWindow(event)) { |
207 set_state(GS_PENDING_SYNTHETIC_CLICK); | 208 set_state(GS_PENDING_SYNTHETIC_CLICK); |
208 return false; | 209 return false; |
209 } | 210 } |
210 if (point.IsInScrollWindow(event)) { | 211 if (point.IsInScrollWindow(event)) { |
211 AppendScrollGestureBegin(point, gestures); | 212 AppendScrollGestureBegin(point, gestures); |
212 AppendScrollGestureUpdate(point, gestures); | 213 AppendScrollGestureUpdate(point, gestures); |
213 set_state(GS_SCROLL); | 214 set_state(GS_SCROLL); |
214 return true; | 215 return true; |
215 } | 216 } |
216 return false; | 217 return false; |
217 } | 218 } |
218 | 219 |
219 bool GestureSequence::InScroll(const TouchEvent& event, | 220 bool GestureSequence::InScroll(const TouchEvent& event, |
220 const GesturePoint& point, Gestures* gestures) { | 221 const GesturePoint& point, Gestures* gestures) { |
| 222 if (!point.DidScroll(event)) |
| 223 return false; |
221 AppendScrollGestureUpdate(point, gestures); | 224 AppendScrollGestureUpdate(point, gestures); |
222 return true; | 225 return true; |
223 } | 226 } |
224 | 227 |
225 bool GestureSequence::NoGesture(const TouchEvent&, | 228 bool GestureSequence::NoGesture(const TouchEvent&, |
226 const GesturePoint& point, Gestures*) { | 229 const GesturePoint& point, Gestures*) { |
227 Reset(); | 230 Reset(); |
228 return false; | 231 return false; |
229 } | 232 } |
230 | 233 |
231 bool GestureSequence::TouchDown(const TouchEvent& event, | 234 bool GestureSequence::TouchDown(const TouchEvent& event, |
232 const GesturePoint& point, Gestures* gestures) { | 235 const GesturePoint& point, Gestures* gestures) { |
233 AppendTapDownGestureEvent(point, gestures); | 236 AppendTapDownGestureEvent(point, gestures); |
234 set_state(GS_PENDING_SYNTHETIC_CLICK); | 237 set_state(GS_PENDING_SYNTHETIC_CLICK); |
235 return false; | 238 return false; |
236 } | 239 } |
237 | 240 |
238 bool GestureSequence::ScrollEnd(const TouchEvent& event, | 241 bool GestureSequence::ScrollEnd(const TouchEvent& event, |
239 const GesturePoint& point, Gestures* gestures) { | 242 const GesturePoint& point, Gestures* gestures) { |
240 if (point.IsInFlickWindow(event)) | 243 if (point.IsInFlickWindow(event)) |
241 AppendScrollGestureEnd(point, gestures, point.x_velocity(), | 244 AppendScrollGestureEnd(point, gestures, point.x_velocity(), |
242 point.y_velocity()); | 245 point.y_velocity()); |
243 else | 246 else |
244 AppendScrollGestureEnd(point, gestures, 0.f, 0.f); | 247 AppendScrollGestureEnd(point, gestures, 0.f, 0.f); |
245 set_state(GS_NO_GESTURE); | |
246 Reset(); | 248 Reset(); |
247 return false; | 249 return false; |
248 } | 250 } |
249 | 251 |
250 } // namespace aura | 252 } // namespace aura |
OLD | NEW |