Skip to main content

Module resize_block

Module resize_block 

Source

StructsΒ§

Resize πŸ”’
The resize delta a shape+mode commits to for the accumulated raw_delta, computed from immutable reads only (so it can run before a mutable apply, as DragStopped needs). The pipeline: constrain_resize_delta β†’ clamp_to_min_height β†’ clamp_to_min_width β†’ clamp_to_widest β†’ contain-icon, and for a free image/icon β†’ aspect snap β†’ contain β†’ edge magnetism β†’ contain. Both the drag preview and the drop apply this, so they agree. An icon is re-contained after every snap, so containment always wins.
ResizeBounds
The sizes a resize stays between, taken when it begins.

EnumsΒ§

ResizeBlock

ConstantsΒ§

MIN_BLOCK_WIDTH πŸ”’
Smallest width a block or a text box may be resized to: 4 grid cells. Ports, areas, images, and icons are exempt (they may be narrower) β€” see min_resize_size.

FunctionsΒ§

clamp_to_min_height πŸ”’
Clamp the y-component of a resize delta so the block cannot shrink below min_height. Which edge moves (and therefore the sign of the constraint) depends on the resize mode.
clamp_to_min_width πŸ”’
Clamp the x-component of a resize delta so the block cannot shrink below min_width. Which edge moves (and therefore the sign of the constraint) depends on the resize mode.
clamp_to_widest πŸ”’
Clamp the x-component of a resize delta so the shape cannot grow wider than widest, never forcing a shape already wider to shrink.
icon_preview πŸ”’
The icon a resized block carries, and the offset to preview it at: exactly where the drop puts it (see icon_rect_after_resize), so the icon tracks the block through the drag instead of jumping into place on release.
intrinsic_aspect πŸ”’
The intrinsic aspect ratio (w/h) of an image or icon shape, or None for other shapes or an image the painter can’t resolve. Drives the aspect-lock resize snap.
min_block_height πŸ”’
Minimum height a resize may shrink shape to. For a child block this is a valid block height: at least PIN_PITCH (a single pin slot), and tall enough to hold its pins. The pins can slide up into the top margin as the block shrinks (the resize emitter rides them up, see crate::edit::geometry::resize), so the pin floor is set by their span β€” the slots between the highest and lowest pin β€” giving PIN_PITCH * (span + 1). Non-blocks keep the bare pin floor (0.0 when they have none).
min_block_width πŸ”’
Minimum width a resize may shrink shape to: MIN_BLOCK_WIDTH for a child block or a text box, 0.0 for any other shape (which may be freely narrow).
min_resize_size πŸ”’
The size floor a resize of shape must respect: its own minimum (see min_block_width and min_block_height) grown to hold its icon, since a block never shrinks smaller than the artwork it carries. The icon’s extent is raised to the lattice the drop snaps to, or the snap would round back through it.
resize_bounds πŸ”’
What a resize of shape stays between: min_resize_size, and for a text box the widest box its column cap allows.
resize_mode_at πŸ”’
The corner handle pos grabs on shape’s selection rect, if any. Handles only exist on resizable shapes.
resize_snap πŸ”’
Only blocks hold their height to the 4-cell pitch; ports, areas, images and text boxes just snap to the grid.