pub struct VirtualizedListState {
pub selected: Option<usize>,
/* private fields */
}Expand description
State for the VirtualizedList widget.
Fields§
§selected: Option<usize>Currently selected index.
Implementations§
Source§impl VirtualizedListState
impl VirtualizedListState
Sourcepub fn variable(default_height: u16) -> Self
pub fn variable(default_height: u16) -> Self
Create variable-height state before its first render.
Sourcepub fn with_predictor(self, config: PredictorConfig) -> Self
pub fn with_predictor(self, config: PredictorConfig) -> Self
Enable category-aware prediction of unmeasured row heights. Measured heights remain exact; unclassified rows use category zero.
Sourcepub fn predicted_height(&self, category: usize) -> u16
pub fn predicted_height(&self, category: usize) -> u16
Point prediction for a category, or the configured default height.
Sourcepub fn predictor_stats(&self) -> Option<PredictorStats>
pub fn predictor_stats(&self) -> Option<PredictorStats>
Statistics from measured rows, when prediction is enabled.
Sourcepub fn measure(&mut self, idx: usize, height: u16)
pub fn measure(&mut self, idx: usize, height: u16)
Record the measured height of item idx for a variable-height
list. Rendering measures the visible rows itself; call this when an
item’s height changed while off-screen so offsets stay exact. Ignored
until the first variable-height render creates the tracker.
Sourcepub fn measure_in_category(&mut self, idx: usize, height: u16, category: usize)
pub fn measure_in_category(&mut self, idx: usize, height: u16, category: usize)
Record an off-screen measurement together with its item category.
Sourcepub fn heights(&self) -> Option<&VariableHeightsFenwick>
pub fn heights(&self) -> Option<&VariableHeightsFenwick>
The variable-height tracker (after the first variable-height render).
Sourcepub fn with_overscan(self, overscan: usize) -> Self
pub fn with_overscan(self, overscan: usize) -> Self
Create with overscan.
Sourcepub fn with_follow(self, follow: bool) -> Self
pub fn with_follow(self, follow: bool) -> Self
Create with follow mode enabled.
Sourcepub fn with_persistence_id(self, id: impl Into<String>) -> Self
pub fn with_persistence_id(self, id: impl Into<String>) -> Self
Create with a persistence ID for state saving. Without one the list has
no StateKey and its state is not persisted.
Sourcepub fn persistence_id(&self) -> Option<&str>
pub fn persistence_id(&self) -> Option<&str>
Get the persistence ID, if set.
Sourcepub fn scroll_offset(&self) -> usize
pub fn scroll_offset(&self) -> usize
Get raw scroll offset.
Warning: After scroll_to_bottom, this may return usize::MAX
(a lazy sentinel that gets clamped during rendering). Use
scroll_offset_clamped with a known
total_items to get a safe value for display or indexing.
Sourcepub fn scroll_offset_clamped(&self, total_items: usize) -> usize
pub fn scroll_offset_clamped(&self, total_items: usize) -> usize
Get scroll offset clamped against a known total item count.
Prefer this over scroll_offset() when the total is available,
because scroll_to_bottom may store usize::MAX internally.
Sourcepub fn visible_count(&self) -> usize
pub fn visible_count(&self) -> usize
Get visible item count (from last render).
Sourcepub fn scroll_to_top(&mut self)
pub fn scroll_to_top(&mut self)
Scroll to top.
Sourcepub fn scroll_to_bottom(&mut self, total_items: usize)
pub fn scroll_to_bottom(&mut self, total_items: usize)
Scroll to bottom.
Sourcepub fn select_previous(&mut self, total_items: usize)
pub fn select_previous(&mut self, total_items: usize)
Select previous item.
Sourcepub fn select_next(&mut self, total_items: usize)
pub fn select_next(&mut self, total_items: usize)
Select next item.
Sourcepub fn is_at_bottom(&self, total_items: usize) -> bool
pub fn is_at_bottom(&self, total_items: usize) -> bool
Check if at bottom.
Sourcepub fn set_follow(&mut self, follow: bool, total_items: usize)
pub fn set_follow(&mut self, follow: bool, total_items: usize)
Enable/disable follow mode.
Sourcepub fn follow_mode(&self) -> bool
pub fn follow_mode(&self) -> bool
Check if follow mode is enabled.
Sourcepub fn handle_mouse(
&mut self,
event: &MouseEvent,
hit: Option<(HitId, HitRegion, u64)>,
scrollbar_hit_id: HitId,
total_items: usize,
viewport_height: u16,
fixed_item_height: u16,
) -> MouseResult
pub fn handle_mouse( &mut self, event: &MouseEvent, hit: Option<(HitId, HitRegion, u64)>, scrollbar_hit_id: HitId, total_items: usize, viewport_height: u16, fixed_item_height: u16, ) -> MouseResult
Handle mouse events, including scrollbar interaction.
The caller must provide the hit test result and the expected hit ID for the scrollbar.
After a ListHeightMode::Variable render the scrollbar works in
rows, as it was drawn, and fixed_item_height is ignored: the thumb
position maps back to the nearest item start, and a wheel or arrow
step always moves at least one item.
Trait Implementations§
Source§impl Clone for VirtualizedListState
impl Clone for VirtualizedListState
Source§impl Debug for VirtualizedListState
impl Debug for VirtualizedListState
Source§impl Default for VirtualizedListState
impl Default for VirtualizedListState
Source§impl Stateful for VirtualizedListState
impl Stateful for VirtualizedListState
Source§type State = VirtualizedListPersistState
type State = VirtualizedListPersistState
Source§fn state_key(&self) -> Option<StateKey>
fn state_key(&self) -> Option<StateKey>
None if it has no
stable identity and must not be persisted. Read more