AdoptiveNode

Struct AdoptiveNode 

Source
pub struct AdoptiveNode { /* private fields */ }
Expand description

Represents a node setup to dynamically swap child.

Any property node can be made adoptive by wrapping it with this node.

Implementations§

Source§

impl AdoptiveNode

Source

pub fn new(create: impl FnOnce(AdoptiveChildNode) -> UiNode) -> Self

Create the adoptive node, the AdoptiveChildNode must be used as the child of the created node.

The created node is assumed to not be inited.

Source

pub fn try_new<E>( create: impl FnOnce(AdoptiveChildNode) -> Result<UiNode, E>, ) -> Result<Self, E>

Create the adoptive node using a closure that can fail.

The created node is assumed to not be inited.

Source

pub fn replace_child(&mut self, new_child: UiNode) -> UiNode

Replaces the child node.

Returns the previous child, the initial child is a UiNode::nil.

§Panics

Panics if is_inited.

Source

pub fn is_inited(&self) -> bool

Returns true if this node is inited.

Source

pub fn into_parts(self) -> (Arc<Mutex<UiNode>>, UiNode)

Into child reference and node.

§Panics

Panics if is_inited.

Source

pub fn from_parts(child: Arc<Mutex<UiNode>>, node: UiNode) -> Self

From parts, assumes the nodes are not inited and that child is the actual child of node.

Trait Implementations§

Source§

impl UiNodeImpl for AdoptiveNode

Source§

fn init(&mut self)

Initializes the node in a new UI context. Read more
Source§

fn deinit(&mut self)

Deinitializes the node in the current UI context. Read more
Source§

fn children_len(&self) -> usize

Gets the current count of children nodes.
Source§

fn with_child(&mut self, index: usize, visitor: &mut dyn FnMut(&mut UiNode))

Visit a child node by index. If the index is not valid visitor is not called. Read more
Source§

fn is_list(&self) -> bool

Gets if the node represents a list of other nodes. Read more
Source§

fn for_each_child(&mut self, visitor: &mut dyn FnMut(usize, &mut UiNode))

Call visitor for each child node of self, one at a time. Read more
Source§

fn try_for_each_child( &mut self, visitor: &mut dyn FnMut(usize, &mut UiNode) -> ControlFlow<BoxAnyVarValue>, ) -> ControlFlow<BoxAnyVarValue>

Call visitor for each child node of self, one at a time, with control flow. Read more
Source§

fn par_each_child(&mut self, visitor: &(dyn Fn(usize, &mut UiNode) + Sync))

Calls visitor for each child node in parallel. Read more
Source§

fn par_fold_reduce( &mut self, identity: BoxAnyVarValue, fold: &(dyn Fn(BoxAnyVarValue, usize, &mut UiNode) -> BoxAnyVarValue + Sync), reduce: &(dyn Fn(BoxAnyVarValue, BoxAnyVarValue) -> BoxAnyVarValue + Sync), ) -> BoxAnyVarValue

Calls fold for each child node in parallel, with fold accumulators produced by cloning identity, then merges the folded results using reduce to produce the final value also in parallel. Read more
Source§

fn info(&mut self, info: &mut WidgetInfoBuilder)

Builds widget info. Read more
Source§

fn event(&mut self, update: &EventUpdate)

Receives an event. Read more
Source§

fn update(&mut self, updates: &WidgetUpdates)

Receives variable and other non-event updates. Read more
Source§

fn update_list( &mut self, updates: &WidgetUpdates, observer: &mut dyn UiNodeListObserver, )

Does update and if the node is a list notifies list changes to the observer.
Source§

fn measure(&mut self, wm: &mut WidgetMeasure) -> PxSize

Computes the widget size given the contextual layout metrics without actually updating the widget layout. Read more
Source§

fn measure_list( &mut self, wm: &mut WidgetMeasure, measure: &(dyn Fn(usize, &mut UiNode, &mut WidgetMeasure) -> PxSize + Sync), fold_size: &(dyn Fn(PxSize, PxSize) -> PxSize + Sync), ) -> PxSize

If the node is_list measure each child and combine the size using fold_size. Read more
Source§

fn layout(&mut self, wl: &mut WidgetLayout) -> PxSize

Computes the widget layout given the contextual layout metrics. Read more
Source§

fn layout_list( &mut self, wl: &mut WidgetLayout, layout: &(dyn Fn(usize, &mut UiNode, &mut WidgetLayout) -> PxSize + Sync), fold_size: &(dyn Fn(PxSize, PxSize) -> PxSize + Sync), ) -> PxSize

If the node is_list layout each child and combine the size using fold_size. Read more
Source§

fn render(&mut self, frame: &mut FrameBuilder)

Generates render instructions and updates transforms and hit-test areas. Read more
Source§

fn render_list( &mut self, frame: &mut FrameBuilder, render: &(dyn Fn(usize, &mut UiNode, &mut FrameBuilder) + Sync), )

If the node is_list render each child. Read more
Source§

fn render_update(&mut self, update: &mut FrameUpdate)

Updates values in the last generated frame. Read more
Source§

fn render_update_list( &mut self, update: &mut FrameUpdate, render_update: &(dyn Fn(usize, &mut UiNode, &mut FrameUpdate) + Sync), )

If the node is_list render_update each child. Read more
Source§

fn as_widget(&mut self) -> Option<&mut dyn WidgetUiNodeImpl>

Gets the node implementation as a WidgetUiNodeImpl, if the node defines a widget instance scope.

Auto Trait Implementations§

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.

Source§

impl<T> Instrument for T

Source§

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

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

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

impl<U> IntoUiNode for U
where U: UiNodeImpl,

Source§

fn into_node(self) -> UiNode

Instantiate the UI node.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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