pub struct ListItem { /* private fields */ }Expand description
A list item
Implementations§
Methods from Deref<Target = Div>§
Sourcepub fn element_id(&self) -> Option<&str>
pub fn element_id(&self) -> Option<&str>
Get the element ID if set
Sourcepub fn stateful_context_key(&self) -> Option<&str>
pub fn stateful_context_key(&self) -> Option<&str>
Get the stateful context key if set
Sourcepub fn swap(&mut self) -> Div
pub fn swap(&mut self) -> Div
Swap this Div with a default, returning the original
This is a convenience method for use in state callbacks where you need
to consume self to chain builder methods, then assign back.
Note: This takes ownership of the current Div and leaves a default in its place. All properties are preserved in the returned Div. You must assign the result back to complete the update.
For updating specific properties without the swap pattern, consider using
the setter methods directly (e.g., set_bg(), set_transform()).
§Example
.on_state(|state, div| match state {
ButtonState::Idle => {
*div = div.swap().bg(Color::BLUE).rounded(4.0);
}
ButtonState::Hovered => {
*div = div.swap().bg(Color::CYAN).rounded(8.0);
}
})Sourcepub fn set_bg(&mut self, color: impl Into<Brush>)
pub fn set_bg(&mut self, color: impl Into<Brush>)
Set the background color/brush without consuming self
This is useful in state callbacks where you want to update properties without using the swap pattern.
Sourcepub fn set_rounded(&mut self, radius: f32)
pub fn set_rounded(&mut self, radius: f32)
Set the corner radius without consuming self
Sourcepub fn set_transform(&mut self, transform: Transform)
pub fn set_transform(&mut self, transform: Transform)
Set the transform without consuming self
Sourcepub fn set_shadow(&mut self, shadow: Shadow)
pub fn set_shadow(&mut self, shadow: Shadow)
Set the shadow without consuming self
Sourcepub fn set_opacity(&mut self, opacity: f32)
pub fn set_opacity(&mut self, opacity: f32)
Set the opacity without consuming self
Sourcepub fn set_border(&mut self, width: f32, color: Color)
pub fn set_border(&mut self, width: f32, color: Color)
Set border with width and color without consuming self
Sourcepub fn set_overflow_clip(&mut self, clip: bool)
pub fn set_overflow_clip(&mut self, clip: bool)
Set overflow clip without consuming self
Sourcepub fn set_padding_x(&mut self, px: f32)
pub fn set_padding_x(&mut self, px: f32)
Set horizontal padding without consuming self
Sourcepub fn set_padding_y(&mut self, px: f32)
pub fn set_padding_y(&mut self, px: f32)
Set vertical padding without consuming self
Sourcepub fn set_child(&mut self, child: impl ElementBuilder + 'static)
pub fn set_child(&mut self, child: impl ElementBuilder + 'static)
Clear all children and add a single child
Sourcepub fn clear_children(&mut self)
pub fn clear_children(&mut self)
Clear all children
Sourcepub fn set_w(&mut self, px: f32)
pub fn set_w(&mut self, px: f32)
Set width in pixels without consuming self
This is useful in state callbacks where you want to update layout properties without using the swap pattern.
Sourcepub fn set_h_auto(&mut self)
pub fn set_h_auto(&mut self)
Set height to auto without consuming self
Sourcepub fn set_style(&mut self, style: &ElementStyle)
pub fn set_style(&mut self, style: &ElementStyle)
Sourcepub fn merge(&mut self, other: Div)
pub fn merge(&mut self, other: Div)
Merge properties from another Div into this one
This applies the other Div’s non-default properties on top of this one.
Useful in on_state callbacks to apply changes without reassignment:
.on_state(|state, div| {
div.merge(div().bg(color).child(label));
})Sourcepub fn style_mut(&mut self) -> &mut Style
pub fn style_mut(&mut self) -> &mut Style
Get direct access to the taffy style for advanced configuration
Sourcepub fn event_handlers(&self) -> &EventHandlers
pub fn event_handlers(&self) -> &EventHandlers
Get a reference to the event handlers
Sourcepub fn event_handlers_mut(&mut self) -> &mut EventHandlers
pub fn event_handlers_mut(&mut self) -> &mut EventHandlers
Get a mutable reference to the event handlers
Trait Implementations§
Source§impl ElementBuilder for ListItem
impl ElementBuilder for ListItem
Source§fn build(&self, tree: &mut LayoutTree) -> LayoutNodeId
fn build(&self, tree: &mut LayoutTree) -> LayoutNodeId
Source§fn render_props(&self) -> RenderProps
fn render_props(&self) -> RenderProps
Source§fn children_builders(&self) -> &[Box<dyn ElementBuilder>]
fn children_builders(&self) -> &[Box<dyn ElementBuilder>]
Source§fn element_type_id(&self) -> ElementTypeId
fn element_type_id(&self) -> ElementTypeId
Source§fn semantic_type_name(&self) -> Option<&'static str>
fn semantic_type_name(&self) -> Option<&'static str>
Source§fn element_classes(&self) -> &[String]
fn element_classes(&self) -> &[String]
Source§fn text_render_info(&self) -> Option<TextRenderInfo>
fn text_render_info(&self) -> Option<TextRenderInfo>
Source§fn styled_text_render_info(&self) -> Option<StyledTextRenderInfo>
fn styled_text_render_info(&self) -> Option<StyledTextRenderInfo>
Source§fn svg_render_info(&self) -> Option<SvgRenderInfo>
fn svg_render_info(&self) -> Option<SvgRenderInfo>
Source§fn image_render_info(&self) -> Option<ImageRenderInfo>
fn image_render_info(&self) -> Option<ImageRenderInfo>
Source§fn canvas_render_info(
&self,
) -> Option<Rc<dyn Fn(&mut dyn DrawContext, CanvasBounds)>>
fn canvas_render_info( &self, ) -> Option<Rc<dyn Fn(&mut dyn DrawContext, CanvasBounds)>>
Source§fn event_handlers(&self) -> Option<&EventHandlers>
fn event_handlers(&self) -> Option<&EventHandlers>
Source§fn scroll_info(&self) -> Option<ScrollRenderInfo>
fn scroll_info(&self) -> Option<ScrollRenderInfo>
Source§fn scroll_physics(&self) -> Option<Arc<Mutex<ScrollPhysics>>>
fn scroll_physics(&self) -> Option<Arc<Mutex<ScrollPhysics>>>
Source§fn motion_animation_for_child(
&self,
_child_index: usize,
) -> Option<MotionAnimation>
fn motion_animation_for_child( &self, _child_index: usize, ) -> Option<MotionAnimation>
Source§fn motion_bindings(&self) -> Option<MotionBindings>
fn motion_bindings(&self) -> Option<MotionBindings>
Source§fn motion_stable_id(&self) -> Option<&str>
fn motion_stable_id(&self) -> Option<&str>
Source§fn motion_should_replay(&self) -> bool
fn motion_should_replay(&self) -> bool
Source§fn motion_is_suspended(&self) -> bool
fn motion_is_suspended(&self) -> bool
Source§fn motion_is_exiting(&self) -> bool
fn motion_is_exiting(&self) -> bool
Use query_motion(key).exit() to explicitly trigger motion exit
Source§fn layout_bounds_storage(&self) -> Option<Arc<Mutex<Option<ElementBounds>>>>
fn layout_bounds_storage(&self) -> Option<Arc<Mutex<Option<ElementBounds>>>>
Source§fn layout_bounds_callback(
&self,
) -> Option<Arc<dyn Fn(ElementBounds) + Send + Sync>>
fn layout_bounds_callback( &self, ) -> Option<Arc<dyn Fn(ElementBounds) + Send + Sync>>
Source§fn set_auto_id(&mut self, _id: String) -> bool
fn set_auto_id(&mut self, _id: String) -> bool
Source§fn children_builders_mut(&mut self) -> &mut [Box<dyn ElementBuilder>]
fn children_builders_mut(&mut self) -> &mut [Box<dyn ElementBuilder>]
Source§fn bound_scroll_ref(&self) -> Option<&ScrollRef>
fn bound_scroll_ref(&self) -> Option<&ScrollRef>
Source§fn motion_on_ready_callback(
&self,
) -> Option<Arc<dyn Fn(ElementBounds) + Send + Sync>>
fn motion_on_ready_callback( &self, ) -> Option<Arc<dyn Fn(ElementBounds) + Send + Sync>>
Source§fn layout_animation_config(&self) -> Option<LayoutAnimationConfig>
fn layout_animation_config(&self) -> Option<LayoutAnimationConfig>
Source§fn visual_animation_config(&self) -> Option<VisualAnimationConfig>
fn visual_animation_config(&self) -> Option<VisualAnimationConfig>
Auto Trait Implementations§
impl Freeze for ListItem
impl !RefUnwindSafe for ListItem
impl !Send for ListItem
impl !Sync for ListItem
impl Unpin for ListItem
impl UnsafeUnpin 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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.