Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
hit_metrics.hpp
Go to the documentation of this file.
1#pragma once
2
5
7
8#include <algorithm>
9
10namespace pulp::view {
11
24struct HitMetrics {
27 float min_target_pt = 0.0f;
28
33 static constexpr float default_min_target_pt(PointerType type) noexcept {
34 switch (type) {
35 case PointerType::touch: return 44.0f;
36 case PointerType::pen: return 12.0f;
37 case PointerType::mouse: break;
38 }
39 return 8.0f;
40 }
41
43 static constexpr HitMetrics for_pointer(PointerType type) noexcept {
45 }
46
48 [[nodiscard]] constexpr float effective_target_pt() const noexcept {
50 }
51
56 [[nodiscard]] constexpr float tolerance_px(float pixels_per_point = 1.0f) const noexcept {
57 const float scale = pixels_per_point > 0.0f ? pixels_per_point : 1.0f;
58 return effective_target_pt() * 0.5f * scale;
59 }
60};
61
62} // namespace pulp::view
Input event types with modifier keys and pointer IDs.
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
@ type
Built-in / common type name (e.g. int, Number).
Definition code_editor_tokenizer.hpp:39
PointerType
Pointer device type (W3C PointerEvent.pointerType).
Definition input_events.hpp:75
@ pen
Stylus / Apple Pencil.
Definition input_events.hpp:78
@ mouse
Mouse cursor (default).
Definition input_events.hpp:76
@ touch
Direct touch (finger).
Definition input_events.hpp:77
@ scale
Definition css_animation.hpp:126
Minimum hit-target sizing for one pointer type.
Definition hit_metrics.hpp:24
constexpr float effective_target_pt() const noexcept
Effective target extent in points, resolving 0 to the type default.
Definition hit_metrics.hpp:48
static constexpr HitMetrics for_pointer(PointerType type) noexcept
Metrics carrying this pointer type's default target extent.
Definition hit_metrics.hpp:43
constexpr float tolerance_px(float pixels_per_point=1.0f) const noexcept
One-sided tolerance in pixels for a distance-from-anchor hit test.
Definition hit_metrics.hpp:56
static constexpr float default_min_target_pt(PointerType type) noexcept
Minimum comfortable target extent for a pointer type, in points.
Definition hit_metrics.hpp:33
float min_target_pt
Full minimum target extent in points. Zero selects the per-type default.
Definition hit_metrics.hpp:27
PointerType pointer_type
Definition hit_metrics.hpp:25