Enum zng_app::widget::node::UiNodeOp

source ·
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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.

§desired_size: &'a mut PxSize

Return value, the widget’s desired size after measure.

§

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.

§final_size: &'a mut PxSize

Return value, the widget’s final size after layout.

§

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

The UiNode::render_update.

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§

source§

impl<'a> UiNodeOp<'a>

source

pub fn mtd(&self) -> UiNodeOpMethod

Gets the operation without the associated data.

source

pub fn reborrow(&mut self) -> UiNodeOp<'_>

Reborrow the op.

Trait Implementations§

source§

impl<'a> Debug for UiNodeOp<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> StateValue for T
where T: Any + Send + Sync,