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§
sourcefn with_node<R, F>(&mut self, index: usize, f: F) -> Rwhere
F: FnOnce(&mut BoxedUiNode) -> R,
fn with_node<R, F>(&mut self, index: usize, f: F) -> Rwhere
F: FnOnce(&mut BoxedUiNode) -> R,
sourcefn for_each<F>(&mut self, f: F)
fn for_each<F>(&mut self, f: F)
Calls f
for each node in the list with the index, sequentially.
sourcefn par_fold_reduce<T, I, F, R>(&mut self, identity: I, fold: F, reduce: R) -> T
fn par_fold_reduce<T, I, F, R>(&mut self, identity: I, fold: F, reduce: R) -> T
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
},
)
sourcefn boxed(self) -> BoxedUiNodeList
fn boxed(self) -> BoxedUiNodeList
Gets self
boxed, or itself if it is already boxed.
sourcefn drain_into(&mut self, vec: &mut Vec<BoxedUiNode>)
fn drain_into(&mut self, vec: &mut Vec<BoxedUiNode>)
Move all nodes into vec
.
Provided Methods§
sourcefn init_all(&mut self)
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.
sourcefn deinit_all(&mut self)
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.
sourcefn info_all(&mut self, info: &mut WidgetInfoBuilder)
fn info_all(&mut self, info: &mut WidgetInfoBuilder)
Rebuilds the list in a context, all node info is rebuilt.
sourcefn update_all(
&mut self,
updates: &WidgetUpdates,
observer: &mut dyn UiNodeListObserver,
)
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.
sourcefn event_all(&mut self, update: &EventUpdate)
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.
sourcefn measure_each<F, S>(
&mut self,
wm: &mut WidgetMeasure,
measure: F,
fold_size: S,
) -> PxSize
fn measure_each<F, S>( &mut self, wm: &mut WidgetMeasure, measure: F, fold_size: S, ) -> PxSize
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.
sourcefn layout_each<F, S>(
&mut self,
wl: &mut WidgetLayout,
layout: F,
fold_size: S,
) -> PxSize
fn layout_each<F, S>( &mut self, wl: &mut WidgetLayout, layout: F, fold_size: S, ) -> PxSize
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.
sourcefn render_all(&mut self, frame: &mut FrameBuilder)
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.
sourcefn render_update_all(&mut self, update: &mut FrameUpdate)
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.
sourcefn downcast_unbox<L: UiNodeList>(self) -> Result<L, BoxedUiNodeList>where
Self: Sized,
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
.
sourcefn actual_type_id(&self) -> TypeId
fn actual_type_id(&self) -> TypeId
Returns the type_id
of the unboxed list.