Skip to main content

Module create

Module create 

Source
Expand description

The create family: the emitters that mint entities. Every one takes its new ids pre-minted — ops land with concrete ids, so a compound gesture (a wire and the pin it lands on) is one commit.

Structs§

NewBlock
The block a drag drew: where it lands, and the two corners it spans. A struct like NewPin and NewPort, because the emitter also needs the document to name it and seven loose arguments say nothing.
NewPin
A pin the gesture stamped on a block edge: pin’s parameters, and the rider route carries when a wire lands on a free slot.
NewPort
A boundary port the gesture stamped: the block whose boundary it joins, and the two corners of the body box drawn for it. Its slot is searched, not given.
NewRoute
One wire the gesture drew.
PathOrdinal
Where a grabbed corner lands in a route’s polyline — the arc-length ordinal the gesture classified against solved geometry the emitter cannot see. Past the end clamps to the end.

Enums§

RouteEnd
Where a drawn wire landed: on a pin that already exists, or on a free slot marker, which stamps the destination pin in the same commit.

Constants§

BLOCK_PREFIX 🔒
The auto-name a freshly drawn block carries, numbered across the whole document, so blocks the user declines to name still tell each other apart — which a shared “Untitled” does not.
PORT_PREFIX 🔒
The auto-name every stamped pin takes, numbered per owner.
STAMPED_AREA 🔒
STAMPED_PORT_WIDTH
TOP_BLOCK_DEFAULT_HEIGHT 🔒
TOP_BLOCK_DEFAULT_RECT 🔒
The rect a top block is born with: deliberately small and fixed rather than derived from what it holds.
TOP_BLOCK_DEFAULT_WIDTH 🔒
TOP_PREFIX 🔒
The auto-name a wrapped level takes.
UNTITLED 🔒
The name a freshly drawn area carries into its rename editor. A block gets a numbered one instead (BLOCK_PREFIX) — an area never appears in a breadcrumb, a hierarchy row or a PDF outline, which is where same-named neighbours were confusing.

Functions§

area
Inventory row “New Area”: a drag stamps a boundary annotation box. Unlike a block, an area holds no pins, so its height is whatever the drag drew.
block
Inventory row “New Block”: a drag stamps a child block on scope — the document root is a scope like any other. The parent’s child list is derived, so parent is the whole structural write.
block_title
A label at a block title’s resting side, for a caller naming one itself.
block_value
The block block stamps, as a value — for a caller that needs it in hand as well as in the commit. An embed does: the boundary its ports slot onto is this block’s, and the index has no row for it yet (clipboard::paste_into_fresh).
default_port_rect 🔒
Where a stamped pin’s port body sits inside its owner’s own interior view: the owner’s rect magnified by DEFAULT_SCALE_FOR_NEW_VIEW so the expanded view has room for child blocks, the body hugging the edge its slot sits on and tracking the slot down that edge. A body landing on an existing one steps outward by its own width until clear — bounded, so a pathological interior cannot spin.
demoted_rect 🔒
The rect the old root shows as once demoted: the one it already has, made tall enough that its lowest pin slot still fits. Its size is not derived from what it contains — a block as large as the whole drawing is unwieldy — and a degenerate rect (a root written before tops were born with a size) falls back to the default rather than demoting to an invisible sliver.
first_free_slot 🔒
The first slot the owner’s pins leave free, scanning top-down and West before East. Total: each offset offers two slots, so some slot at an offset in 0..=n escapes n occupants.
grown_to_fit 🔒
The growth rider: a block too short for slot grows two cells at a time until it fits. None when it already fits.
height_for_slot 🔒
The shortest block, in cells, that still offers slot slot: the slot’s own row plus the clearance max_pin_slot keeps below it.
label 🔒
A fresh label at its kind’s resting side: a block title sits at the bottom, a type label and an area title at the top.
next_free_title 🔒
The lowest {prefix}<n> from 1 up that no live block titles itself, so two blocks the user has not named are still told apart wherever their titles are listed — the nav breadcrumb, the hierarchy, the PDF outline.
next_pin_ordinal 🔒
The auto-name a stamped pin takes ("Port N", tag "N"Drawing::add_port_auto_named, add_named_pin). Ids count per document, not per block, so the number is read back off the owner’s pins: one past the highest they already carry.
owner_pins 🔒
pin
Inventory row “Add Pin (block edge)”: a click on a slot marker — or a wire pulled out of one — stamps a pin there.
pin_init 🔒
The pin a stamp lands as.
port
Inventory row “Add Port (boundary)”: stamp a port on the scope’s own boundary at the first free slot, growing the block until that slot fits.
route
Inventory row “New Route (wire)”: connect two pins along the solved path. A wire landing on a free slot carries its destination pin, and a destination the owner refuses takes the wire with it — a rejected route must never leave an orphan pin.
stamped 🔒
A default extent hung off a grid-snapped drop point — the arithmetic the stamped_* defaults share.
stamped_area
The box an area dropped on the canvas takes, on stamped_block’s terms. Wider than a block and free of its pin ladder: an area’s job is to enclose a few of them.
stamped_block
The box a block dropped on the canvas takes, anchored top-left at the drop point. A drop names one corner and a block needs two, so the extent is the one the document already gives a block nobody sized (TOP_BLOCK_DEFAULT_RECT) — deliberately small and fixed.
stamped_port
The body box a port stamped on the canvas takes, on stamped_block’s terms. Only the width is a default: the height is PORT_HEIGHT, which port forces on whatever box it is handed anyway.
text_box
Inventory row “New Text Box”: a click places an empty text annotation and opens its editor; emptying it there is what deletes it (naming::edit_text).
wire_label
Inventory row “Add Wire Label”: drop a name label on a wire, at the arc length the click projected onto its polyline.
wrap_top
Inventory row “Wrap Top”: add a level above the whole document — a fresh root whose sole child is the old one, which demotes to a child rect. A document with no root yet (top is NULL) has nothing to demote, so the wrap is just the new root.