Struct re_ui::list_item::LabelContent
source · pub struct LabelContent<'a> {
text: WidgetText,
subdued: bool,
weak: bool,
italics: bool,
label_style: LabelStyle,
icon_fn: Option<Box<dyn FnOnce(&mut Ui, Rect, WidgetVisuals) + 'a>>,
buttons_fn: Option<Box<dyn FnOnce(&mut Ui) -> Response + 'a>>,
always_show_buttons: bool,
text_wrap_mode: Option<TextWrapMode>,
min_desired_width: Option<f32>,
}
Expand description
ListItemContent
that displays a simple label with optional icon and buttons.
Fields§
§text: WidgetText
§subdued: bool
§weak: bool
§italics: bool
§label_style: LabelStyle
§icon_fn: Option<Box<dyn FnOnce(&mut Ui, Rect, WidgetVisuals) + 'a>>
§text_wrap_mode: Option<TextWrapMode>
§min_desired_width: Option<f32>
Implementations§
source§impl<'a> LabelContent<'a>
impl<'a> LabelContent<'a>
pub fn new(text: impl Into<WidgetText>) -> Self
sourcepub fn subdued(self, subdued: bool) -> Self
pub fn subdued(self, subdued: bool) -> Self
Set the subdued state of the item.
Note: takes precedence over Self::weak
if set.
sourcepub fn weak(self, weak: bool) -> Self
pub fn weak(self, weak: bool) -> Self
Set the weak state of the item.
Note: Self::subdued
takes precedence if set.
sourcepub fn label_style(self, style: LabelStyle) -> Self
pub fn label_style(self, style: LabelStyle) -> Self
Style the label for an unnamed items.
The styling is applied on top of to Self::weak
and Self::subdued
. It also implies Self::italics
.
sourcepub fn min_desired_width(self, min_desired_width: f32) -> Self
pub fn min_desired_width(self, min_desired_width: f32) -> Self
Set the minimum desired for the content.
This defaults to zero.
sourcepub fn with_icon(self, icon: &'a Icon) -> Self
pub fn with_icon(self, icon: &'a Icon) -> Self
Provide an Icon
to be displayed on the left of the item.
sourcepub fn with_icon_fn(
self,
icon_fn: impl FnOnce(&mut Ui, Rect, WidgetVisuals) + 'a
) -> Self
pub fn with_icon_fn( self, icon_fn: impl FnOnce(&mut Ui, Rect, WidgetVisuals) + 'a ) -> Self
Provide a custom closure to draw an icon on the left of the item.
Provide a closure to display on-hover buttons on the right of the item.
Buttons also show when the item is selected, in order to support clicking them on touch
screens. The buttons can be set to be always shown with Self::always_show_buttons
.
Notes:
- If buttons are used, the item will allocate the full available width of the parent. If the enclosing UI adapts to the childrens width, it will unnecessarily grow. If buttons aren’t used, the item will only allocate the width needed for the text and icons if any.
- A right to left layout is used, so the right-most button must be added first.
Always show the buttons.
By default, buttons are only shown when the item is hovered or selected. By setting this to
true
, the buttons are always shown.
fn get_text_wrap_mode(&self, ui: &Ui) -> TextWrapMode
Trait Implementations§
source§impl ListItemContent for LabelContent<'_>
impl ListItemContent for LabelContent<'_>
source§fn ui(self: Box<Self>, ui: &mut Ui, context: &ContentContext<'_>)
fn ui(self: Box<Self>, ui: &mut Ui, context: &ContentContext<'_>)
source§fn desired_width(&self, ui: &Ui) -> DesiredWidth
fn desired_width(&self, ui: &Ui) -> DesiredWidth
Auto Trait Implementations§
impl<'a> Freeze for LabelContent<'a>
impl<'a> !RefUnwindSafe for LabelContent<'a>
impl<'a> !Send for LabelContent<'a>
impl<'a> !Sync for LabelContent<'a>
impl<'a> Unpin for LabelContent<'a>
impl<'a> !UnwindSafe for LabelContent<'a>
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> 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 more