Skip to main content

Module hit_test

Module hit_test 

Source
Expand description

Bounding-box estimators for hit-testing pin/port labels and stubs. These mirror the geometry the drawing primitives use, but return the rect rather than painting — driving click/drag/marquee targets in widget. They measure text through whichever Renderer backend the caller holds, so a hit test is exercisable without an egui context.

Structs§

PinExtent
Bounding box of a whole pin as drawn — its stub plus the name and tag labels — at the given side/offset. Tools frame selected pins with this so the idle selection rectangle and the drag preview enclose the same parts and the frame doesn’t change shape when a drag begins.
TagSlot
Shared tag-rect computation used by both block pins and ports. left/right are the shape’s edge x-coordinates; line_y the stub’s y.

Functions§

block_pin_label_anchor 🔒
World anchor (and horizontal alignment) of a block pin’s labels, matching pin_text_location.
estimate_bbox_for_pin_name
pin_name_rect_at for a block pin given its side/offset.
estimate_bbox_for_pin_stub
Hit region for a pin/port stub (the red line): the stub segment, widened to +/- GRID_SIZE / 3 vertically so it presents an easy click target. left/right are the shape’s edge x-coordinates; line_y the stub’s y.
estimate_bbox_for_pin_type
pin_type_rect_at for a block pin given its side/offset.
pin_name_rect_at
Rect of a pin’s name line at world anchor pos/h_align, positioned exactly as draw_pin_labels (centered on the stub). An empty name is sized to the “Add Name” placeholder so the slot stays a click/placeholder target while the shape is selected.
pin_type_rect_at
Rect of a pin’s type line — the sibling of pin_name_rect_at, measured in the smaller subtitle font and placed just below the name.