pub struct List<'a, C: PixelColor, M: Clone> { /* private fields */ }Expand description
Styled, scrollable vertical list of selectable rows.
Build it with List::new, add rows via List::item,
List::item_with, or List::push, then enable scrolling with the
same builders a Column exposes. A tapped row emits the
List::on_select message carrying its zero-based index.
Implementations§
Source§impl<'a, C: PixelColor + 'a, M: Clone + 'a> List<'a, C, M>
impl<'a, C: PixelColor + 'a, M: Clone + 'a> List<'a, C, M>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new empty list. Position and size are assigned by the parent
via arrange. Defaults to filling its container with 0 px spacing
between rows.
Sourcepub fn id(self, id: WidgetId) -> Self
pub fn id(self, id: WidgetId) -> Self
Set a stable base id so rows can participate in focus traversal.
Sourcepub fn spacing(self, spacing: u32) -> Self
pub fn spacing(self, spacing: u32) -> Self
Gap (px) between rows. Defaults to 0 (rows abut, suited to dividers).
Sourcepub fn selected(self, index: usize) -> Self
pub fn selected(self, index: usize) -> Self
Index of the row to render with the selected highlight.
Host-driven — typically the value the last List::on_select set.
Sourcepub fn on_select<F>(self, f: F) -> Self
pub fn on_select<F>(self, f: F) -> Self
Callback invoked with a tapped row’s index. Without it the rows are inert (they still draw, but emit no message).
Sourcepub fn item_with(
self,
leading: Option<impl Into<String>>,
label: impl Into<String>,
trailing: Option<impl Into<String>>,
) -> Self
pub fn item_with( self, leading: Option<impl Into<String>>, label: impl Into<String>, trailing: Option<impl Into<String>>, ) -> Self
Append a row with an optional leading slot (e.g. an icon
glyph), a main label, and an optional trailing slot (e.g. an
accessory glyph or value text). Pass ""/None for slots you don’t
need.
Sourcepub fn push(self, row: ListRow<'a, C, M>) -> Self
pub fn push(self, row: ListRow<'a, C, M>) -> Self
Append a pre-built ListRow. The row’s index is reassigned
to its position in the list, and the list-wide divider/select settings
are applied at layout time.
Sourcepub fn scrollable(self, dir: ScrollDirection) -> Self
pub fn scrollable(self, dir: ScrollDirection) -> Self
Make this list scrollable on dir. Mirrors
Column::scrollable. Lists are vertical, so
ScrollDirection::Vertical is the usual choice.
Sourcepub fn scroll_state(self, state: &ScrollState) -> Self
pub fn scroll_state(self, state: &ScrollState) -> Self
Supply the host-owned ScrollState read this frame.
Implies scrolling (vertical by default). Mirrors
Column::scroll_state.
Sourcepub fn scrollbar(self, mode: ScrollbarMode) -> Self
pub fn scrollbar(self, mode: ScrollbarMode) -> Self
When the scrollbar is drawn. Mirrors Column::scrollbar.
Sourcepub fn snap(self, mode: SnapMode) -> Self
pub fn snap(self, mode: SnapMode) -> Self
Snapping mode. Mirrors Column::snap.
Trait Implementations§
Source§impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for List<'a, C, M>
impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for List<'a, C, M>
Source§fn measure(&mut self, constraints: Constraints) -> Size
fn measure(&mut self, constraints: Constraints) -> Size
constraints.Source§fn preferred_size(&self) -> (Length, Length)
fn preferred_size(&self) -> (Length, Length)
.width(...) / .height(...).
Containers consult this during layout to allocate fixed slots,
query intrinsic sizes, and split residual space among
Fill / FillPortion children. Default is Length::Fill on
both axes.Source§fn arrange(&mut self, rect: Rectangle)
fn arrange(&mut self, rect: Rectangle)
Source§fn handle_touch(&mut self, point: Point, phase: TouchPhase) -> Option<M>
fn handle_touch(&mut self, point: Point, phase: TouchPhase) -> Option<M>
Source§fn mark_pressed(&mut self, point: Point)
fn mark_pressed(&mut self, point: Point)
point hits. No message emit.
Containers forward to children. Default no-op.Source§fn draw<'t>(
&self,
renderer: &mut dyn Renderer<C>,
theme: &Theme<'t, C>,
) -> Result<(), RenderError>
fn draw<'t>( &self, renderer: &mut dyn Renderer<C>, theme: &Theme<'t, C>, ) -> Result<(), RenderError>
renderer at rect.Source§fn widget_id(&self) -> Option<WidgetId>
fn widget_id(&self) -> Option<WidgetId>
Source§fn is_focusable(&self) -> bool
fn is_focusable(&self) -> bool
Source§fn collect_focusable(&self, out: &mut Vec<WidgetId>)
fn collect_focusable(&self, out: &mut Vec<WidgetId>)
Source§fn sync_focus(&mut self, focused: Option<WidgetId>)
fn sync_focus(&mut self, focused: Option<WidgetId>)
Source§fn handle_action(&mut self, action: UiAction) -> Option<M>
fn handle_action(&mut self, action: UiAction) -> Option<M>
Source§fn route_action(&mut self, target: WidgetId, action: UiAction) -> Option<M>
fn route_action(&mut self, target: WidgetId, action: UiAction) -> Option<M>
target.target for directional actions.Auto Trait Implementations§
impl<'a, C, M> Freeze for List<'a, C, M>
impl<'a, C, M> !RefUnwindSafe for List<'a, C, M>
impl<'a, C, M> !Send for List<'a, C, M>
impl<'a, C, M> !Sync for List<'a, C, M>
impl<'a, C, M> Unpin for List<'a, C, M>where
C: Unpin,
impl<'a, C, M> UnsafeUnpin for List<'a, C, M>
impl<'a, C, M> !UnwindSafe for List<'a, C, M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<'a, C, M, W> IntoElement<'a, C, M> for W
impl<'a, C, M, W> IntoElement<'a, C, M> for W
Source§fn into_element(self) -> Element<'a, C, M>
fn into_element(self) -> Element<'a, C, M>
self.