class GestureArenaV2
Defined at line 164 of file ../../src/ui/a11y/lib/gesture_manager/arena_v2/gesture_arena_v2.h
The Gesture Arena for accessibility services.
The Gesture Arena manages several recognizers which are trying to interpret a gesture that is
being performed. It respects the following rules:
* Contests begin at the start of an interaction, and continue until every recognizer has either
accepted or rejected.
* Of the recognizers that accept, a win is awarded to the highest priority recognizer.
All recognizers must eventually accept or reject. Once a recognizer has decided, it may not
change its mind.
Recognizers continue to receive incoming pointer events until they release
their |ParticipationToken| or are defeated. After the winning recognizer
releases its |ParticipationToken|, the next interaction will begin a new
contest. (Or, if all recognizers reject, then the next interaction will begin
a new contest.)
The order in which recognizers are added to the arena determines event dispatch order and win
priority. When routing pointer events to recognizers, they see the event in order they were
added. During resolution, if multiple recognizers declared "accept", the one that was added
first is awarded the win.
In this model, it is important to notice that there are two layers of abstraction:
1. Raw pointer events, which come from the input system, arrive at the arena and are dispatched
to recognizers via an |InteractionTracker|.
2. Gestures, which are sequences of pointer events with a semantic meaning, are identified by
recognizers.
With that in mind, each recognizer defines the semantic meaning for the sequence of pointer
events that it is receiving. In another words, it is expected that a recognizer could identify a
single tap, another a double tap, and so on.
"Accepting" indicates that a recognizer identified a gesture. However, that recognizer may not
necessarily be awarded a win, if a higher priority recognizer also accepts. Recognizers are free
to handle their events optimistically, but if they do then they must undo/reset any changes they
effect if they are eventually defeated. For example, a single-tap recognizer may accept, but if
a higher-priority double-tap recognzier also accepts, the latter will win.
Recognizers should not destroy the arena.
If any recognizer accepts, the input system is immediately notified that the interactions
were consumed (as would be any new interactions until the end of the gesture).
If all recognizers reject, the input system is notified that the interactions were rejected.
Implementation notes: this arena is heavily influenced by Fluttter's gesture arena:
https://flutter.dev/docs/development/ui/advanced/gestures For those familiar how Flutter version
works, here are the important main differences:
- The arena here is not per finger (a.k.a. per pointer ID), which means that recognizers may
receive events from multiple interactions (i.e. fingers) concurrently.
- There are not default wins or multiple levels of acceptance. Recognizers must be certain when
they decide to accept.
Public Methods
void ~GestureArenaV2 ()
Defined at line 171 of file ../../src/ui/a11y/lib/gesture_manager/arena_v2/gesture_arena_v2.h
void GestureArenaV2 (InteractionTracker::HeldInteractionCallback callback)
The arena takes a callback, which is called on each interaction that became
closed before the contest's consumption status (accept or reject) was decided.
See `InteractionTracker` for details.
Defined at line 179 of file ../../src/ui/a11y/lib/gesture_manager/arena_v2/gesture_arena_v2.cc
void Add (GestureRecognizerV2 * recognizer)
Adds a new recognizer to the arena. The new recognizer starts participating in the next
contest.
Defined at line 182 of file ../../src/ui/a11y/lib/gesture_manager/arena_v2/gesture_arena_v2.cc
InteractionTracker::ConsumptionStatus Status ()
Return the consumption status of the current contest.
Defined at line 188 of file ../../src/ui/a11y/lib/gesture_manager/arena_v2/gesture_arena_v2.h
void ClearRecognizers ()
Clears all recognizers from the arena.
Defined at line 189 of file ../../src/ui/a11y/lib/gesture_manager/arena_v2/gesture_arena_v2.cc
InteractionTracker::ConsumptionStatus OnEvent (const fuchsia::ui::pointer::augment::TouchEventWithLocalHit & event)
Dispatches a new pointer event to this arena. This event gets sent to all participating
recognizers.
Virtual for testing; overridden by a mock.
Defined at line 204 of file ../../src/ui/a11y/lib/gesture_manager/arena_v2/gesture_arena_v2.cc