pub struct WidgetBuilding { /* private fields */ }Expand description
Represents a finalizing WidgetBuilder.
Widgets can register a build action to get access to this on build, build action properties also receive it as their first argument.
Build actions provides an opportunity to remove or capture the final properties of a widget, after they have all been resolved
and when assigns generated. Build actions can also define the child node and insert intrinsic nodes.
Implementations§
Source§impl WidgetBuilding
impl WidgetBuilding
Sourcepub fn widget_type(&self) -> WidgetType
pub fn widget_type(&self) -> WidgetType
The widget that started this builder.
Sourcepub fn has_child(&self) -> bool
pub fn has_child(&self) -> bool
If an innermost node is defined.
If false by the end of build the FillUiNode is used as the innermost node.
Sourcepub fn set_child(&mut self, node: impl IntoUiNode)
pub fn set_child(&mut self, node: impl IntoUiNode)
Set/replace the innermost node of the widget.
Sourcepub fn disable_inspector(&mut self)
pub fn disable_inspector(&mut self)
Don’t insert the inspector node and inspector metadata on build.
The inspector metadata is inserted by default when feature="inspector" is active.
Sourcepub fn disable_trace_widget(&mut self)
pub fn disable_trace_widget(&mut self)
Don’t insert the widget trace node on build.
The trace node is inserted by default when feature="trace_widget" is active.
Sourcepub fn disable_trace_wgt_item(&mut self)
pub fn disable_trace_wgt_item(&mut self)
Don’t insert property/intrinsic trace nodes on build.
The trace nodes is inserted by default when feature="trace_wgt_item" is active.
Sourcepub fn push_intrinsic(
&mut self,
group: NestGroup,
name: &'static str,
intrinsic: impl FnOnce(UiNode) -> UiNode + Send + Sync + 'static,
)
pub fn push_intrinsic( &mut self, group: NestGroup, name: &'static str, intrinsic: impl FnOnce(UiNode) -> UiNode + Send + Sync + 'static, )
Insert intrinsic node, that is a core functionality node of the widget that cannot be overridden.
The name is used for inspector/trace only, intrinsic nodes are not deduplicated.
Sourcepub fn push_intrinsic_positioned(
&mut self,
position: NestPosition,
name: &'static str,
intrinsic: impl FnOnce(UiNode) -> UiNode + Send + Sync + 'static,
)
pub fn push_intrinsic_positioned( &mut self, position: NestPosition, name: &'static str, intrinsic: impl FnOnce(UiNode) -> UiNode + Send + Sync + 'static, )
Insert intrinsic node with custom nest position.
The name is used for inspector/trace only, intrinsic nodes are not deduplicated.
Sourcepub fn remove_property(
&mut self,
property_id: PropertyId,
) -> Option<BuilderProperty>
pub fn remove_property( &mut self, property_id: PropertyId, ) -> Option<BuilderProperty>
Removes the property.
Note that if the property can already be captured by another widget component.
Sourcepub fn capture_property(
&mut self,
property_id: PropertyId,
) -> Option<BuilderPropertyRef<'_>>
pub fn capture_property( &mut self, property_id: PropertyId, ) -> Option<BuilderPropertyRef<'_>>
Flags the property as captured and returns a reference to it.
Note that captured properties are not instantiated in the final build, but they also are not removed like unset.
A property can be “captured” more then once, and if the "inspector" feature is enabled they can be inspected.
Sourcepub fn capture_var<T>(&mut self, property_id: PropertyId) -> Option<Var<T>>where
T: VarValue,
pub fn capture_var<T>(&mut self, property_id: PropertyId) -> Option<Var<T>>where
T: VarValue,
Flags the property as captured and downcast the input var.
Sourcepub fn capture_var_or_else<T, F>(
&mut self,
property_id: PropertyId,
or_else: impl FnOnce() -> F,
) -> Var<T>
pub fn capture_var_or_else<T, F>( &mut self, property_id: PropertyId, or_else: impl FnOnce() -> F, ) -> Var<T>
Flags the property as captured and downcast the input var, or calls or_else to generate a fallback.
Sourcepub fn capture_var_or_default<T>(&mut self, property_id: PropertyId) -> Var<T>
pub fn capture_var_or_default<T>(&mut self, property_id: PropertyId) -> Var<T>
Flags the property as captured and downcast the input var, returns a new one with the default value.
Sourcepub fn capture_ui_node(&mut self, property_id: PropertyId) -> Option<UiNode>
pub fn capture_ui_node(&mut self, property_id: PropertyId) -> Option<UiNode>
Flags the property as captured and get the input node.
Sourcepub fn capture_ui_node_or_else(
&mut self,
property_id: PropertyId,
or_else: impl FnOnce() -> UiNode,
) -> UiNode
pub fn capture_ui_node_or_else( &mut self, property_id: PropertyId, or_else: impl FnOnce() -> UiNode, ) -> UiNode
Flags the property as captured and get the input node, or calls or_else to generate a fallback node.
Sourcepub fn capture_ui_node_or_nil(&mut self, property_id: PropertyId) -> UiNode
pub fn capture_ui_node_or_nil(&mut self, property_id: PropertyId) -> UiNode
Flags the property as captured and get the input node, or UiNode::nil if the property is not found.
Sourcepub fn capture_handler<A: Clone + 'static>(
&mut self,
property_id: PropertyId,
) -> Option<ArcHandler<A>>
pub fn capture_handler<A: Clone + 'static>( &mut self, property_id: PropertyId, ) -> Option<ArcHandler<A>>
Flags the property as captured and downcast the input handler.
Sourcepub fn build_action_property(&mut self) -> Option<&PropertyInfo>
pub fn build_action_property(&mut self) -> Option<&PropertyInfo>
Identifies the current running build action property.
Sourcepub fn expect_property_capture(&mut self)
pub fn expect_property_capture(&mut self)
If is running a build_action_property and is building with debug assertions logs an error that
explains the property will not work on the widget because it was not captured.
Methods from Deref<Target = WidgetBuilderProperties>§
Sourcepub fn property(
&self,
property_id: PropertyId,
) -> Option<BuilderPropertyRef<'_>>
pub fn property( &self, property_id: PropertyId, ) -> Option<BuilderPropertyRef<'_>>
Reference the property, if it is present.
Sourcepub fn property_mut(
&mut self,
property_id: PropertyId,
) -> Option<BuilderPropertyMut<'_>>
pub fn property_mut( &mut self, property_id: PropertyId, ) -> Option<BuilderPropertyMut<'_>>
Modify the property, if it is present.
Sourcepub fn properties(&self) -> impl Iterator<Item = BuilderPropertyRef<'_>>
pub fn properties(&self) -> impl Iterator<Item = BuilderPropertyRef<'_>>
Iterate over the current properties.
The properties may not be sorted in the correct order if the builder has never built.
Sourcepub fn properties_mut(&mut self) -> impl Iterator<Item = BuilderPropertyMut<'_>>
pub fn properties_mut(&mut self) -> impl Iterator<Item = BuilderPropertyMut<'_>>
iterate over mutable references to the current properties.
Sourcepub fn capture_value<T>(&mut self, property_id: PropertyId) -> Option<T>where
T: VarValue,
pub fn capture_value<T>(&mut self, property_id: PropertyId) -> Option<T>where
T: VarValue,
Flags the property as captured and downcast the input value.
Unlike other property kinds you can capture values in the WidgetBuilder, note that the value may not
the final value, unless you are capturing on build.
Other property kinds can only be captured in WidgetBuilding as
their values strongly depend on the final when blocks that are only applied after building starts.
Sourcepub fn capture_value_or_else<T>(
&mut self,
property_id: PropertyId,
or_else: impl FnOnce() -> T,
) -> Twhere
T: VarValue,
pub fn capture_value_or_else<T>(
&mut self,
property_id: PropertyId,
or_else: impl FnOnce() -> T,
) -> Twhere
T: VarValue,
Flags the property as captured and downcast the input value, or calls or_else to generate the value.
Sourcepub fn capture_value_or_default<T>(&mut self, property_id: PropertyId) -> T
pub fn capture_value_or_default<T>(&mut self, property_id: PropertyId) -> T
Flags the property as captured and downcast the input value, or returns the default value.
Trait Implementations§
Source§impl Deref for WidgetBuilding
impl Deref for WidgetBuilding
Auto Trait Implementations§
impl Freeze for WidgetBuilding
impl !RefUnwindSafe for WidgetBuilding
impl Send for WidgetBuilding
impl !Sync for WidgetBuilding
impl !Unpin for WidgetBuilding
impl !UnwindSafe for WidgetBuilding
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<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