pub struct SelectionState { /* private fields */ }Expand description
Cursor and scroll offset for a list of len items.
len is supplied per call rather than stored, so one state can outlive the
collection it indexes: filters, reloads, and live updates all change len
without invalidating the selection.
Scrolling the selection into view belongs to whoever draws the rows, because
only it knows how many fit; ListView writes
the window it settled on back through SelectionState::set_offset.
Implementations§
Source§impl SelectionState
impl SelectionState
pub fn new(len: usize) -> Self
pub fn selected(&self) -> Option<usize>
pub fn offset(&self) -> usize
Sourcepub fn set_offset(&mut self, offset: usize)
pub fn set_offset(&mut self, offset: usize)
Records the window the rows were actually drawn from, so the next frame scrolls against it and a click hit-tests against the same rows.
pub fn select(&mut self, selected: Option<usize>, len: usize)
pub fn select_first(&mut self, len: usize)
pub fn select_row(&mut self, visible_row: usize, len: usize)
Sourcepub fn set_rows_area(&mut self, area: Rect)
pub fn set_rows_area(&mut self, area: Rect)
Records where the rows were drawn, so clicks can be mapped back to an index without every caller re-deriving the headers and borders above them. Called from rendering.
Sourcepub fn rows_area(&self) -> Rect
pub fn rows_area(&self) -> Rect
Where the rows were last drawn, for hit-testing a click against a pane.
Sourcepub fn select_at(&mut self, row: u16, len: usize) -> bool
pub fn select_at(&mut self, row: u16, len: usize) -> bool
Selects the row drawn at terminal row, reporting whether one was hit.
Rows outside the last drawn area leave the selection alone.
Sourcepub fn step(
&mut self,
len: usize,
direction: Direction,
selectable: impl Fn(usize) -> bool,
)
pub fn step( &mut self, len: usize, direction: Direction, selectable: impl Fn(usize) -> bool, )
Wrapping move to the nearest index in direction for which selectable
holds. Leaves the selection untouched when no index qualifies, so panes
whose rows are a mix of headers and entries never land on a header.
Sourcepub fn step_clamped(
&mut self,
len: usize,
direction: Direction,
selectable: impl Fn(usize) -> bool,
)
pub fn step_clamped( &mut self, len: usize, direction: Direction, selectable: impl Fn(usize) -> bool, )
Like Self::step, but stops at the ends instead of wrapping. Suits
long lists that are scanned rather than cycled.
pub fn clamp(&mut self, len: usize)
Trait Implementations§
Source§impl Clone for SelectionState
impl Clone for SelectionState
Source§fn clone(&self) -> SelectionState
fn clone(&self) -> SelectionState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SelectionState
impl Debug for SelectionState
Source§impl Default for SelectionState
impl Default for SelectionState
Source§fn default() -> SelectionState
fn default() -> SelectionState
impl Eq for SelectionState
Source§impl PartialEq for SelectionState
impl PartialEq for SelectionState
impl StructuralPartialEq for SelectionState
Auto Trait Implementations§
impl Freeze for SelectionState
impl RefUnwindSafe for SelectionState
impl Send for SelectionState
impl Sync for SelectionState
impl Unpin for SelectionState
impl UnsafeUnpin for SelectionState
impl UnwindSafe for SelectionState
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> ⓘ
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> ⓘ
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