pub struct PropertyContent<'a> {
label: WidgetText,
min_desired_width: f32,
icon_fn: Option<Box<dyn FnOnce(&mut Ui, Rect, WidgetVisuals) + 'a>>,
show_only_when_collapsed: bool,
value_fn: Option<Box<dyn FnOnce(&mut Ui, WidgetVisuals) + 'a>>,
button: Option<Box<dyn ItemButton + 'a>>,
}
Expand description
ListItemContent
to display property-like, two-column content, with the left column
containing a label (along with an optional icon) and the right column containing some custom
value (which may be editable).
Fields§
§label: WidgetText
§min_desired_width: f32
§icon_fn: Option<Box<dyn FnOnce(&mut Ui, Rect, WidgetVisuals) + 'a>>
§show_only_when_collapsed: bool
§value_fn: Option<Box<dyn FnOnce(&mut Ui, WidgetVisuals) + 'a>>
Implementations§
source§impl<'a> PropertyContent<'a>
impl<'a> PropertyContent<'a>
pub fn new(label: impl Into<WidgetText>) -> PropertyContent<'a>
sourcepub fn min_desired_width(self, min_desired_width: f32) -> PropertyContent<'a>
pub fn min_desired_width(self, min_desired_width: f32) -> PropertyContent<'a>
Set the minimum desired width for the entire content.
Since there is no possibly way to meaningfully collapse two to three columns worth of content, this is set to 200.0 by default.
sourcepub fn with_icon(self, icon: &'a Icon) -> PropertyContent<'a>
pub fn with_icon(self, icon: &'a Icon) -> PropertyContent<'a>
Provide an Icon
to be displayed on the left of the label.
sourcepub fn with_icon_fn<F>(self, icon_fn: F) -> PropertyContent<'a>where
F: FnOnce(&mut Ui, Rect, WidgetVisuals) + 'a,
pub fn with_icon_fn<F>(self, icon_fn: F) -> PropertyContent<'a>where
F: FnOnce(&mut Ui, Rect, WidgetVisuals) + 'a,
Provide a custom closure to draw an icon on the left of the item.
Add a right-aligned super::ItemButton
.
Note: for aesthetics, space is always reserved for the action button.
Helper to add an super::ItemActionButton
to the right of the item.
See Self::button
for more information.
Helper to add an enabled/disabled super::ItemActionButton
to the right of the item.
See Self::button
for more information.
Helper to add a super::ItemMenuButton
to the right of the item.
See Self::button
for more information.
sourcepub fn show_only_when_collapsed(
self,
show_only_when_collapsed: bool
) -> PropertyContent<'a>
pub fn show_only_when_collapsed( self, show_only_when_collapsed: bool ) -> PropertyContent<'a>
Display value only for leaf or collapsed items.
When enabled, the value for this item is not displayed for uncollapsed hierarchical items. This is convenient when the value serves are a summary of the child content, which doesn’t need to be displayed when said content is visible.
Enabled by default.
sourcepub fn value_fn<F>(self, value_fn: F) -> PropertyContent<'a>where
F: FnOnce(&mut Ui, WidgetVisuals) + 'a,
pub fn value_fn<F>(self, value_fn: F) -> PropertyContent<'a>where
F: FnOnce(&mut Ui, WidgetVisuals) + 'a,
Provide a closure to draw the content of the right column.
sourcepub fn value_bool(self, b: bool) -> PropertyContent<'a>
pub fn value_bool(self, b: bool) -> PropertyContent<'a>
Show a read-only boolean in the value column.
sourcepub fn value_bool_mut(self, b: &'a mut bool) -> PropertyContent<'a>
pub fn value_bool_mut(self, b: &'a mut bool) -> PropertyContent<'a>
Show an editable boolean in the value column.
sourcepub fn value_text(self, text: impl Into<WidgetText> + 'a) -> PropertyContent<'a>
pub fn value_text(self, text: impl Into<WidgetText> + 'a) -> PropertyContent<'a>
Show a static text in the value column.
sourcepub fn value_text_mut(self, text: &'a mut String) -> PropertyContent<'a>
pub fn value_text_mut(self, text: &'a mut String) -> PropertyContent<'a>
Show an editable text in the value column.
sourcepub fn value_color(self, rgba: &'a [u8; 4]) -> PropertyContent<'a>
pub fn value_color(self, rgba: &'a [u8; 4]) -> PropertyContent<'a>
Show a read-only color in the value column.
sourcepub fn value_color_mut(self, rgba: &'a mut [u8; 4]) -> PropertyContent<'a>
pub fn value_color_mut(self, rgba: &'a mut [u8; 4]) -> PropertyContent<'a>
Show an editable color in the value column.
Trait Implementations§
source§impl ListItemContent for PropertyContent<'_>
impl ListItemContent for PropertyContent<'_>
source§fn ui(self: Box<PropertyContent<'_>>, ui: &mut Ui, context: &ContentContext<'_>)
fn ui(self: Box<PropertyContent<'_>>, 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 PropertyContent<'a>
impl<'a> !RefUnwindSafe for PropertyContent<'a>
impl<'a> !Send for PropertyContent<'a>
impl<'a> !Sync for PropertyContent<'a>
impl<'a> Unpin for PropertyContent<'a>
impl<'a> !UnwindSafe for PropertyContent<'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 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