Skip to main content

Module tree

Module tree 

Source
Expand description

A tree of splits, and the frame that draws one.

SplitPane is two panes and a divider. SplitTree is however many of those the caller nests, arranged as a SplitLayout the caller owns. The tree is data, not view state: the library draws whatever tree it is handed and reports every change the typist asked for as a SplitChange, so a host that refuses a resize keeps the arrangement that still holds.

§Persisting a layout

This crate takes no serialization dependency, so SplitLayout carries no derived Serialize. Instead it converts losslessly to and from a flat Vec<SplitRecord> of plain fields, which a host serializes with whatever format it already uses:

let layout = SplitLayout::horizontal(
    "workspace",
    0.3,
    SplitLayout::leaf(SplitPaneSpec::new("files").min(180.0)),
    SplitLayout::pane("editor"),
);
let records = layout.to_records();
// ... the host writes `records` out field by field, and reads them back ...
assert_eq!(SplitLayout::from_records(&records).unwrap(), layout);

§Minimums propagate

A leaf states the smallest it may be drawn at. A branch’s minimum along its own axis is the sum of its children’s, plus the divider between them, and across the other axis it is the larger of the two. A divider high in the tree therefore stops where a leaf far below it would run out of room, rather than reporting a ratio that starves it.

Structs§

SplitPaneSpec
One leaf of a SplitLayout: a named place the caller puts content.
SplitRecord
One node of a SplitLayout, as plain fields a host can write anywhere.
SplitTree
Draws a SplitLayout and reports what the typist asked to change.

Enums§

SplitChange
A change the typist asked the layout for. Nothing has been applied.
SplitKind
What one SplitRecord describes.
SplitLayout
A tree of splits the caller owns.
SplitRecordError
Why a set of records is not a tree.