Module plan
Expand description
The arithmetic of a stack of collapsible sections: how heights share a panel, and what a drag on a boundary between two sections does. Heights are in points, a section’s body alone (its title band is the caller’s); folded sections take no height and are skipped.
fit: the heights a stack shows in the room it has. A height set by hand is kept while it fits; the sections never set by hand share the rest equally, and the last open section takes what is left, less any empty room kept under it.plan_drag: what moving a boundary does, from the heights shown. Nothing gives way in proportion: sections give in turn, the nearest first, each down to its least height, as a code editor’s split view does.DragMode::Pullmoves the sections below as a block instead, opening empty room under the last.resized_above: the section a boundary resizes: under a folded section, the first open one above it.pin_plan: the heights to keep by hand so thatfitshows a plan, the sections it did not touch staying sized by the list.keep_title: what folding or opening a section keeps so that its title stays where it is (held_above: the sections that must not move).rows_least: the least height of a section of rows.
use egui_stack::sections::plan::{DragMode, Placed, plan_drag};
let section = |height| Placed { open: true, least: 50.0, height };
let stack = [section(100.0), section(100.0), section(100.0)];
// Down, the section just below gives first, down to its least height;
// the last gives only then.
let plan = plan_drag(&stack, 0, 70.0, 0.0, DragMode::Push);
assert_eq!(plan.heights, [170.0, 50.0, 80.0]);
assert_eq!(plan.moved, 70.0);Structs§
- Asked
- A section as a stack asks for it: what
fitlays out. - Drag
Plan - What a drag does (
plan_drag). - Fit
- The heights a stack shows (
fit). - Kept
- What to keep so that folding or opening a section leaves its title where
it is (
keep_title). - Placed
- A section as laid out: what a drag starts from.
Enums§
- Drag
Mode - How a drag moves the sections around a boundary.
Functions§
- fit
- Lays sections out in
roompoints, keepingemptypoints of it under the last section. - fit_
content fit_withinfor a stack sized by its content (Sections::filloff): the last open section keeps a height set by hand too, as every other one, past its content as well, so that a drag moves its band down into the room under it. The room the heights leave goes under the last band, in the returned room left as inFit::empty.- fit_
within fitwith bounds: a section sized by the list, the last open one included, is never laid out taller thanmost(its greatest height or its content’s; missing or infinite, no bound) nor shorter than its least. The others share what is left in turn, and the room none takes goes under the last band. Heights set by hand are kept as byfit: the last open section ignores its own.- held_
above - The open sections above
section, with their shown heights: what must not move for its title to stay where it is. - keep_
title - What folding or opening the section
sectionkeeps, from theheightsshown and theemptyroom under them, so that its title does not move. - pin_
plan - The heights to keep by hand, section by section, so that
fitshowsplaninroom, withemptykept under the last section. - pin_
plan_ content pin_planfor a stack sized by its content, laid out byfit_contentwith the samemost: the last open section is pinned too when the plan moves it.- pin_
plan_ within pin_planfor a stack laid out byfit_withinwith the samemost.- plan_
drag - What moving the boundary under the section
abovebydeltadoes (down if positive), from the heights inplaced;emptyis the room under the last section. - resized_
above - The section a boundary resizes, the one on the line under the section
line:lineitself when open, else the first open one above it, past any folded ones (they have no height to change);Nonewhen nothing above is open, and the boundary cannot move.open: whether each section is, top first. - rows_
least - The least height of a section of
countrows, eachrowtall: two rows, or all of them when it has fewer.