pub struct VirtualListHandle { /* private fields */ }Expand description
The scroll and measurement state of one VirtualList. Cheap to clone;
clones share the state. Keep one per list in the owning view.
Implementations§
Source§impl VirtualListHandle
impl VirtualListHandle
Sourcepub fn new(item_count: usize) -> Self
pub fn new(item_count: usize) -> Self
A measured (variable-row-height) handle for a list of item_count
rows, scrolled to the top.
Sourcepub fn uniform(item_count: usize) -> Self
pub fn uniform(item_count: usize) -> Self
A uniform (fixed-row-height) handle for a list of item_count rows,
scrolled to the top. Every row is laid out at the height of the
first, so rows should be built at one explicit height.
Sourcepub fn is_uniform(&self) -> bool
pub fn is_uniform(&self) -> bool
Whether this handle was made by uniform.
Sourcepub fn item_count(&self) -> usize
pub fn item_count(&self) -> usize
The number of rows the list renders.
Sourcepub fn set_item_count(&self, item_count: usize)
pub fn set_item_count(&self, item_count: usize)
Replaces the collection: item_count rows, all remeasured, scrolled
back to the top. For an append or a local edit, splice
keeps the scroll position and the other rows’ measurements.
Sourcepub fn splice(&self, old_range: Range<usize>, count: usize)
pub fn splice(&self, old_range: Range<usize>, count: usize)
Replaces the rows in old_range with count new rows, keeping every
other row’s measured height and the scroll position (a uniform list
clamps it when the content got shorter).
Sourcepub fn remeasure(&self)
pub fn remeasure(&self)
Discards every measured height, for when row content changed size without the count changing (a font or density switch). A uniform list measures its first row every frame, so this does nothing there.
Sourcepub fn scroll_to_item(&self, ix: usize, strategy: VirtualListScroll)
pub fn scroll_to_item(&self, ix: usize, strategy: VirtualListScroll)
Scrolls so row ix is visible, per strategy. An index past the end
scrolls to the end. Takes effect on the next frame.
Sourcepub fn scroll_by(&self, distance: Pixels)
pub fn scroll_by(&self, distance: Pixels)
Scrolls by distance (positive moves the content up, towards later
rows), clamped to the content.
Sourcepub fn first_visible_item(&self) -> usize
pub fn first_visible_item(&self) -> usize
The index of the first row at the top of the viewport.
Sourcepub fn bounds_for_item(&self, ix: usize) -> Option<Bounds<Pixels>>
pub fn bounds_for_item(&self, ix: usize) -> Option<Bounds<Pixels>>
Row ix’s window-coordinate bounds from the last frame, when it was
rendered.
Sourcepub fn viewport_bounds(&self) -> Bounds<Pixels>
pub fn viewport_bounds(&self) -> Bounds<Pixels>
The list’s viewport in window coordinates, as laid out in the last frame (zero-sized before the first). This is what PageUp/PageDown step over: it follows a bounded parent or a resized window, where a configured height would not.
Sourcepub fn remaining_below(&self) -> Option<Pixels>
pub fn remaining_below(&self) -> Option<Pixels>
How much content lies below the viewport’s bottom edge after the
last frame, or None when that is not known. A uniform list knows it
exactly once laid out: the row count times the measured row, less the
scroll offset and the viewport. A measured list knows it only when
its last row was laid out in the last frame, since the rows it has
not built have no height yet.
Sourcepub fn is_scrolled_to_top(&self) -> bool
pub fn is_scrolled_to_top(&self) -> bool
Whether the list is scrolled to its top (within half a pixel).
Sourcepub fn is_scrolled_to_end(&self) -> bool
pub fn is_scrolled_to_end(&self) -> bool
Whether the list’s last row ends inside the viewport. An empty list
answers true. A nonempty measured list answers false until its
last row has been laid out; uniform mode defaults to true before
GPUI reports its scroll extent.
Trait Implementations§
Source§impl Clone for VirtualListHandle
impl Clone for VirtualListHandle
Auto Trait Implementations§
impl !RefUnwindSafe for VirtualListHandle
impl !Send for VirtualListHandle
impl !Sync for VirtualListHandle
impl !UnwindSafe for VirtualListHandle
impl Freeze for VirtualListHandle
impl Unpin for VirtualListHandle
impl UnsafeUnpin for VirtualListHandle
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,
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> ⓘ
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