pub struct ListItem {
pub interactive: bool,
pub selected: bool,
pub draggable: bool,
pub drag_target: bool,
pub force_hovered: bool,
force_background: Option<Color32>,
pub collapse_openness: Option<f32>,
height: f32,
}
Expand description
Content-generic list item.
The following features are supported:
- Flat or collapsible hierarchical lists.
- Full-span background highlighting.
- Interactive or not.
- Support for drag and drop with
crate::drag_and_drop
.
Besides these core features, ListItem
delegates all content to the ListItemContent
implementations, such as super::LabelContent
and super::PropertyContent
.
Usage example can be found in re_ui_example
.
Fields§
§interactive: bool
§selected: bool
§draggable: bool
§drag_target: bool
§force_hovered: bool
§force_background: Option<Color32>
§collapse_openness: Option<f32>
§height: f32
Implementations§
source§impl ListItem
impl ListItem
sourcepub fn interactive(self, interactive: bool) -> ListItem
pub fn interactive(self, interactive: bool) -> ListItem
Can the user click and interact with it?
Set to false
for items that only show info, but shouldn’t be interactive.
Note: making the list item non-interactive does not necessarily make its content
non-interactive. For example, a non-interactive list item may be used in conjunction with
super::PropertyContent
to build property-like editors.
sourcepub fn drop_target_style(self, drag_target: bool) -> ListItem
pub fn drop_target_style(self, drag_target: bool) -> ListItem
Highlight the item as the current drop target.
Use this while dragging, to highlight which container will receive the drop at any given time. Note: this flag has otherwise no behavioral effect. It’s up to the caller to set it when the item is being hovered (or otherwise selected as drop target) while a drag is in progress.
sourcepub fn force_hovered(self, force_hovered: bool) -> ListItem
pub fn force_hovered(self, force_hovered: bool) -> ListItem
Override the hovered state even if the item is not actually hovered.
Used to highlight items representing things that are hovered elsewhere in the UI. Note that
the [egui::Response
] returned by Self::show_flat
, Self::show_hierarchical
, and
Self::show_hierarchical_with_children
will still reflect the actual hover state.
sourcepub fn force_background(self, force_background: Color32) -> ListItem
pub fn force_background(self, force_background: Color32) -> ListItem
Override the background color for the item.
If set, this takes precedence over Self::force_hovered
and any kind of selection/
interaction-driven background handling.
sourcepub fn with_height(self, height: f32) -> ListItem
pub fn with_height(self, height: f32) -> ListItem
Set the item height.
The default is provided by DesignTokens::list_item_height
and is suitable for hierarchical
lists.
sourcepub fn show_flat<'a>(
self,
ui: &mut Ui,
content: impl ListItemContent + 'a
) -> Response
pub fn show_flat<'a>( self, ui: &mut Ui, content: impl ListItemContent + 'a ) -> Response
Draw the item as part of a flat list.
Important: must be called while nested in a super::list_item_scope
.
sourcepub fn show_hierarchical(
self,
ui: &mut Ui,
content: impl ListItemContent
) -> Response
pub fn show_hierarchical( self, ui: &mut Ui, content: impl ListItemContent ) -> Response
Draw the item as a leaf node from a hierarchical list.
Important: must be called while nested in a super::list_item_scope
.
sourcepub fn show_hierarchical_with_children<R>(
self,
ui: &mut Ui,
id: Id,
default_open: bool,
content: impl ListItemContent,
add_children: impl FnOnce(&mut Ui) -> R
) -> ShowCollapsingResponse<R>
pub fn show_hierarchical_with_children<R>( self, ui: &mut Ui, id: Id, default_open: bool, content: impl ListItemContent, add_children: impl FnOnce(&mut Ui) -> R ) -> ShowCollapsingResponse<R>
Draw the item as a non-leaf node from a hierarchical list.
The id
should be globally unique! You can use ui.make_persistent_id(…)
for that. The
children content is indented.
Important: must be called while nested in a super::list_item_scope
.
sourcepub fn show_hierarchical_with_children_unindented<R>(
self,
ui: &mut Ui,
id: Id,
default_open: bool,
content: impl ListItemContent,
add_children: impl FnOnce(&mut Ui) -> R
) -> ShowCollapsingResponse<R>
pub fn show_hierarchical_with_children_unindented<R>( self, ui: &mut Ui, id: Id, default_open: bool, content: impl ListItemContent, add_children: impl FnOnce(&mut Ui) -> R ) -> ShowCollapsingResponse<R>
Draw the item with unindented child content.
This is similar to Self::show_hierarchical_with_children
but without indent. This is
only for special cases such as crate::SectionCollapsingHeader
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ListItem
impl RefUnwindSafe for ListItem
impl Send for ListItem
impl Sync for ListItem
impl Unpin for ListItem
impl UnwindSafe for ListItem
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
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request