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
impl PanelList
sourcepub fn new(list: impl UiNodeList) -> PanelList
pub fn new(list: impl UiNodeList) -> PanelList
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) -> PanelList<D>
pub fn new_custom(list: impl UiNodeList) -> PanelList<D>
New from list
and custom data type.
sourcepub fn track_info_range(
self,
info_id: impl Into<StateId<PanelListRange>>,
) -> PanelList<D>
pub fn track_info_range( self, info_id: impl Into<StateId<PanelListRange>>, ) -> PanelList<D>
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,
) -> (Box<dyn UiNodeListBoxed>, Vec<Mutex<RawMutex, D>>, FrameValueKey<PxTransform>, Option<StateId<PanelListRange>>)
pub fn into_parts( self, ) -> (Box<dyn UiNodeListBoxed>, Vec<Mutex<RawMutex, D>>, FrameValueKey<PxTransform>, Option<StateId<PanelListRange>>)
Into list and associated data.
sourcepub fn from_parts(
list: Box<dyn UiNodeListBoxed>,
data: Vec<Mutex<RawMutex, D>>,
offset_key: FrameValueKey<PxTransform>,
info_id: Option<StateId<PanelListRange>>,
) -> PanelList<D>
pub fn from_parts( list: Box<dyn UiNodeListBoxed>, data: Vec<Mutex<RawMutex, D>>, offset_key: FrameValueKey<PxTransform>, info_id: Option<StateId<PanelListRange>>, ) -> PanelList<D>
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,
) -> Size2D<Px, Px>
pub fn measure_each<F, S>( &mut self, wm: &mut WidgetMeasure, measure: F, fold_size: S, ) -> Size2D<Px, Px>
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,
) -> Size2D<Px, Px>
pub fn layout_each<F, S>( &mut self, wl: &mut WidgetLayout, layout: F, fold_size: S, ) -> Size2D<Px, Px>
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 Box<dyn UiNodeBoxed>, &mut D),
)
pub fn for_each_z_sorted( &mut self, f: impl FnMut(usize, &mut Box<dyn UiNodeBoxed>, &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 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 drain_into(&mut self, vec: &mut Vec<Box<dyn UiNodeBoxed>>)
fn drain_into(&mut self, vec: &mut Vec<Box<dyn UiNodeBoxed>>)
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,
) -> Size2D<Px, Px>
fn measure_each<F, S>( &mut self, wm: &mut WidgetMeasure, measure: F, fold_size: S, ) -> Size2D<Px, Px>
source§fn layout_each<F, S>(
&mut self,
wl: &mut WidgetLayout,
layout: F,
fold_size: S,
) -> Size2D<Px, Px>
fn layout_each<F, S>( &mut self, wl: &mut WidgetLayout, layout: F, fold_size: S, ) -> Size2D<Px, Px>
source§fn downcast_unbox<L>(self) -> Result<L, Box<dyn UiNodeListBoxed>>where
L: UiNodeList,
Self: Sized,
fn downcast_unbox<L>(self) -> Result<L, Box<dyn UiNodeListBoxed>>where
L: UiNodeList,
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§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> 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