Skip to main content

List

Struct List 

Source
pub struct List<T> { /* private fields */ }
Expand description

A list widget for displaying items

Implementations§

Source§

impl<T> List<T>

Source

pub fn new(items: Vec<T>) -> Self

Create a new list with items

Source

pub fn selected(self, idx: usize) -> Self

Set selected index

Source

pub fn highlight_fg(self, color: Color) -> Self

Set highlight foreground color

Source

pub fn highlight_bg(self, color: Color) -> Self

Set highlight background color

Source

pub fn items(&self) -> &[T]

Get items

Source

pub fn selected_index(&self) -> usize

Get selected index

Source

pub fn len(&self) -> usize

Get number of items

Source

pub fn is_empty(&self) -> bool

Check if empty

Source

pub fn select_next(&mut self)

Select next item (wraps around)

Source

pub fn select_prev(&mut self)

Select previous item (wraps around)

Trait Implementations§

Source§

impl<T: Display> StyledView for List<T>

Source§

fn set_id(&mut self, id: impl Into<String>)

Set element ID
Source§

fn add_class(&mut self, class: impl Into<String>)

Add a CSS class
Source§

fn remove_class(&mut self, class: &str)

Remove a CSS class
Source§

fn toggle_class(&mut self, class: &str)

Toggle a CSS class
Source§

fn has_class(&self, class: &str) -> bool

Check if has class
Source§

impl<T: Display> View for List<T>

Source§

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

Get element ID (for CSS #id selectors)
Source§

fn classes(&self) -> &[String]

Get CSS classes (for CSS .class selectors)
Source§

fn meta(&self) -> WidgetMeta

Get widget metadata for DOM
Source§

fn render(&self, ctx: &mut RenderContext<'_>)

Render the view
Source§

fn widget_type(&self) -> &'static str

Get widget type name (for CSS type selectors)
Source§

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

Get child views (for container widgets) Read more

Auto Trait Implementations§

§

impl<T> !Freeze for List<T>

§

impl<T> !RefUnwindSafe for List<T>

§

impl<T> Send for List<T>
where T: Send,

§

impl<T> !Sync for List<T>

§

impl<T> Unpin for List<T>
where T: Unpin,

§

impl<T> UnwindSafe for List<T>
where T: UnwindSafe,

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.