Skip to main content

Module item

Module item 

Source
Expand description

Dense list items: one row look for lists, trees and panels.

Experimental: may change in any release (docs/stability.md).

A ListItem is a row of the theme’s row height (size.row.height, apart from the controls’ size.control.height): an optional drag handle, indent guides down its levels, a collapsing arrow, an icon, its label, weak text on its right (ListItem::trailing) and action buttons (ItemAction: a visibility eye, remove) shown while the row is hovered, focused or selected, or always. The tree and the list draw their rows with the same pieces, so a row looks the same everywhere. A PropertyRow is the same row with a name column and a value.

Everything is painted through the kit: the row’s box is the list-item component (based on list-row, so a kit restyling rows restyles items), its guides list-guide, its action buttons icon-button, its arrow the kit’s disclosure glyphs.

use egui_pop_core::icon::Icon;
use egui_pop_views::item::{ItemAction, ListItem};

fn layer(ui: &mut egui::Ui, shown: &mut bool, selected: bool) -> bool {
    let eye = if *shown { Icon::Visible } else { Icon::Hidden };
    let out = ListItem::new("Ground")
        .icon(Icon::File)
        .trailing("12 points")
        .selected(selected)
        .action(ItemAction::new("visibility", eye, "Hide Ground").pinned(!*shown))
        .show(ui);
    if out.action() == Some("visibility") {
        *shown = !*shown;
    }
    out.response.clicked()
}

§Keyboard

A standalone item takes the focus (Tab); Enter or Space clicks it, Right and Left open and close a collapsing one. Its action buttons follow it in the Tab order: they show while the item or one of them has the focus, so Tab walks from the item through its buttons to the next widget, and Shift+Tab walks back. In the tree, the cursor’s row shows its actions while the tree has the focus, and they come right after the tree in the Tab order: Tab from the tree reaches the cursor’s buttons, Shift+Tab goes back to the tree. Screen readers also find each action on the row itself, as a custom action named by its label.

A label that does not fit draws on one line, elided with “…” before the row’s trailing text and buttons, which stay whole; hovering the row then shows the full label. The row’s accessible name is always the full label.

Structs§

ItemAction
An action button at a row’s right end: an icon, and its label (its accessible name and tooltip, and the row’s custom action for screen readers).
ItemResponse
What ListItem::show returns.
ListItem
A dense row: see the module.

Enums§

Disclosure
The column on a row’s left that holds its collapsing arrow.
Reveal
When a row’s action buttons show.

Functions§

row_height
A row’s height: the theme’s size.row.height, kept apart from the controls’ height, and never under the body text.