Skip to main content

HitContext

Struct HitContext 

Source
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>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn kind(&self) -> PointerKind

The pointer kind this test serves.

Source

pub fn tokens(&self) -> &InputTokens

The token ladder in force.

Source

pub fn layout_direction(&self) -> LayoutDirection

The reading direction.

Source

pub fn default_slop(&self) -> HitSlop

The density default slop for this pointer — the last link of the precedence chain.

Source

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.

Source

pub fn is_read_only(&self, id: WidgetId) -> bool

Ask the installed probe whether id refuses edits. false when no probe was installed.

Trait Implementations§

Source§

impl Debug for HitContext<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for HitContext<'a>

§

impl<'a> !Send for HitContext<'a>

§

impl<'a> !Sync for HitContext<'a>

§

impl<'a> !UnwindSafe for HitContext<'a>

§

impl<'a> Freeze for HitContext<'a>

§

impl<'a> Unpin for HitContext<'a>

§

impl<'a> UnsafeUnpin for HitContext<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.