Expand description
Pure-math window layout engine for term-wm.
Provides tiling (BSP/N-ary tree) and floating window layout math with
zero runtime dependencies. Supports no_std via the std feature
(enabled by default).
Structs§
- Drag
Handle - A hit-test region for the title bar of a floating window.
- Edge
Resistance - Focus
Ring - A cyclic focus ring with a single current item.
- Header
Drag - State of an in-progress header drag (move).
- Layout
Rect - A rectangle with signed origin and unsigned dimensions.
- Longest
Side - Splits along the longer side of the area (width ≥ height → Horizontal).
- Mouse
Position - A mouse cursor position with an explicit coordinate space tag.
- Ratio
- An integer ratio
(p, q)meaningp/(p+q)of the parent’s size. - Region
Map - A map from ID to rectangle, with hit-testing support.
- Resize
Drag - State of an in-progress resize drag.
- Resize
Handle - A single-cell hit-test handle at a corner or along an edge of a floating window.
- Scroll
State - Scroll state for a scrollable viewport.
- Size
Constraints - Minimum dimensions enforced by tree mutation functions.
- Snap
Preview - Spiral
- Cycles
Horizontal, Vertical, Horizontal, Vertical, …based on depth. - Split
Gap - ZOrder
- A flat z-order list. The last element is the top-most (front-most) item.
Enums§
- BspNode
- A strict binary (BSP) split tree.
- Coord
Space - Distinguishes coordinate spaces to prevent accidental mixing.
- Direction
- Insert
Position - Layout
Error - Errors returned by tree mutation operations.
- Layout
Node - Nary
Node - Orientation
- The direction children are stacked in a split container.
- Quadrant
- Which diagonal quadrant of a rectangle a point falls in.
- Rect
Spec - A rectangle specification that can be either absolute or percentage-based.
- Resize
Edge - Identifies which edge(s) of a floating window are being dragged.
- Snap
Target
Constants§
- FLOATING_
MIN_ HEIGHT - Minimum height for a floating window (in cells).
- FLOATING_
MIN_ WIDTH - Minimum width for a floating window (in cells).
Traits§
- Layout
Engine - Common interface for tree-based layout engines (BSP and N-ary).
- Orientation
Heuristic - Decides which orientation to use when splitting an area.
Functions§
- apply_
resize_ drag_ signed - Apply a resize drag delta to a floating window’s geometry.
- build_
rects_ from_ sizes - Build rects from a list of per-child sizes along an orientation.
- corner_
preview_ rect - Compute a corner (quarter-screen) preview rect.
- detect_
corner_ snap - Detect a corner snap when the cursor is simultaneously within
sensitivityof both an X edge and a Y edge. Uses saturating arithmetic exclusively. - detect_
edge_ snap - detect_
quadrant - Determine which diagonal quadrant of
targetthe cursor falls in. - edge_
preview_ rect - find_
closest_ region - Find the region whose center is nearest to
(cx, cy)using aspect-ratio-weighted Euclidean distance. ReturnsNonefor empty input. - floating_
header_ for_ region - Generate a drag handle for the title bar of a floating window.
- gap_
insert - Offset a rectangle by
gap * indexalong the given orientation. Used when placing children in a split with inter-child gaps. Generic over gap type. - gap_
size - Compute the per-gap size between children in a split.
- handle_
thickness - Compute the visual thickness of a split handle gap.
- hit_
test_ leaf - Find the top-most (last-in-slice) region that contains
(col, row). - inset
- Shrink a rectangle by the given margins on each side. The resulting width/height saturate at zero. Generic over margin types.
- rect_
contains - Convenience wrapper around
LayoutRect::contains. Generic over coordinate type. - resize_
handles_ for_ region - Generate all 8 resize handles (4 corners + 4 edges) for a floating region.
- resolve_
target - Two-phase target resolution for spatial insertion:
- split_
area_ for_ path - split_
at_ path_ mut - split_
rect_ bsp - Split a rectangle into two along the given orientation using a ratio.
- split_
rects_ nary - split_
rects_ weighted - Weighted split of a rect into
child_countrects using integer weights. - split_
rects_ with_ gaps - Split a rect into
child_countrects separated bygap-width gaps. - split_
sizes - Extract the per-child dimension sizes from a split result.
- tiled_
preview_ rect