Documentation
¶
Overview ¶
Package layout provides a pure-geometry layout engine for the Arena TUI. It computes rectangles for a tree of panes and contains no rendering code.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderTree ¶
RenderTree composes the rendered content of each leaf into the layout's shape. content maps a leaf ID to its already-rendered string. Vertical splits stack with JoinVertical(Left); horizontal splits sit side by side with JoinHorizontal(Top). Invisible nodes are skipped. Unlike the geometry files, this rendering layer may depend on lipgloss.
Types ¶
type Direction ¶
type Direction int
Direction is the axis along which a split arranges its children.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns a layout tree and its current area, and is the single place that mutates the layout at runtime (resize, collapse). Each mutation reflows once, so consumers read the resulting rects via Rect. Construct page trees with the builders and hand the root to NewManager.
func NewManager ¶
NewManager returns a Manager for the given layout tree.
func (*Manager) Grow ¶
Grow adjusts the flex weight of the leaf with the given ID by delta (weight is clamped to a minimum of 1) and reflows. Growing a fixed-size leaf has no effect. Unknown IDs are ignored.
func (*Manager) Rect ¶
Rect returns the computed rectangle for the leaf with the given ID. The second result is false when the leaf is collapsed (absent from the layout).
func (*Manager) ToggleCollapse ¶
ToggleCollapse flips the visibility of the leaf with the given ID and reflows. Unknown IDs are ignored.
type Node ¶
type Node struct {
ID string
Dir Direction
Children []*Node
Mode SizeMode
Size int
Weight int
MinW int
MinH int
Visible bool
}
Node is one element of a layout tree. A node is either a leaf (ID set, no Children) or a split (Children set). Construct nodes with the builders rather than literals so defaults (Visible, Weight) are set correctly.