Expand description
Folds inside a panel: a group whose header row folds and opens its
body (Fold), and a row of a hand-built tree with its disclosure
toggle (TreeRow), for the folds that are neither a whole side bar
of stacked sections (crate::sections::Sections) nor a data view’s
tree.
Experimental: may change in any release
(docs/stability.md).
- A fold’s header is a section band in the kit’s look (its disclosure mark, its title, an optional count), with optional actions at its right end. A click on the band, or Space or Enter while it has the keyboard, folds or opens it; Left folds it and Right opens it.
- A tree row is the row the caller draws, after its toggle: a branch’s
toggle folds and opens the rows below it (a click, Space or Enter,
Left and Right while it has the keyboard); a leaf’s row takes the
same room, so that branches and leaves line up. Rows below a branch
are indented by one level. A flat tree’s row says its own depth
(
TreeRow::depth): indented by that many levels, and read aloud at its level. - What is open is kept by id in egui’s persisted memory, with the
window’s layout, as egui’s own collapsing regions keep it: a fold
has the id an egui
CollapsingHeadergiven the sameid_salthas, and a tree row the id it is given, so either replaces egui’s without losing what the user opened.is_openreads it andset_openchanges it. - Named and observable. A fold’s header is a button named by its
title and count (“Folders, 3”), a tree row’s toggle a disclosure
triangle named after its row (“Show or hide Photos”, the strings
provider’s
egui-pop-fold-toggle); both say whether they are expanded and answer assistive technology’s expand and collapse actions.
use egui_pop_core::fold::{Fold, TreeRow};
let ctx = egui::Context::default();
let mut out = ctx.run_ui(Default::default(), |ui| {
Fold::new("folders", "Folders").count(2).default_open(true).show(ui, |ui| {
let id = ui.make_persistent_id("photos");
TreeRow::new(id, "Photos")
.show(ui, |ui| ui.label("Photos"))
.body(ui, |ui| {
TreeRow::new(ui.make_persistent_id("2024"), "2024")
.leaf(true)
.show(ui, |ui| ui.label("2024"));
});
});
});
out.textures_delta.clear();Structs§
- Fold
- A group inside a panel whose header row folds and opens its body: a section band (disclosure mark, title, count) with optional actions at its right end, its body indented below it when open. Its open state is kept by id (see the module).
- Fold
Response - What a fold did this pass.
- Guide
Row - One row of a tree, as
IndentGuides::paintneeds it: its depth (0 at the top) and its rectangle, whose left edge is where the tree’s first level starts (aTreeRow’s whole row). - TreeRow
- A row of a hand-built tree: a branch’s toggle, or a leaf’s room for
one, then the row the caller draws;
TreeRowResponse::bodyshows the rows below a branch, indented, when it is open. Its open state is kept under the id it is given (see the module). - Tree
RowResponse - A shown tree row: its toggle, its row, and the rows below it.
Enums§
- Indent
Guides - When a hand-built tree draws its indent guides: a thin line down each
nesting level, as VS Code’s explorer does (
renderIndentGuides). Never by default, so that a tree looks as it always did.