#[non_exhaustive]pub enum UiNodeOp<'a> {
Init,
Deinit,
Info {
info: &'a mut WidgetInfoBuilder,
},
Event {
update: &'a EventUpdate,
},
Update {
updates: &'a WidgetUpdates,
},
Measure {
wm: &'a mut WidgetMeasure,
desired_size: &'a mut PxSize,
},
Layout {
wl: &'a mut WidgetLayout,
final_size: &'a mut PxSize,
},
Render {
frame: &'a mut FrameBuilder,
},
RenderUpdate {
update: &'a mut FrameUpdate,
},
}
Expand description
Represents a node operation in a match_node
.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Init
The UiNode::init
.
Initialize the node in a new UI context.
Common init operations are subscribing to variables and events and initializing data.
You can use WIDGET
to subscribe events and vars, the subscriptions live until the widget is deinited.
This operation can be called again after a Deinit
.
Deinit
The UiNode::deinit
.
Deinitialize the node in the current UI context.
Common deinit operations include dropping allocations and handlers.
Init
can be called again after this.
Info
The UiNode::info
.
Build widget info.
This operation is called every time there are structural changes in the UI tree such as a node added or removed, you
can also request an info rebuild using WIDGET.update_info
.
Only nodes in widgets that requested info rebuild and nodes in their ancestors receive this call. Other
widgets reuse their info in the new info tree. The widget’s latest built info is available in WIDGET.info
.
Note that info rebuild has higher priority over event, update, layout and render, this means that if you set a variable and request info update the next info rebuild will still observe the old variable value, you can work around this issue by only requesting info rebuild after the variable updates.
Fields
info: &'a mut WidgetInfoBuilder
Info builder.
Event
The UiNode::event
.
Receive an event.
Every call to this operation is for a single update of a single event type, you can listen to events
by subscribing to then on Init
and using the Event::on
method during this operation to detect the event.
Note that events sent to descendant nodes also flow through the match node and are automatically delegated if
you don’t manually delegate. Automatic delegation happens after the operation is handled, you can call
child.event
to manually delegate before handling.
When an ancestor handles the event before the descendants this is a preview handling, so match nodes handle event operations in preview by default.
Fields
update: &'a EventUpdate
Event update args and targets.
Update
The UiNode::update
.
Receive variable and other non-event updates.
Calls to this operation aggregate all updates that happen in the last pass, multiple variables can be new at the same time.
You can listen to variable updates by subscribing to then on Init
and using the Var::get_new
method during this operation
to receive the new values.
Common update operations include reacting to variable changes to generate an intermediary value
for layout or render. You can use WIDGET
to request layout and render. Note that for simple variables
that are used directly on layout or render you can subscribe to that operation directly, skipping update.
Fields
updates: &'a WidgetUpdates
Update targets
Measure
The UiNode::measure
.
Compute the widget size given the contextual layout metrics without actually updating the widget layout.
Implementers must set desired_size
to the same size Layout
sets for the given LayoutMetrics
, without
affecting the actual widget render. Panel widgets that implement some complex layouts need to get
the estimated widget size for a given layout context, this value is used to inform the actual Layout
call.
Nodes that implement Layout
must also implement this operation, the LAYOUT
context can be used to retrieve the metrics,
the WidgetMeasure
field can be used to communicate with the parent layout, such as disabling inline layout, the
PxSize
field must be set to the desired size given the layout context.
Fields
wm: &'a mut WidgetMeasure
Measure pass state.
Layout
The UiNode::layout
.
Compute the widget layout given the contextual layout metrics.
Implementers must also implement Measure
. This operation is called by the parent layout once the final constraints
for the frame are defined, the LAYOUT
context can be used to retrieve the constraints, the WidgetLayout
field
can be used to communicate layout metadata such as inline segments to the parent layout, the PxSize
field must be
set to the final size given the layout context.
Only widgets and ancestors that requested layout or use metrics that changed since last layout receive this call. Other widgets reuse the last layout result.
Nodes that render can also implement this operation just to observe the latest widget size, if changes are detected
the WIDGET.render
method can be used to request render.
Fields
wl: &'a mut WidgetLayout
Layout pass state.
Render
The UiNode::render
.
Generate render instructions and update transforms and hit-test areas.
This operation does not generate pixels immediately, it generates display items that are visual building block instructions for the renderer that will run after the window display list is built.
Only widgets and ancestors that requested render receive this call, other widgets reuse the display items and transforms from the last frame.
Fields
frame: &'a mut FrameBuilder
Frame builder.
RenderUpdate
Update values in the last generated frame.
Some display item values and transforms can be updated directly, without needing to rebuild the display list. All FrameBuilder
methods that accept a FrameValue<T>
input can be bound to an ID that can be used to update that value.
Only widgets and ancestors that requested render update receive this call. Note that if any other widget in the same window requests render all pending render update requests are upgraded to render requests.
Fields
update: &'a mut FrameUpdate
Fame updater.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for UiNodeOp<'a>
impl<'a> !RefUnwindSafe for UiNodeOp<'a>
impl<'a> Send for UiNodeOp<'a>
impl<'a> Sync for UiNodeOp<'a>
impl<'a> Unpin for UiNodeOp<'a>
impl<'a> !UnwindSafe for UiNodeOp<'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
§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