pub struct List { /* private fields */ }Expand description
A list that renders only the rows its viewport holds.
Implementations§
Source§impl List
impl List
pub fn new( ident: impl Into<Ident>, count: usize, render_row: impl Fn(usize, &mut Window, &mut App) -> ListItem + 'static, ) -> Self
pub fn selected(self, id: impl Into<SharedString>) -> Self
Sourcepub fn row_height(self, height: f32) -> Self
pub fn row_height(self, height: f32) -> Self
Every row is this tall. Uniform height is what makes the list cheap; the default comes from the control scale for the list’s size.
Sourcepub fn visible_rows(self, rows: usize) -> Self
pub fn visible_rows(self, rows: usize) -> Self
Bounds the viewport to rows rows, which is what lets the list skip
the rows it does not show.
pub fn on_select( self, handler: impl Fn(SharedString, &mut Window, &mut App) + 'static, ) -> Self
Sourcepub fn reorderable(self, reorderable: bool) -> Self
pub fn reorderable(self, reorderable: bool) -> Self
Lets a row be picked up and put down somewhere else in the list.
The whole row is the handle. A list row’s ordinary action is a click, and GPUI only calls a press a drag once it has travelled two pixels, so both fit on the same row without a grip column the caller would have to render into every row it owns.
Sourcepub fn accepts(
self,
predicate: impl Fn(&DragItem, &DropPosition) -> bool + 'static,
) -> Self
pub fn accepts( self, predicate: impl Fn(&DragItem, &DropPosition) -> bool + 'static, ) -> Self
Whether this list takes a payload, and where.
Without one, a reorderable list takes its own rows and nothing else. Anything wider than that is policy, and policy is the caller’s.
Sourcepub fn on_reorder(
self,
handler: impl Fn(&DropIntent, &mut Window, &mut App) + 'static,
) -> Self
pub fn on_reorder( self, handler: impl Fn(&DropIntent, &mut Window, &mut App) + 'static, ) -> Self
Reports where a dropped row should go. The list does not move it.
Trait Implementations§
Source§impl IntoElement for List
impl IntoElement for List
Source§type Element = ViewElement<List>
type Element = ViewElement<List>
Source§fn into_element(self) -> Self::Element
fn into_element(self) -> Self::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Source§impl RenderOnce for List
impl RenderOnce for List
Source§fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
Render::render() method
which takes a mutable reference.Auto Trait Implementations§
impl !RefUnwindSafe for List
impl !Send for List
impl !Sync for List
impl !UnwindSafe for List
impl Freeze for List
impl Unpin for List
impl UnsafeUnpin for List
Blanket Implementations§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
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<E> Flipping for Ewhere
E: IntoElement,
impl<E> Flipping for Ewhere
E: IntoElement,
Source§impl<T> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
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