pub struct HitContext<'a> { /* private fields */ }Expand description
Everything a hit test needs to know that the arena cannot work out alone: which pointer is asking, which token ladder is in force, which way the UI reads, and which nodes refuse edits.
Built once per hit test and passed by reference through the recursion.
HitContext::mouse is the pointer-less door — an exact mouse hit test on
the Compact ladder, which is what every call site that predates the touch
programme has always meant.
Implementations§
Source§impl<'a> HitContext<'a>
impl<'a> HitContext<'a>
Sourcepub fn new(kind: PointerKind, tokens: &'a InputTokens) -> Self
pub fn new(kind: PointerKind, tokens: &'a InputTokens) -> Self
A hit test on behalf of kind against tokens, left-to-right, with no
read-only probe.
Sourcepub fn mouse() -> HitContext<'static>
pub fn mouse() -> HitContext<'static>
The pointer-less door: mouse, exact, Compact ladder.
This is what WidgetArena::hit_test_at
and the inspector’s picker use. The mouse’s slop radius is 0.0 at every
density, so the ladder choice is unobservable — it matters only to a
widget that opts a precise pointer into a hit outset.
Sourcepub fn direction(self, direction: LayoutDirection) -> Self
pub fn direction(self, direction: LayoutDirection) -> Self
Set the reading direction, so a widget’s leading / trailing hit
outsets land on the right screen edges.
Sourcepub fn without_slop(self) -> Self
pub fn without_slop(self) -> Self
Turn the miss-only slop pass off while keeping the pointer kind, so
the exact pass — including every widget’s Widget::hit_outset for that
kind — is all that runs.
The one consumer is the target-conformance audit
(target_audit), which measures a
control’s reach twice: once through this door and once through the full
one, and attributes the difference to the mechanism that produced it. A
harness that could not tell the two apart would certify a target and be
unable to say what makes it reachable.
Sourcepub fn read_only_probe(self, probe: &'a dyn Fn(WidgetId) -> bool) -> Self
pub fn read_only_probe(self, probe: &'a dyn Fn(WidgetId) -> bool) -> Self
Install a probe the slop pass calls to ask whether a node refuses edits.
A read-only surface is never a slop candidate, and “read-only” is a
question only TextSurface can
answer — the registry lives on the WidgetTree, not the arena, so the
tree hands the arena a probe rather than the arena reaching for state it
does not own.
Sourcepub fn kind(&self) -> PointerKind
pub fn kind(&self) -> PointerKind
The pointer kind this test serves.
Sourcepub fn tokens(&self) -> &InputTokens
pub fn tokens(&self) -> &InputTokens
The token ladder in force.
Sourcepub fn layout_direction(&self) -> LayoutDirection
pub fn layout_direction(&self) -> LayoutDirection
The reading direction.
Sourcepub fn default_slop(&self) -> HitSlop
pub fn default_slop(&self) -> HitSlop
The density default slop for this pointer — the last link of the precedence chain.
Sourcepub fn slop_enabled(&self) -> bool
pub fn slop_enabled(&self) -> bool
Whether the miss-only pass can produce anything at all. false for a
mouse, which is what keeps the historical path free of new work.
Sourcepub fn is_read_only(&self, id: WidgetId) -> bool
pub fn is_read_only(&self, id: WidgetId) -> bool
Ask the installed probe whether id refuses edits. false when no
probe was installed.