| 200 | return processed; |
| 201 | } |
| 202 | |
| 203 | GestureTypes LayerRoot::getGesturesTypesForTouchEvent(const TouchEvent& event) const { |
| 204 | if (_contentLayer == nullptr) { |
| 205 | return GestureTypes(); |
| 206 | } |
| 207 | |
| 208 | auto gestureCandidates = _touchDispatcher.getGestureCandidatesForEvent(event, _contentLayer); |
| 209 | |
| 210 | GestureTypes types; |
| 211 | |
| 212 | for (const auto& gesture : gestureCandidates) { |
| 213 | if (Valdi::castOrNull<TapGestureRecognizer>(gesture) != nullptr) { |
| 214 | types.hasTap = true; |
| 215 | } else if (Valdi::castOrNull<ScrollGestureRecognizer>(gesture) != nullptr) { |
| 216 | types.hasScroll = true; |
| 217 | } else if (Valdi::castOrNull<DragGestureRecognizer>(gesture) != nullptr) { |
| 218 | types.hasDrag = true; |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | return types; |
| 223 | } |
| 224 | |
| 225 | bool LayerRoot::refreshTouches(const TimePoint& currentTime) { |
| 226 | if (_touchDispatcher.isEmpty()) { |
| 227 | return false; |
| 228 | } |
| 229 | if (!_touchDispatcher.getLastEvent()) { |
| 230 | return false; |
| 231 | } |
| 232 | |
| 233 | const auto& lastEvent = _touchDispatcher.getLastEvent().value(); |
| 234 | |
| 235 | auto offsetSinceLastEvent = currentTime - lastEvent.getTime(); |
| 236 | |
| 237 | if (offsetSinceLastEvent.milliseconds() < kTouchRefreshMs) { |
| 238 | // Only refresh gestures if there wasn't another event that came over 10ms ago |
| 239 | return false; |