Expand description
Multi-touch gesture recogniser.
The platform shells (web JS, native winit) forward raw touch events
to [App::on_touch_start/move/end/cancel]. TouchState maintains
the set of active touches and, once two or more fingers are down,
aggregates them each frame into a MultiTouchInfo describing zoom,
rotation, pan, and average pressure relative to the previous frame.
Widgets that want to react to gestures read the current frame’s
aggregate via current_multi_touch, a thread-local written by
[App::publish_multi_touch] at the start of each paint. Single-
finger touches continue to flow through the regular mouse-emulation
path, so existing widgets keep working with no changes.
The API shape deliberately mirrors egui’s (zoom_delta,
rotation_delta, translation_delta, num_touches, center_pos)
so ports from egui code read cleanly.
Structs§
- Multi
Touch Info - Gesture aggregate for the current frame, produced when two or more
fingers are on the same device. All deltas are relative to the
previous frame’s positions — the widget just accumulates them into
its own angle / scale / translation state (see
LionViewfor the canonical consumer). - Touch
Device Id - Stable per-device identifier. Different physical input surfaces
(e.g. a laptop’s built-in touchscreen and a connected tablet) hash
to different values. The web shell always uses
0(the browser doesn’t expose multiple touch devices to pages); winit passes through its device id. - TouchId
- Per-finger identifier, stable from Start through End/Cancel. Re- used after lift — browsers and winit both guarantee identifiers are unique only for the lifetime of the touch.
- Touch
State - Tracks every active touch across every known device. Lives on
App; widgets never see this directly.
Enums§
- Touch
Phase - Which phase of the gesture this touch event represents.
Functions§
- current_
multi_ touch - Fetch the current frame’s multi-touch aggregate. Returns
Nonewhen fewer than two fingers are down on any device, so a widget writes:if let Some(mt) = current_multi_touch() { … }. - last_
touch_ event_ age - Time elapsed since the most recent touch lifecycle event, or
Noneif no touch event has ever fired. Mouse events synthesised from a touchstart / touchend by the web shell arrive within a millisecond of the touch event — widgets needing to tell touch-synthesised mouse events apart from real desktop clicks check this against a small threshold. - set_
current - Publish this frame’s multi-touch aggregate. Called by
App::paintright before painting begins.