Skip to main content

TreeBuilder

Trait TreeBuilder 

Source
pub trait TreeBuilder<S: NodeSource + 'static>: Sized {
Show 14 methods // Required methods fn row_height(self, h: RowHeight) -> Self; fn indent(self, pts: f64) -> Self; fn section_headers(self) -> Self; fn on_expansion(self, f: impl Fn(S::Key, bool) + 'static) -> Self; fn expanded(self, set: impl Binding<HashSet<S::Key>>) -> Self; fn expandable(self, f: impl Fn(&S::Key) -> bool + 'static) -> Self; fn selected(self, f: impl Fn() -> Vec<S::Key> + 'static) -> Self; fn on_selection(self, f: impl Fn(Vec<S::Key>) + 'static) -> Self; fn multi_select(self) -> Self; fn movable(self, mv: Move<S::Key>) -> Self; fn type_ahead(self, f: impl Fn(&S::Key) -> String + 'static) -> Self; fn reveal(self, target: impl Binding<Option<S::Key>>) -> Self; fn row_id(self, f: impl Fn(&S::Key) -> ElementId + 'static) -> Self; fn row_context_menu( self, f: impl Fn(&S::Key) -> Vec<MenuEntry> + 'static, ) -> Self;
}
Expand description

Builder methods of TreePiece, reachable through a Decorated (docs/api-style.md “Typed builders and erasure”): generic modifiers and typed ones chain in any order.

Required Methods§

Source

fn row_height(self, h: RowHeight) -> Self

Row sizing: Uniform(h) (fastest) or Automatic (self-sizing).

Source

fn indent(self, pts: f64) -> Self

Indentation per depth level, in points (unset = the platform’s default step).

Source

fn section_headers(self) -> Self

Render a two-level source as sections. Root branches are headings and cannot be selected; root leaves remain ordinary rows. Children must be leaves. This enables native ExpandableListView on Android, where arbitrary-depth trees are composed.

Source

fn on_expansion(self, f: impl Fn(S::Key, bool) + 'static) -> Self

Reports an actual user/scripting disclosure change with the stable application key. Programmatic writes to expanded do not echo this callback.

Source

fn expanded(self, set: impl Binding<HashSet<S::Key>>) -> Self

The app-owned expansion set (docs/tree.md): the user’s disclosure clicks update it, and the app writing it discloses/collapses the native rows. Persist it (or don’t); it is plain state.

Source

fn expandable(self, f: impl Fn(&S::Key) -> bool + 'static) -> Self

Which rows can hold children at all: what draws (or omits) the disclosure, and which rows a drop may land on. Defaults to “has children right now”, which draws no disclosure on an empty group; a source with real branch/leaf kinds should say so.

Source

fn selected(self, f: impl Fn() -> Vec<S::Key> + 'static) -> Self

Reactively sync the native selection to these keys (empty clears). Point it and Self::on_selection at one signal and selection is two-way, shared with anything else reading the same state.

Source

fn on_selection(self, f: impl Fn(Vec<S::Key>) + 'static) -> Self

Called with the full selected key set (empty = cleared) whenever the user changes the selection.

Source

fn multi_select(self) -> Self

Allow selecting several rows at once, where the toolkit supports it.

Source

fn movable(self, mv: Move<S::Key>) -> Self

Let the user drag rows to a new parent/position with the platform’s native mechanism, where the backend supports it (probe Cap::TreeMove): the tree is movable exactly when it carries a Move, whose handler re-parents the app’s data.

ⓘ
tree(nodes, row_view).movable(Move::new(move |key, parent, index| store.reparent(key, parent, index)))
Source

fn type_ahead(self, f: impl Fn(&S::Key) -> String + 'static) -> Self

The row’s type-ahead string (docs/tree.md): what native type-select matches against. Unset rows don’t participate.

Source

fn reveal(self, target: impl Binding<Option<S::Key>>) -> Self

Programmatic reveal: set the signal to Some(key) and the row scrolls into view with every ancestor expanded (through Self::expanded, so the app sees the change).

Source

fn row_id(self, f: impl Fn(&S::Key) -> ElementId + 'static) -> Self

A dayscript element id per row, from its key (docs/tree.md): re-applied on every recycle, so tap/assert_text address the row wherever its cell currently sits. It is also what the expand:/tree_move: steps resolve rows by.

Source

fn row_context_menu( self, f: impl Fn(&S::Key) -> Vec<MenuEntry> + 'static, ) -> Self

A per-row context menu, built when the menu is summoned (docs/menus.md “Dynamic context menus”): right-click on desktop, long-press on touch. The closure receives the row’s key and returns the menu to show; it may adjust the app’s selection first (the convention: a summon outside the current selection selects that row). An empty result shows nothing for that row.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<S: NodeSource + 'static, DecoratedInner: TreeBuilder<S> + Piece> TreeBuilder<S> for Decorated<DecoratedInner>

Source§

impl<S: NodeSource + 'static> TreeBuilder<S> for TreePiece<S>

Day API ↩ Guides· daybrite.dev