pub struct PanelList<D = DefaultPanelListData>where
D: PanelListData,{ /* private fields */ }Expand description
Represents the final UI list in a panel layout node.
Panel widgets should wrap their children node on this type to support Z-index sorting and to easily track associated item data.
By default the associated item data is a DefaultPanelListData that represents the offset of each item inside the panel,
but it can be any type that implements PanelListData. The panel list default render implementation uses this data
to position the children widgets. Note that you must commit_data changes to this data at the end of a layout pass.
Panel widgets can also mark the list using track_info_range to implement getter properties such as is_odd or
is_even.
Implementations§
Source§impl PanelList<DefaultPanelListData>
impl PanelList<DefaultPanelListData>
Sourcepub fn new(list: impl IntoUiNode) -> Self
pub fn new(list: impl IntoUiNode) -> Self
New from list and default data.
Source§impl<D> PanelList<D>where
D: PanelListData,
impl<D> PanelList<D>where
D: PanelListData,
Sourcepub fn new_custom(list: impl IntoUiNode) -> Self
pub fn new_custom(list: impl IntoUiNode) -> Self
New from list and custom data type.
Sourcepub fn track_info_range(
self,
info_id: impl Into<StateId<PanelListRange>>,
) -> Self
pub fn track_info_range( self, info_id: impl Into<StateId<PanelListRange>>, ) -> Self
Enable tracking the first and last child in the parent widget info.
The info is set in the info_id, it can be used to identify the children widgets
that are the panel children as the info tree may track extra widgets as children
when they are set by other properties, like background.
Sourcepub fn into_parts(
self,
) -> (UiNode, Vec<Mutex<D>>, FrameValueKey<PxTransform>, Option<StateId<PanelListRange>>)
pub fn into_parts( self, ) -> (UiNode, Vec<Mutex<D>>, FrameValueKey<PxTransform>, Option<StateId<PanelListRange>>)
Into list and associated data.
Sourcepub fn from_parts(
list: UiNode,
data: Vec<Mutex<D>>,
offset_key: FrameValueKey<PxTransform>,
info_id: Option<StateId<PanelListRange>>,
) -> Self
pub fn from_parts( list: UiNode, data: Vec<Mutex<D>>, offset_key: FrameValueKey<PxTransform>, info_id: Option<StateId<PanelListRange>>, ) -> Self
Sourcepub fn info_id(&self) -> Option<StateId<PanelListRange>>
pub fn info_id(&self) -> Option<StateId<PanelListRange>>
Gets the ID set on the parent widget info if track_info_range was enabled.
Sourcepub fn with_child<R>(
&mut self,
index: usize,
visitor: impl FnOnce(&mut UiNode, &mut D) -> R,
) -> R
pub fn with_child<R>( &mut self, index: usize, visitor: impl FnOnce(&mut UiNode, &mut D) -> R, ) -> R
Call visitor with a exclusive reference to the child node and associated data identified by index.
Panics if the index is out of bounds.
Sourcepub fn for_each_child(
&mut self,
visitor: impl FnMut(usize, &mut UiNode, &mut D),
)
pub fn for_each_child( &mut self, visitor: impl FnMut(usize, &mut UiNode, &mut D), )
Call visitor for each child node of self, one at a time.
The closure parameters are the child index, the child and the associated data.
Sourcepub fn try_for_each_child<B: VarValue>(
&mut self,
visitor: &mut dyn FnMut(usize, &mut UiNode, &mut D) -> ControlFlow<B>,
) -> ControlFlow<B>
pub fn try_for_each_child<B: VarValue>( &mut self, visitor: &mut dyn FnMut(usize, &mut UiNode, &mut D) -> ControlFlow<B>, ) -> ControlFlow<B>
Call visitor for each child node of self, one at a time, with control flow.
The closure parameters are the child index, the child and the associated data.
Sourcepub fn par_each_child(
&mut self,
visitor: impl Fn(usize, &mut UiNode, &mut D) + Sync,
)where
D: Sync,
pub fn par_each_child(
&mut self,
visitor: impl Fn(usize, &mut UiNode, &mut D) + Sync,
)where
D: Sync,
Calls visitor for each child node in parallel.
The closure parameters are the child index, the child and the associated data.
Sourcepub fn par_fold_reduce<T>(
&mut self,
identity: T,
fold: impl Fn(T, usize, &mut UiNode, &mut D) -> T + Sync,
reduce: impl Fn(T, T) -> T + Send + Sync,
) -> Twhere
T: VarValue,
pub fn par_fold_reduce<T>(
&mut self,
identity: T,
fold: impl Fn(T, usize, &mut UiNode, &mut D) -> T + Sync,
reduce: impl Fn(T, T) -> T + Send + Sync,
) -> Twhere
T: VarValue,
Calls fold for each child node with associated data in parallel, with fold accumulators produced by cloning
identity, then merges the folded results using reduce to produce the final value also in parallel.
The reduce call is associative, the order is preserved in the result.
Sourcepub fn measure_list(
&mut self,
wm: &mut WidgetMeasure,
measure: impl Fn(usize, &mut UiNode, &mut D, &mut WidgetMeasure) -> PxSize + Sync,
fold_size: impl Fn(PxSize, PxSize) -> PxSize + Sync,
) -> PxSize
pub fn measure_list( &mut self, wm: &mut WidgetMeasure, measure: impl Fn(usize, &mut UiNode, &mut D, &mut WidgetMeasure) -> PxSize + Sync, fold_size: impl Fn(PxSize, PxSize) -> PxSize + Sync, ) -> PxSize
Call measure for each node with associated data and combines the final size using fold_size.
Sourcepub fn layout_list(
&mut self,
wl: &mut WidgetLayout,
layout: impl Fn(usize, &mut UiNode, &mut D, &mut WidgetLayout) -> PxSize + Sync,
fold_size: impl Fn(PxSize, PxSize) -> PxSize + Sync,
) -> PxSize
pub fn layout_list( &mut self, wl: &mut WidgetLayout, layout: impl Fn(usize, &mut UiNode, &mut D, &mut WidgetLayout) -> PxSize + Sync, fold_size: impl Fn(PxSize, PxSize) -> PxSize + Sync, ) -> PxSize
Call layout for each node with associated data and combines the final size using fold_size.
Sourcepub fn render_list(
&mut self,
frame: &mut FrameBuilder,
render: impl Fn(usize, &mut UiNode, &mut D, &mut FrameBuilder) + Sync,
)
pub fn render_list( &mut self, frame: &mut FrameBuilder, render: impl Fn(usize, &mut UiNode, &mut D, &mut FrameBuilder) + Sync, )
Call render for each node with associated data.
Note that the PanelListData child offset and reference frame are already pushed when render is called.
Sourcepub fn render_update_list(
&mut self,
update: &mut FrameUpdate,
render_update: impl Fn(usize, &mut UiNode, &mut D, &mut FrameUpdate) + Sync,
)
pub fn render_update_list( &mut self, update: &mut FrameUpdate, render_update: impl Fn(usize, &mut UiNode, &mut D, &mut FrameUpdate) + Sync, )
Call render_update for each node with associated data.
Note that the PanelListData child offset and reference frame are already pushed when render_update is called.
Sourcepub fn for_each_z_sorted(
&mut self,
visitor: impl FnMut(usize, &mut UiNode, &mut D),
)
pub fn for_each_z_sorted( &mut self, visitor: impl FnMut(usize, &mut UiNode, &mut D), )
Iterate over the list in the Z order.
Sourcepub fn commit_data(&mut self) -> PanelListDataChanges
pub fn commit_data(&mut self) -> PanelListDataChanges
Sourcepub fn offset_key(&self) -> FrameValueKey<PxTransform>
pub fn offset_key(&self) -> FrameValueKey<PxTransform>
Key used to define reference frames for each item.
The default implementation of render_all uses this key and the item index.
Trait Implementations§
Source§impl<D> UiNodeImpl for PanelList<D>where
D: PanelListData,
impl<D> UiNodeImpl for PanelList<D>where
D: PanelListData,
Source§fn children_len(&self) -> usize
fn children_len(&self) -> usize
Source§fn try_for_each_child(
&mut self,
visitor: &mut dyn FnMut(usize, &mut UiNode) -> ControlFlow<BoxAnyVarValue>,
) -> ControlFlow<BoxAnyVarValue>
fn try_for_each_child( &mut self, visitor: &mut dyn FnMut(usize, &mut UiNode) -> ControlFlow<BoxAnyVarValue>, ) -> ControlFlow<BoxAnyVarValue>
Source§fn par_each_child(&mut self, visitor: &(dyn Fn(usize, &mut UiNode) + Sync))
fn par_each_child(&mut self, visitor: &(dyn Fn(usize, &mut UiNode) + Sync))
visitor for each child node in parallel. Read moreSource§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
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
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 moreSource§fn info(&mut self, info: &mut WidgetInfoBuilder)
fn info(&mut self, info: &mut WidgetInfoBuilder)
Source§fn event(&mut self, update: &EventUpdate)
fn event(&mut self, update: &EventUpdate)
Source§fn update(&mut self, updates: &WidgetUpdates)
fn update(&mut self, updates: &WidgetUpdates)
Source§fn update_list(
&mut self,
updates: &WidgetUpdates,
observer: &mut dyn UiNodeListObserver,
)
fn update_list( &mut self, updates: &WidgetUpdates, observer: &mut dyn UiNodeListObserver, )
update and if the node is a list notifies list changes to the observer.Source§fn measure(&mut self, wm: &mut WidgetMeasure) -> PxSize
fn measure(&mut self, wm: &mut WidgetMeasure) -> PxSize
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
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
Source§fn layout(&mut self, wl: &mut WidgetLayout) -> PxSize
fn layout(&mut self, wl: &mut WidgetLayout) -> PxSize
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
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
Source§fn render(&mut self, frame: &mut FrameBuilder)
fn render(&mut self, frame: &mut FrameBuilder)
Source§fn render_update(&mut self, update: &mut FrameUpdate)
fn render_update(&mut self, update: &mut FrameUpdate)
Source§fn as_widget(&mut self) -> Option<&mut dyn WidgetUiNodeImpl>
fn as_widget(&mut self) -> Option<&mut dyn WidgetUiNodeImpl>
WidgetUiNodeImpl, if the node defines a widget instance scope.Source§fn render_list(
&mut self,
frame: &mut FrameBuilder,
render: &(dyn Fn(usize, &mut UiNode, &mut FrameBuilder) + Sync),
)
fn render_list( &mut self, frame: &mut FrameBuilder, render: &(dyn Fn(usize, &mut UiNode, &mut FrameBuilder) + Sync), )
Source§fn render_update_list(
&mut self,
update: &mut FrameUpdate,
render_update: &(dyn Fn(usize, &mut UiNode, &mut FrameUpdate) + Sync),
)
fn render_update_list( &mut self, update: &mut FrameUpdate, render_update: &(dyn Fn(usize, &mut UiNode, &mut FrameUpdate) + Sync), )
Auto Trait Implementations§
impl<D> Freeze for PanelList<D>
impl<D = DefaultPanelListData> !RefUnwindSafe for PanelList<D>
impl<D> Send for PanelList<D>
impl<D = DefaultPanelListData> !Sync for PanelList<D>
impl<D> Unpin for PanelList<D>where
D: Unpin,
impl<D = DefaultPanelListData> !UnwindSafe for PanelList<D>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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