pub struct List<'a> { /* private fields */ }Expand description
A scrollable, single-column list of plain-text items with a ListState-driven highlighted
item – Table’s single-column sibling, sharing its windowing and selection story.
One item renders per line, top-aligned in the area it’s rendered into and clipped to
area.width(). state.offset() is the index of the first item drawn – rendering draws
whatever window offset names and does not clamp or auto-scroll it, matching
Table’s and ListState’s existing “only the caller knows the viewport
height” design. Call state.ensure_visible(visible_item_count)
before rendering to keep state.selected() on-screen. If selected() is Some and its item
falls within the visible window, that item is drawn with an inverted highlight background; if
it has scrolled out of view, nothing is highlighted.
item_style and selected_style each default to the same fixed palette as
Table’s row_style/selected_style (a dim gray-blue for unselected items,
a bright-white-on-dark-blue highlight for the selected one); set them with
List::item_style/List::selected_style.
Implementations§
Source§impl<'a> List<'a>
impl<'a> List<'a>
Sourcepub const fn item_style(self, style: Style) -> Self
pub const fn item_style(self, style: Style) -> Self
Set the style of unselected items.
Sourcepub const fn selected_style(self, style: Style) -> Self
pub const fn selected_style(self, style: Style) -> Self
Set the style of the selected item, including its background fill.
Sourcepub fn theme(self, theme: Theme) -> Self
pub fn theme(self, theme: Theme) -> Self
Applies theme’s named roles to this list: item_style becomes theme.fg on
theme.panel_bg, and selected_style becomes theme.bg on theme.accent.
item_style sets an explicit background rather than leaving it at Style::new()’s
default: an unset background isn’t “transparent” once a real backend draws it (a bare
Color::Default cell paints as solid black behind the glyph – see
retroglyph-software’s DEFAULT_BG), so this widget assumes it’s drawn on
theme.panel_bg, true when composed with a themed super::Panel/super::Modal.
Drawing this list directly on the raw screen background instead needs a manual
.item_style(...) override afterwards.
Call before any manual List::item_style/List::selected_style override you want to
keep.