pub struct ScrollFieldState { /* private fields */ }Expand description
Caller-owned position and focus for one Material scroll field.
Implementations§
Source§impl ScrollFieldState
impl ScrollFieldState
Sourcepub fn new(
item_count: usize,
index: usize,
cx: &mut Context<'_, ScrollFieldState>,
) -> ScrollFieldState
pub fn new( item_count: usize, index: usize, cx: &mut Context<'_, ScrollFieldState>, ) -> ScrollFieldState
Creates a position at the requested option, clamped to the available indices.
Sourcepub fn item_count(&self) -> usize
pub fn item_count(&self) -> usize
Returns the total number of selectable options in this scroll field.
Sourcepub fn set_item_count(
&mut self,
count: usize,
cx: &mut Context<'_, ScrollFieldState>,
)
pub fn set_item_count( &mut self, count: usize, cx: &mut Context<'_, ScrollFieldState>, )
Updates the options and centers the clamped destination immediately.
Sourcepub fn selected_option(&self) -> Option<usize>
pub fn selected_option(&self) -> Option<usize>
Reads the nearest option or None when the field is empty.
Sourcepub fn target_option(&self) -> Option<usize>
pub fn target_option(&self) -> Option<usize>
Reads the destination, including while the wheel is settling.
Sourcepub fn is_scroll_in_progress(&self) -> bool
pub fn is_scroll_in_progress(&self) -> bool
Returns whether a scroll gesture or settling animation is currently active.
Sourcepub fn focus_handle(&self) -> &FocusHandle
pub fn focus_handle(&self) -> &FocusHandle
Returns the retained focus handle for this scroll field.
Sourcepub fn scroll_to_option(
&mut self,
index: usize,
cx: &mut Context<'_, ScrollFieldState>,
)
pub fn scroll_to_option( &mut self, index: usize, cx: &mut Context<'_, ScrollFieldState>, )
Centers the clamped option without animation.
Sourcepub fn animate_scroll_to_option(
&mut self,
index: usize,
cx: &mut Context<'_, ScrollFieldState>,
)
pub fn animate_scroll_to_option( &mut self, index: usize, cx: &mut Context<'_, ScrollFieldState>, )
Scrolls to the clamped option using the window’s motion policy.
Auto Trait Implementations§
impl !RefUnwindSafe for ScrollFieldState
impl !Send for ScrollFieldState
impl !Sync for ScrollFieldState
impl !UnwindSafe for ScrollFieldState
impl Forget for ScrollFieldState
impl Freeze for ScrollFieldState
impl Move for ScrollFieldState
impl Unpin for ScrollFieldState
impl UnsafeUnpin for ScrollFieldState
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
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