Skip to main content

Module plan

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::Pull moves 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 that fit shows 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 fit lays out.
DragPlan
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§

DragMode
How a drag moves the sections around a boundary.

Functions§

fit
Lays sections out in room points, keeping empty points of it under the last section.
fit_content
fit_within for a stack sized by its content (Sections::fill off): 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 in Fit::empty.
fit_within
fit with bounds: a section sized by the list, the last open one included, is never laid out taller than most (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 by fit: 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 section keeps, from the heights shown and the empty room under them, so that its title does not move.
pin_plan
The heights to keep by hand, section by section, so that fit shows plan in room, with empty kept under the last section.
pin_plan_content
pin_plan for a stack sized by its content, laid out by fit_content with the same most: the last open section is pinned too when the plan moves it.
pin_plan_within
pin_plan for a stack laid out by fit_within with the same most.
plan_drag
What moving the boundary under the section above by delta does (down if positive), from the heights in placed; empty is the room under the last section.
resized_above
The section a boundary resizes, the one on the line under the section line: line itself when open, else the first open one above it, past any folded ones (they have no height to change); None when 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 count rows, each row tall: two rows, or all of them when it has fewer.