pub struct SortingList { /* private fields */ }
Expand description
Represents a sorted view into an UiNode::is_list
.
The underlying list is not changed, a sorted index map is used to iterate the underlying list.
The sorting is lazy and gets invalidated on every init and every time there are changes observed in update_list
.
Methods measure_list
, layout_list
, render
, for_each_child
and par_each_child
are the only that iterate sorted. Method
with_child
uses the sort index. Method update_list
notifies a reset if there is any change in the list or sorting.
Other methods delegate to the unsorted list.
Implementations§
Source§impl SortingList
impl SortingList
Sourcepub fn new(
list: impl IntoUiNode,
sort: impl Fn(&mut UiNode, &mut UiNode) -> Ordering + Send + 'static,
) -> Self
pub fn new( list: impl IntoUiNode, sort: impl Fn(&mut UiNode, &mut UiNode) -> Ordering + Send + 'static, ) -> Self
New from list and sort function.
Sourcepub fn list(&mut self) -> &mut UiNode
pub fn list(&mut self) -> &mut UiNode
Mutable borrow the inner list.
You must call invalidate_sort
if any modification is done to the list.
Sourcepub fn invalidate_sort(&mut self)
pub fn invalidate_sort(&mut self)
Invalidate the sort, the list will resort on the nest time the sorted positions are needed.
Note that you can also invalidate sort from the inside using SORTING_LIST::invalidate_sort
.
Sourcepub fn chain(self, other: impl IntoUiNode) -> UiNode
pub fn chain(self, other: impl IntoUiNode) -> UiNode
Create a list chain node.
See UiNode::chain
for more details.
Trait Implementations§
Source§impl UiNodeImpl for SortingList
impl UiNodeImpl for SortingList
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),
_: &(dyn Fn(BoxAnyVarValue, BoxAnyVarValue) -> BoxAnyVarValue + Sync),
) -> BoxAnyVarValue
fn par_fold_reduce( &mut self, identity: BoxAnyVarValue, fold: &(dyn Fn(BoxAnyVarValue, usize, &mut UiNode) -> BoxAnyVarValue + Sync), _: &(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_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(&mut self, update: &mut FrameUpdate)
fn render_update(&mut self, update: &mut FrameUpdate)
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), )
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.Auto Trait Implementations§
impl Freeze for SortingList
impl !RefUnwindSafe for SortingList
impl Send for SortingList
impl !Sync for SortingList
impl Unpin for SortingList
impl !UnwindSafe for SortingList
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