pub struct PanelList<D = DefaultPanelListData>where
D: PanelListData,{ /* private fields */ }
Expand description
Represents the final UiNodeList
in a panel layout node.
Panel widgets should wrap their children list 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 UiNodeList) -> Self
pub fn new(list: impl UiNodeList) -> 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 UiNodeList) -> Self
pub fn new_custom(list: impl UiNodeList) -> 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,
) -> (BoxedUiNodeList, Vec<Mutex<D>>, FrameValueKey<PxTransform>, Option<StateId<PanelListRange>>)
pub fn into_parts( self, ) -> (BoxedUiNodeList, Vec<Mutex<D>>, FrameValueKey<PxTransform>, Option<StateId<PanelListRange>>)
Into list and associated data.
sourcepub fn from_parts(
list: BoxedUiNodeList,
data: Vec<Mutex<D>>,
offset_key: FrameValueKey<PxTransform>,
info_id: Option<StateId<PanelListRange>>,
) -> Self
pub fn from_parts( list: BoxedUiNodeList, 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_node<R, F>(&mut self, index: usize, f: F) -> R
pub fn with_node<R, F>(&mut self, index: usize, f: F) -> R
Visit the specific node with associated data, panic if index
is out of bounds.
sourcepub fn for_each<F>(&mut self, f: F)
pub fn for_each<F>(&mut self, f: F)
Calls f
for each node in the list with the index and associated data.
sourcepub fn par_each<F>(&mut self, f: F)
pub fn par_each<F>(&mut self, f: F)
Calls f
for each node in the list with the index and associated data in parallel.
sourcepub fn par_fold_reduce<T, I, F, R>(
&mut self,
identity: I,
fold: F,
reduce: R,
) -> T
pub 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 with the index and associated data in parallel.
This method behaves the same as UiNodeList::par_fold_reduce
, with the added data.
sourcepub fn measure_each<F, S>(
&mut self,
wm: &mut WidgetMeasure,
measure: F,
fold_size: S,
) -> PxSize
pub 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, the inputs are the child index, node, data and the WidgetMeasure
.
sourcepub fn layout_each<F, S>(
&mut self,
wl: &mut WidgetLayout,
layout: F,
fold_size: S,
) -> PxSize
pub 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, the inputs are the child index, node, data and the WidgetLayout
.
sourcepub fn for_each_z_sorted(
&mut self,
f: impl FnMut(usize, &mut BoxedUiNode, &mut D),
)
pub fn for_each_z_sorted( &mut self, f: impl FnMut(usize, &mut BoxedUiNode, &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> UiNodeList for PanelList<D>where
D: PanelListData,
impl<D> UiNodeList for PanelList<D>where
D: PanelListData,
source§fn 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,
source§fn for_each<F>(&mut self, f: F)
fn for_each<F>(&mut self, f: F)
f
for each node in the list with the index, sequentially.source§fn par_each<F>(&mut self, f: F)
fn par_each<F>(&mut self, f: F)
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
fn par_fold_reduce<T, I, F, R>(&mut self, identity: I, fold: F, reduce: R) -> T
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. Read moresource§fn boxed(self) -> BoxedUiNodeList
fn boxed(self) -> BoxedUiNodeList
self
boxed, or itself if it is already boxed.source§fn drain_into(&mut self, vec: &mut Vec<BoxedUiNode>)
fn drain_into(&mut self, vec: &mut Vec<BoxedUiNode>)
vec
.source§fn deinit_all(&mut self)
fn deinit_all(&mut self)
source§fn info_all(&mut self, info: &mut WidgetInfoBuilder)
fn info_all(&mut self, info: &mut WidgetInfoBuilder)
source§fn event_all(&mut self, update: &EventUpdate)
fn event_all(&mut self, update: &EventUpdate)
source§fn update_all(
&mut self,
updates: &WidgetUpdates,
observer: &mut dyn UiNodeListObserver,
)
fn update_all( &mut self, updates: &WidgetUpdates, observer: &mut dyn UiNodeListObserver, )
source§fn render_all(&mut self, frame: &mut FrameBuilder)
fn render_all(&mut self, frame: &mut FrameBuilder)
source§fn render_update_all(&mut self, update: &mut FrameUpdate)
fn render_update_all(&mut self, update: &mut FrameUpdate)
source§fn 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
source§fn 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
source§fn downcast_unbox<L: UiNodeList>(self) -> Result<L, BoxedUiNodeList>where
Self: Sized,
fn downcast_unbox<L: UiNodeList>(self) -> Result<L, BoxedUiNodeList>where
Self: Sized,
source§fn actual_type_id(&self) -> TypeId
fn actual_type_id(&self) -> TypeId
type_id
of the unboxed list.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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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