pub struct DropdownState<T: DropdownItem> {
pub filtered: Vec<T>,
pub selected: usize,
pub scroll_offset: usize,
pub title: String,
/* private fields */
}Expand description
Generic dropdown state. Owns the filtered item list, selection,
and scroll offset. Type parameter T must implement DropdownItem.
Fields§
§filtered: Vec<T>Currently visible items after filtering.
selected: usizeIndex into filtered.
scroll_offset: usizeScroll offset for the visible window.
title: StringTitle shown above the dropdown.
Implementations§
Source§impl<T: DropdownItem> DropdownState<T>
impl<T: DropdownItem> DropdownState<T>
Sourcepub fn new(items: Vec<T>, title: impl Into<String>) -> Self
pub fn new(items: Vec<T>, title: impl Into<String>) -> Self
Create a new dropdown with the given items and title.
Sourcepub fn apply_filter(&mut self, filter: &str) -> bool
pub fn apply_filter(&mut self, filter: &str) -> bool
Apply a filter string. Resets selection to 0.
Returns false if no items match (caller can dismiss).
Sourcepub fn selected_item(&self) -> Option<&T>
pub fn selected_item(&self) -> Option<&T>
Get the currently selected item, if any.
Sourcepub fn visible_count(&self) -> usize
pub fn visible_count(&self) -> usize
Number of visible rows this dropdown will occupy (including title + padding).
Trait Implementations§
Source§impl<T: Clone + DropdownItem> Clone for DropdownState<T>
impl<T: Clone + DropdownItem> Clone for DropdownState<T>
Source§fn clone(&self) -> DropdownState<T>
fn clone(&self) -> DropdownState<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<T> Freeze for DropdownState<T>
impl<T> RefUnwindSafe for DropdownState<T>where
T: RefUnwindSafe,
impl<T> Send for DropdownState<T>where
T: Send,
impl<T> Sync for DropdownState<T>where
T: Sync,
impl<T> Unpin for DropdownState<T>where
T: Unpin,
impl<T> UnsafeUnpin for DropdownState<T>
impl<T> UnwindSafe for DropdownState<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more