Skip to main content

VirtualListHandle

Struct VirtualListHandle 

Source
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

Source

pub fn new(item_count: usize) -> Self

A measured (variable-row-height) handle for a list of item_count rows, scrolled to the top.

Source

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.

Source

pub fn is_uniform(&self) -> bool

Whether this handle was made by uniform.

Source

pub fn item_count(&self) -> usize

The number of rows the list renders.

Source

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.

Source

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).

Source

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.

Source

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.

Source

pub fn scroll_by(&self, distance: Pixels)

Scrolls by distance (positive moves the content up, towards later rows), clamped to the content.

Source

pub fn first_visible_item(&self) -> usize

The index of the first row at the top of the viewport.

Source

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.

Source

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.

Source

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.

Source

pub fn is_scrolled_to_top(&self) -> bool

Whether the list is scrolled to its top (within half a pixel).

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VirtualListHandle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more