pub struct HitSlop {
pub radius: f32,
pub up_to: f32,
}Expand description
How far a miss may be re-attributed to a target, and up to what target size the offer stands.
radius is a hard ceiling in dp; up_to is the size a target is topped up
towards. See the module docs for the formula and why a large node earns
nothing.
Fields§
§radius: f32The largest outset any node may earn, in dp. 0.0 disables the
mechanism outright.
up_to: f32The target size a node is topped up towards, in dp. A node already at least this big on its smaller axis earns no outset at all.
Implementations§
Source§impl HitSlop
impl HitSlop
Sourcepub const NONE: HitSlop
pub const NONE: HitSlop
No slop at all — the mouse’s value, and what
no_hit_slop resolves
to.
Sourcepub fn for_pointer(kind: PointerKind, tokens: &InputTokens) -> Self
pub fn for_pointer(kind: PointerKind, tokens: &InputTokens) -> Self
The density default for a pointer kind: the kind’s profile hit_slop,
capped for a coarse pointer by InputTokens::slop_budget, topped up
towards InputTokens::target_size.
A precise pointer (mouse, pen) never draws on the budget — its radius is
already the tool’s, and the budget describes a contact patch it does not
have. The mouse’s profile radius is 0.0, so this returns
NONE for a mouse at every density.
Sourcepub fn outset_for(&self, size: Size) -> f32
pub fn outset_for(&self, size: Size) -> f32
The outset a node of size earns:
((up_to − min(w, h)) / 2).clamp(0, radius).
Zero for any node already at least up_to on its smaller axis, and zero
for a degenerate (non-finite, negative) size.