pub struct Ui<S: 'static, H: 'static> { /* private fields */ }Expand description
Used to construct a UI tree with the builder pattern.
Implementations§
Source§impl<S, H> Ui<S, H>
impl<S, H> Ui<S, H>
Sourcepub fn node(&mut self) -> &mut Self
pub fn node(&mut self) -> &mut Self
Create a new node in the tree and make it the current node for subsequent builder calls to configure.
Panics: If called a second time at the root level (only one root node is allowed).
Sourcepub fn id(&mut self, id: NodeId) -> &mut Self
pub fn id(&mut self, id: NodeId) -> &mut Self
Assign an id to the current node, providing a stable identity between build phases.
Panics: If the ID has already been assigned to a different node.
Sourcepub fn classes<'a>(&mut self, classes: impl Into<Option<&'a str>>) -> &mut Self
pub fn classes<'a>(&mut self, classes: impl Into<Option<&'a str>>) -> &mut Self
Append a space-separated list of CSS classes to the current node.
You can pass in None to remove all classes from the current node.
Sourcepub fn text(&mut self, text: impl Into<UIString>) -> &mut Self
pub fn text(&mut self, text: impl Into<UIString>) -> &mut Self
Sets the text to be rendered inside this node.
Sourcepub fn style_sheet<'a>(
&mut self,
style_sheet: impl Into<Option<&'a Stylesheet>>,
) -> &mut Self
pub fn style_sheet<'a>( &mut self, style_sheet: impl Into<Option<&'a Stylesheet>>, ) -> &mut Self
Apply a stylesheet to the current node and all of its children.
You can pass in None to remove a stylesheet from the current node. There can only be one stylesheet per node.
Sourcepub fn event(
&mut self,
event_type: On,
callback: impl Fn(&mut S, &mut EventCtx<'_, H>) + 'static,
) -> &mut Self
pub fn event( &mut self, event_type: On, callback: impl Fn(&mut S, &mut EventCtx<'_, H>) + 'static, ) -> &mut Self
Register an event callback.
Sourcepub fn on_style(
&mut self,
callback: impl Fn(&S, &mut Style) + 'static,
) -> &mut Self
pub fn on_style( &mut self, callback: impl Fn(&S, &mut Style) + 'static, ) -> &mut Self
Register a function to modify the current node’s style before the layout and draw phases.
Useful for applying the results of an On::AnimationFrame event handler.
There can only be one on_style callback per node.
Sourcepub fn on_measure(
&mut self,
callback: impl Fn(&S, &MeasureCtx<'_>) -> Size + 'static,
) -> &mut Self
pub fn on_measure( &mut self, callback: impl Fn(&S, &MeasureCtx<'_>) -> Size + 'static, ) -> &mut Self
Register a function to calculate the node’s preferred size based on the provided constraints. This overrides the node’s built-in text layout measurement.
There can only be one on_measure callback per node.
Sourcepub fn on_canvas(
&mut self,
callback: impl Fn(&S, &mut CanvasCtx<'_>) + 'static,
) -> &mut Self
pub fn on_canvas( &mut self, callback: impl Fn(&S, &mut CanvasCtx<'_>) + 'static, ) -> &mut Self
Register a function to draw arbitrary vector graphics inside the current node.
There can only be one on_canvas callback per node.
Sourcepub fn on_accessibility(
&mut self,
f: impl for<'a> Fn(&S, &mut AccessibilityCtx<'a>) + Send + Sync + 'static,
) -> &mut Self
pub fn on_accessibility( &mut self, f: impl for<'a> Fn(&S, &mut AccessibilityCtx<'a>) + Send + Sync + 'static, ) -> &mut Self
Register a function to construct the accessability information for the current node if the platform requests it.
There can only be one on_accessability callback per node.