pub struct UiNode(/* private fields */);Expand description
A stable declarative UI node. Script-produced nodes contain no GPUI values or lifetimes; trusted Rust Hosts may attach opaque foreground callbacks.
A node is a shared, copy-on-write handle: Rhai passes nodes by value (variables, arrays, arguments), so a clone must not copy the subtree.
Implementations§
Source§impl UiNode
impl UiNode
pub fn text(text: impl Into<ImmutableString>) -> Self
pub fn rich_text(spans: Vec<Span>) -> Self
pub fn canvas(scene: CanvasScene) -> Self
Sourcepub fn svg(source: impl Into<String>) -> Result<Self, InlineSvgError>
pub fn svg(source: impl Into<String>) -> Result<Self, InlineSvgError>
Construct a validated self-contained inline SVG atom.
§Errors
Returns crate::InlineSvgError for active, external, or oversized
markup.
pub fn box_node(children: Vec<Self>) -> Self
pub fn fragment(children: Vec<Self>) -> Self
pub fn column(children: Vec<Self>) -> Self
pub fn row(children: Vec<Self>) -> Self
pub fn custom(primitive: PrimitiveNode) -> Self
pub fn error_boundary(child: Self, fallback: Self) -> Self
pub fn image(handle: OpaqueHandle) -> Self
pub fn asset_image(asset: AssetId) -> Self
pub fn directional_image( left_to_right: OpaqueHandle, right_to_left: OpaqueHandle, ) -> Self
pub fn directional_asset_image( left_to_right: AssetId, right_to_left: AssetId, ) -> Self
pub fn overlay(trigger: Self, content: Self, spec: OverlayNodeSpec) -> Self
pub fn layer(content: Self, spec: LayerNodeSpec) -> Self
pub fn virtual_collection(spec: VirtualCollectionNodeSpec) -> Self
pub fn with_key(self, key: impl Into<ImmutableString>) -> Self
pub fn with_style(self, style: &Style) -> Self
Sourcepub fn with_signal_binding(
self,
property: SignalProperty,
signal: NativeSignal,
) -> Result<Self, SignalError>
pub fn with_signal_binding( self, property: SignalProperty, signal: NativeSignal, ) -> Result<Self, SignalError>
Bind one approved hot property to a component-scoped native signal.
§Errors
Returns a property/type mismatch without changing the node.
Sourcepub fn with_signal_style(
self,
signal: NativeSignal,
states: BTreeMap<String, Style>,
) -> Result<Self, SignalError>
pub fn with_signal_style( self, signal: NativeSignal, states: BTreeMap<String, Style>, ) -> Result<Self, SignalError>
Merge states[value] into this node’s style, where value is the
current value of a string signal.
§Errors
Returns crate::SignalError::TypeMismatch for a signal that is not a
string signal.
pub fn signal_style(&self) -> Option<&SignalStyle>
pub fn with_element_ref(self, reference: ElementRef) -> Self
pub fn with_scrollbars(self, spec: ScrollbarSpec) -> Self
pub fn with_part_styles(self, styles: BTreeMap<String, Style>) -> Self
pub fn with_part_style(self, part: impl Into<String>, style: Style) -> Self
pub fn with_source(self, source: SourceLocation) -> Self
pub fn component_root(&self) -> Option<&ComponentInstancePath>
Sourcepub fn with_environment(self, values: &Map) -> Result<Self, String>
pub fn with_environment(self, values: &Map) -> Result<Self, String>
Set environment values inherited by this node’s subtree, merging with
values set earlier on the same node. Names and values are snake_case
strings; whether they are declared is decided by the active token base.
§Errors
Returns a message for non-string or malformed entries, or more than
crate::token::MAX_ENVIRONMENT_VALUES names.
pub fn with_attribute(self, name: impl Into<String>, value: UiValue) -> Self
pub fn with_handler( self, event: impl Into<String>, handler: impl Into<UiEventHandler>, ) -> Self
pub fn with_handler_phase( self, event: impl Into<String>, phase: EventPhase, handler: impl Into<UiEventHandler>, ) -> Self
Sourcepub fn with_value_handler(
self,
event: impl Into<String>,
handler: impl Into<UiEventHandler>,
value: UiValue,
) -> Self
pub fn with_value_handler( self, event: impl Into<String>, handler: impl Into<UiEventHandler>, value: UiValue, ) -> Self
Append a handler that receives value as its payload; the node’s other
handlers for event keep their own payloads.
pub fn with_host_handler( self, event: impl Into<String>, callback: HostCallback, ) -> Self
pub fn with_handler_payload( self, event: impl Into<String>, payload: UiValue, ) -> Self
pub fn with_motion(self, animation: MotionSource) -> Self
pub fn with_exit_motion(self, motion: MotionSource) -> Self
pub fn with_progress_motion(self, binding: MotionProgressBinding) -> Self
pub fn with_motion_replay_key(self, key: impl Into<String>) -> Self
pub fn with_motion_particle_count(self, count: usize) -> Self
pub fn with_timeline(self, timeline: MotionTimeline) -> Self
Sourcepub fn with_layout_motion(self, duration_ms: u64, easing: MotionEasing) -> Self
pub fn with_layout_motion(self, duration_ms: u64, easing: MotionEasing) -> Self
Opt this node into committed-geometry layout motion.
Assign a same-window shared-layout identity to this real node.
pub fn handlers(&self) -> &BTreeMap<String, Vec<UiEventBinding>>
pub fn handler(&self, event: &str) -> Option<&UiEventHandler>
pub fn event_handlers(&self, event: &str) -> &[UiEventBinding]
Sourcepub fn handler_payload(&self, event: &str) -> Option<&UiValue>
pub fn handler_payload(&self, event: &str) -> Option<&UiValue>
The payload set for event with Self::with_handler_payload, else
the value of the last handler declared with one.
pub fn motions(&self) -> &[MotionSource]
pub fn exit_motions(&self) -> &[MotionSource]
pub fn progress_motions(&self) -> &[MotionProgressBinding]
pub fn timelines(&self) -> &[MotionTimeline]
pub fn kind(&self) -> &UiNodeKind
pub fn kind_tag(&self) -> UiNodeKindTag
pub fn key(&self) -> Option<&NodeKey>
pub fn style(&self) -> &Style
pub fn part_style(&self, part: &str) -> Option<&Style>
pub fn part_styles(&self) -> impl Iterator<Item = (&str, &Style)>
pub fn source(&self) -> Option<&SourceLocation>
pub fn attributes(&self) -> &BTreeMap<String, UiValue>
pub fn signal_bindings( &self, ) -> impl ExactSizeIterator<Item = (SignalProperty, &NativeSignal)>
pub fn element_ref(&self) -> Option<&ElementRef>
Trait Implementations§
Source§impl CustomType for UiNode
impl CustomType for UiNode
Auto Trait Implementations§
impl !RefUnwindSafe for UiNode
impl !Send for UiNode
impl !Sync for UiNode
impl !UnwindSafe for UiNode
impl Freeze for UiNode
impl Unpin for UiNode
impl UnsafeUnpin for UiNode
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Variant for T
impl<T> Variant for T
Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Variant trait object to &mut dyn Any.Source§fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
Variant trait object to Box<dyn Any>.