Expand description
Canonical row layout for ListView / TreeView delegates.
Two widgets:
StandardListItem— primary line[checkbox?] [leading_slot?] [center_slot?] [label] [Spacer] [trailing_slot?]with optional subtitle line[subtitle_leading_slot?] [subtitle] [Spacer] [subtitle_trailing_slot?].StandardTreeItem— same plus depth-driven indent + chevron column (always reserved, even for leaves, so labels at the same depth align).
Selection / hover / pressed background mirrors MenuItem /
ComboBox: rounded RectWidget (item_corner_radius: 8.0),
horizontally inset so corners are visible, theme-driven via
SurfaceRole so light/dark/custom themes propagate without
rebuild.
§Canonical TreeView wiring
use teksilo::data::{TreeCheckedModel, TreeModel};
use teksilo::widgets::{StandardTreeItem, TreeView};
let tree: TreeModel<Item> = ...;
let checks = TreeCheckedModel::new(tree.clone());
TreeView::new_with_context(tree, move |item, entry, selected, ctx| {
let mut row = StandardTreeItem::new(lit!(item.title.clone()))
.from_entry(entry)
.selected(selected)
.leading_slot(IconWidget::from_svg(FOLDER_ICON).icon_size(16.0))
.on_toggle_rc(ctx.toggle_callback());
if entry.has_children {
row = row.tristate_checkbox(checks.signal_for(entry.node_id));
} else {
row = row.checkbox(checks.bool_signal_for(entry.node_id));
}
Box::new(row)
})
.row_click_expands(false) // chevron is the only toggle targetWiring rules:
TreeView::new_with_contextexposes aTreeRowContextthat yieldstoggle_callback()for chevron clicks. Pair with.row_click_expands(false)so body clicks don’t also toggle.- For tristate parent rows, bind to
signal_for(node). For leaves, preferbool_signal_for(node)— the model’s bool ↔ tristate bridge runs ancestor recompute on writes either way. from_entry(&FlatEntry)is shorthand for.depth(entry.depth).has_children(entry.has_children) .is_expanded(entry.is_expanded).
§Accessibility
StandardListItem.accessibility() sets the row’s name (label
only) and description (subtitle, if any) — structural role +
position/level/expanded/selected come from the parent’s
ListItemA11y / TreeRowA11y wrapper. The embedded Checkbox
receives an access_label* override carrying the row label so
screen readers announce “checkbox, checked, [label]” rather than
a nameless Role::CheckBox. The chevron’s TwistArrow is
decorative (set_hidden); the row’s expanded state is owned by
the wrapper.
Structs§
- Standard
List Item - Canonical single-line or two-line row layout for use in a
ListView. - Standard
Tree Item - Canonical row layout for a
TreeView—StandardListItemplus a depth-driven indent column and an always-reserved chevron column.