Trait zng_app::widget::node::UiNodeList

source ·
pub trait UiNodeList: UiNodeListBoxed {
Show 21 methods // Required methods fn with_node<R, F>(&mut self, index: usize, f: F) -> R where F: FnOnce(&mut BoxedUiNode) -> R; fn for_each<F>(&mut self, f: F) where F: FnMut(usize, &mut BoxedUiNode); fn par_each<F>(&mut self, f: F) where F: Fn(usize, &mut BoxedUiNode) + Send + Sync; fn par_fold_reduce<T, I, F, R>( &mut self, identity: I, fold: F, reduce: R, ) -> T where T: Send + 'static, I: Fn() -> T + Send + Sync, F: Fn(T, usize, &mut BoxedUiNode) -> T + Send + Sync, R: Fn(T, T) -> T + Send + Sync; fn len(&self) -> usize; fn boxed(self) -> BoxedUiNodeList; fn drain_into(&mut self, vec: &mut Vec<BoxedUiNode>); // Provided methods fn is_empty(&self) -> bool { ... } fn init_all(&mut self) { ... } fn deinit_all(&mut self) { ... } fn info_all(&mut self, info: &mut WidgetInfoBuilder) { ... } fn update_all( &mut self, updates: &WidgetUpdates, observer: &mut dyn UiNodeListObserver, ) { ... } fn event_all(&mut self, update: &EventUpdate) { ... } fn measure_each<F, S>( &mut self, wm: &mut WidgetMeasure, measure: F, fold_size: S, ) -> PxSize where F: Fn(usize, &mut BoxedUiNode, &mut WidgetMeasure) -> PxSize + Send + Sync, S: Fn(PxSize, PxSize) -> PxSize + Send + Sync, Self: Sized { ... } fn layout_each<F, S>( &mut self, wl: &mut WidgetLayout, layout: F, fold_size: S, ) -> PxSize where F: Fn(usize, &mut BoxedUiNode, &mut WidgetLayout) -> PxSize + Send + Sync, S: Fn(PxSize, PxSize) -> PxSize + Send + Sync, Self: Sized { ... } fn render_all(&mut self, frame: &mut FrameBuilder) { ... } fn render_update_all(&mut self, update: &mut FrameUpdate) { ... } fn downcast_unbox<L: UiNodeList>(self) -> Result<L, BoxedUiNodeList> where Self: Sized { ... } fn actual_type_id(&self) -> TypeId { ... } fn as_any(&mut self) -> &mut dyn Any where Self: Sized { ... } fn op(&mut self, op: UiNodeOp<'_>) where Self: Sized { ... }
}
Expand description

Represents a list of UI nodes.

There are multiple node list types, panel implementers receive children as impl UiNodeList and usually wrap it in a PanelList.

UI node lists delegate the UiNode method for each node in the list, potentially in parallel. Panel implementers call the *_all methods to delegate, they can also use the match_node_list to implement delegation. The trait also offers for_each, par_each and other methods for direct access to the nodes, both sequentially and in parallel.

Note that trying to access the nodes before init will probably not work, the ArcNodeList type is used by properties that request impl UiNodeList input, so captured property lists will always be empty before init.

Required Methods§

source

fn with_node<R, F>(&mut self, index: usize, f: F) -> R
where F: FnOnce(&mut BoxedUiNode) -> R,

Visit the specific node.

§Panics

Panics if index is out of bounds.

source

fn for_each<F>(&mut self, f: F)
where F: FnMut(usize, &mut BoxedUiNode),

Calls f for each node in the list with the index, sequentially.

source

fn par_each<F>(&mut self, f: F)
where F: Fn(usize, &mut BoxedUiNode) + Send + Sync,

Calls f for each node in the list with the index, in parallel.

source

fn par_fold_reduce<T, I, F, R>(&mut self, identity: I, fold: F, reduce: R) -> T
where T: Send + 'static, I: Fn() -> T + Send + Sync, F: Fn(T, usize, &mut BoxedUiNode) -> T + Send + Sync, R: Fn(T, T) -> T + Send + Sync,

Calls fold for each node in the list in parallel, with fold accumulators produced by identity, then merges the folded results using reduce to produce the final value also in parallel.

If reduce is associative the order is preserved in the result.

§Example

This example will collect the node indexes in order:

list.par_fold_reduce(
    Vec::new,
    |mut v, i, _| {
        v.push(i);
        v
    },
    |mut a, b| {
        a.extend(b);
        a
    },
)
source

fn len(&self) -> usize

Gets the current number of nodes in the list.

source

fn boxed(self) -> BoxedUiNodeList

Gets self boxed, or itself if it is already boxed.

source

fn drain_into(&mut self, vec: &mut Vec<BoxedUiNode>)

Move all nodes into vec.

Provided Methods§

source

fn is_empty(&self) -> bool

Returns true if the list does not contain any nodes.

source

fn init_all(&mut self)

Init the list in a context, all nodes are also inited.

The behavior of some list implementations depend on this call, manually initializing nodes is an error.

source

fn deinit_all(&mut self)

Deinit the list in a context, all nodes are also deinited.

The behavior of some list implementations depend on this call, manually deiniting nodes is an error.

source

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

Rebuilds the list in a context, all node info is rebuilt.

source

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

Receive updates for the list in a context, all nodes are also updated.

The behavior of some list implementations depend on this call, manually updating nodes is an error.

source

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

Receive an event for the list in a context, all nodes are also notified.

The behavior of some list implementations depend on this call, manually notifying nodes is an error.

source

fn measure_each<F, S>( &mut self, wm: &mut WidgetMeasure, measure: F, fold_size: S, ) -> PxSize
where F: Fn(usize, &mut BoxedUiNode, &mut WidgetMeasure) -> PxSize + Send + Sync, S: Fn(PxSize, PxSize) -> PxSize + Send + Sync, Self: Sized,

Call measure for each node and combines the final size using fold_size.

The call to measure can be parallel if Parallel::LAYOUT is enabled.

source

fn layout_each<F, S>( &mut self, wl: &mut WidgetLayout, layout: F, fold_size: S, ) -> PxSize
where F: Fn(usize, &mut BoxedUiNode, &mut WidgetLayout) -> PxSize + Send + Sync, S: Fn(PxSize, PxSize) -> PxSize + Send + Sync, Self: Sized,

Call layout for each node and combines the final size using fold_size.

The call to layout can be parallel if Parallel::LAYOUT is enabled.

source

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

Render all nodes.

The correct behavior of some list implementations depend on this call, using for_each to render nodes can break it.

source

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

Render all nodes.

The correct behavior of some list implementations depend on this call, using for_each to render nodes can break it.

source

fn downcast_unbox<L: UiNodeList>(self) -> Result<L, BoxedUiNodeList>
where Self: Sized,

Downcast to L, if self is L or is a BoxedUiNodeList that is L.

source

fn actual_type_id(&self) -> TypeId

Returns the type_id of the unboxed list.

source

fn as_any(&mut self) -> &mut dyn Any
where Self: Sized,

Access to mut dyn Any methods.

source

fn op(&mut self, op: UiNodeOp<'_>)
where Self: Sized,

Runs the UiNodeOp.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl UiNodeList for Option<BoxedUiNode>

source§

fn with_node<R, F>(&mut self, index: usize, f: F) -> R
where F: FnOnce(&mut BoxedUiNode) -> R,

source§

fn for_each<F>(&mut self, f: F)
where F: FnMut(usize, &mut BoxedUiNode),

source§

fn par_each<F>(&mut self, f: F)
where F: Fn(usize, &mut BoxedUiNode) + Send + Sync,

source§

fn par_fold_reduce<T, I, F, R>(&mut self, identity: I, fold: F, _: R) -> T
where T: Send, I: Fn() -> T + Send + Sync, F: Fn(T, usize, &mut BoxedUiNode) -> T + Send + Sync, R: Fn(T, T) -> T + Send + Sync,

source§

fn len(&self) -> usize

source§

fn boxed(self) -> BoxedUiNodeList

source§

fn drain_into(&mut self, vec: &mut Vec<BoxedUiNode>)

source§

impl UiNodeList for Vec<BoxedUiNode>

source§

fn with_node<R, F>(&mut self, index: usize, f: F) -> R
where F: FnOnce(&mut BoxedUiNode) -> R,

source§

fn for_each<F>(&mut self, f: F)
where F: FnMut(usize, &mut BoxedUiNode),

source§

fn par_each<F>(&mut self, f: F)
where F: Fn(usize, &mut BoxedUiNode) + Send + Sync,

source§

fn par_fold_reduce<T, I, F, R>(&mut self, identity: I, fold: F, reduce: R) -> T
where T: Send, I: Fn() -> T + Send + Sync, F: Fn(T, usize, &mut BoxedUiNode) -> T + Send + Sync, R: Fn(T, T) -> T + Send + Sync,

source§

fn len(&self) -> usize

source§

fn boxed(self) -> BoxedUiNodeList

source§

fn drain_into(&mut self, vec: &mut Vec<BoxedUiNode>)

source§

impl UiNodeList for Vec<BoxedUiNodeList>

source§

fn with_node<R, F>(&mut self, index: usize, f: F) -> R
where F: FnOnce(&mut BoxedUiNode) -> R,

source§

fn for_each<F>(&mut self, f: F)
where F: FnMut(usize, &mut BoxedUiNode),

source§

fn par_each<F>(&mut self, f: F)
where F: Fn(usize, &mut BoxedUiNode) + Send + Sync,

source§

fn par_fold_reduce<T, I, F, R>(&mut self, identity: I, fold: F, reduce: R) -> T
where T: Send + 'static, I: Fn() -> T + Send + Sync, F: Fn(T, usize, &mut BoxedUiNode) -> T + Send + Sync, R: Fn(T, T) -> T + Send + Sync,

source§

fn len(&self) -> usize

source§

fn boxed(self) -> BoxedUiNodeList

source§

fn drain_into(&mut self, vec: &mut Vec<BoxedUiNode>)

source§

fn is_empty(&self) -> bool

source§

fn init_all(&mut self)

source§

fn deinit_all(&mut self)

source§

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

source§

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

source§

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

source§

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

source§

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

Implementors§