Skip to main content

Module layout

Module layout 

Source
Expand description

Pure position/alignment helpers shared by the drawing primitives and by the hit-testing in widget. No drawing happens here — each function maps an element’s geometry to a label anchor (and its Align2).

Constants§

PIN_TAG_RISE 🔒
Vertical gap, in world units, between a pin/port’s stub line and the baseline-center of the tag label drawn above it.

Functions§

block_title_position
block_type_position
clamp_label_offset
Clamp a block label’s horizontal offset so its text of width text_width stays within the block’s horizontal extent, given the label’s horizontal anchor — Align::Center for the title, Align::Min (left) for the type, Align::Max (right) for the tag. When the text is wider than the block the label is pinned flush to its anchored edge.
clamped_block_title_position
Like block_title_position, but clamps the horizontal offset so a title of width text_width stays within the block (pinning flush when wider). Used at draw time so a later resize can’t leave a stale offset drawing outside the block.
clamped_block_type_position
Like block_type_position, but clamps the horizontal offset so a type label of width text_width stays within the block (pinning flush when wider). Used at draw time so a later resize can’t leave a stale offset drawing outside.
label_side_for_y
The LabelSide a block label snaps to when its anchor is dragged to y: the top third of the block is Top, the bottom third Bottom, the middle Center. Shared by the live drag preview and the drag-commit so both agree.
pin_tag_location
Position and alignment for the tag label, which sits above the stub line hugging the shape edge: right-justified on the West side, left-justified on the East side (opposite to how name is justified). left/right are the shape’s edge x-coordinates (the inner end of the stub); line_y is the stub’s y.
pin_text_location
port_text_center
title_anchor 🔒
type_anchor 🔒
Placement of a block’s type label. Mirrors block_title_position but is left-anchored to the block’s left edge, so the default (offset == 0, side == Top) sits in the upper-left corner with the text baseline on the top edge and the left edge flush with the block’s.