Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::view::HitMetrics Struct Reference

Minimum hit-target sizing for one pointer type. More...

#include <hit_metrics.hpp>

Public Member Functions

constexpr float effective_target_pt () const noexcept
 Effective target extent in points, resolving 0 to the type default.
constexpr float tolerance_px (float pixels_per_point=1.0f) const noexcept
 One-sided tolerance in pixels for a distance-from-anchor hit test.

Static Public Member Functions

static constexpr float default_min_target_pt (PointerType type) noexcept
 Minimum comfortable target extent for a pointer type, in points.
static constexpr HitMetrics for_pointer (PointerType type) noexcept
 Metrics carrying this pointer type's default target extent.

Public Attributes

PointerType pointer_type = PointerType::mouse
float min_target_pt = 0.0f
 Full minimum target extent in points. Zero selects the per-type default.

Detailed Description

Minimum hit-target sizing for one pointer type.

A 44pt touch target and a 4px mouse target are the SAME hit test evaluated with different metrics, not two hit tests with two code paths. Callers that used to hard-code a tolerance_px now carry a HitMetrics and project it, so widening touch targets never means duplicating the geometry.

min_target_pt is the full edge length the target must present to this pointer type. Hit tests measure distance from a target's anchor, so the usable tolerance is half that extent on each side: a mouse asking for an 8pt target accepts anything within 4px on a 1x surface, which is the value the waveform handle hit test carried literally before this existed.

Member Function Documentation

◆ default_min_target_pt()

constexpr float pulp::view::HitMetrics::default_min_target_pt ( PointerType type)
inlinestaticconstexprnoexcept

Minimum comfortable target extent for a pointer type, in points.

Touch uses the 44pt figure Apple's HIG specifies for finger targets. Pen sits between the two: more precise than a finger, less than a cursor.

◆ effective_target_pt()

float pulp::view::HitMetrics::effective_target_pt ( ) const
inlinenodiscardconstexprnoexcept

Effective target extent in points, resolving 0 to the type default.

◆ for_pointer()

constexpr HitMetrics pulp::view::HitMetrics::for_pointer ( PointerType type)
inlinestaticconstexprnoexcept

Metrics carrying this pointer type's default target extent.

◆ tolerance_px()

float pulp::view::HitMetrics::tolerance_px ( float pixels_per_point = 1.0f) const
inlinenodiscardconstexprnoexcept

One-sided tolerance in pixels for a distance-from-anchor hit test.

pixels_per_point converts the point-space target to the surface's pixel space; it is 1.0 on a 1x surface, where the mouse default yields 4px.

Member Data Documentation

◆ min_target_pt

float pulp::view::HitMetrics::min_target_pt = 0.0f

Full minimum target extent in points. Zero selects the per-type default.

◆ pointer_type

PointerType pulp::view::HitMetrics::pointer_type = PointerType::mouse

The documentation for this struct was generated from the following file: