List

Struct List 

Source
pub struct List {
    pub direction: ListDirection,
    pub selection_mode: SelectionMode,
    pub item_height: Option<f32>,
    pub gap: f32,
    pub scroll_offset: f32,
    /* private fields */
}
Expand description

Virtualized list widget.

Fields§

§direction: ListDirection

Scroll direction

§selection_mode: SelectionMode

Selection mode

§item_height: Option<f32>

Fixed item height (if None, items have variable height)

§gap: f32

Gap between items

§scroll_offset: f32

Current scroll offset

Implementations§

Source§

impl List

Source

pub fn new() -> Self

Create a new empty list.

Source

pub const fn direction(self, direction: ListDirection) -> Self

Set the scroll direction.

Source

pub const fn selection_mode(self, mode: SelectionMode) -> Self

Set the selection mode.

Source

pub const fn item_height(self, height: f32) -> Self

Set fixed item height.

Source

pub const fn gap(self, gap: f32) -> Self

Set gap between items.

Source

pub fn items(self, items: impl IntoIterator<Item = ListItem>) -> Self

Add items to the list.

Source

pub fn render_with<F>(self, f: F) -> Self
where F: Fn(usize, &ListItem) -> Box<dyn Widget> + Send + Sync + 'static,

Set the render callback for items.

Source

pub fn with_test_id(self, id: impl Into<String>) -> Self

Set the test ID.

Source

pub fn item_count(&self) -> usize

Get total item count.

Source

pub fn selected_indices(&self) -> &[usize]

Get selected indices.

Source

pub fn visible_range(&self) -> Range<usize>

Get visible range.

Source

pub const fn content_size(&self) -> f32

Get total content size.

Source

pub fn scroll_to(&mut self, index: usize)

Scroll to a specific item.

Source

pub fn scroll_into_view(&mut self, index: usize)

Scroll to ensure an item is visible.

Source

pub fn select(&mut self, index: usize)

Select an item.

Source

pub fn deselect(&mut self, index: usize)

Deselect an item.

Source

pub fn toggle_selection(&mut self, index: usize)

Toggle item selection.

Source

pub fn clear_selection(&mut self)

Clear all selections.

Trait Implementations§

Source§

impl Default for List

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for List

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for List

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Widget for List

Source§

fn type_id(&self) -> TypeId

Get the type identifier for this widget type.
Source§

fn measure(&self, constraints: Constraints) -> Size

Compute intrinsic size constraints. Read more
Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Position children within allocated bounds. Read more
Source§

fn paint(&self, canvas: &mut dyn Canvas)

Generate draw commands for rendering. Read more
Source§

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Handle input events. Read more
Source§

fn children(&self) -> &[Box<dyn Widget>]

Get child widgets for tree traversal.
Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Get mutable child widgets.
Source§

fn is_focusable(&self) -> bool

Check if this widget can receive keyboard focus.
Source§

fn test_id(&self) -> Option<&str>

Get the test ID for this widget (if any).
Source§

fn bounds(&self) -> Rect

Get the current bounds of this widget. Read more
Source§

fn is_interactive(&self) -> bool

Check if this widget is interactive (can receive focus/events).
Source§

fn accessible_name(&self) -> Option<&str>

Get the accessible name for screen readers.
Source§

fn accessible_role(&self) -> AccessibleRole

Get the accessible role.

Auto Trait Implementations§

§

impl Freeze for List

§

impl !RefUnwindSafe for List

§

impl Send for List

§

impl Sync for List

§

impl Unpin for List

§

impl !UnwindSafe for List

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,