SortingList

Struct SortingList 

Source
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

Source

pub fn new( list: impl IntoUiNode, sort: impl Fn(&mut UiNode, &mut UiNode) -> Ordering + Send + 'static, ) -> SortingList

New from list and sort function.

Source

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.

Source

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.

Source

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

Source§

fn children_len(&self) -> usize

Gets the current count of children nodes.
Source§

fn with_child(&mut self, index: usize, visitor: &mut dyn FnMut(&mut UiNode))

Visit a child node by index. If the index is not valid visitor is not called. Read more
Source§

fn is_list(&self) -> bool

Gets if the node represents a list of other nodes. Read more
Source§

fn for_each_child(&mut self, visitor: &mut dyn FnMut(usize, &mut UiNode))

Call visitor for each child node of self, one at a time. Read more
Source§

fn try_for_each_child( &mut self, visitor: &mut dyn FnMut(usize, &mut UiNode) -> ControlFlow<BoxAnyVarValue>, ) -> ControlFlow<BoxAnyVarValue>

Call visitor for each child node of self, one at a time, with control flow. Read more
Source§

fn par_each_child(&mut self, visitor: &(dyn Fn(usize, &mut UiNode) + Sync))

Calls visitor for each child node in parallel. Read more
Source§

fn par_fold_reduce( &mut self, identity: BoxAnyVarValue, fold: &(dyn Fn(BoxAnyVarValue, usize, &mut UiNode) -> BoxAnyVarValue + Sync), _: &(dyn Fn(BoxAnyVarValue, BoxAnyVarValue) -> BoxAnyVarValue + Sync), ) -> BoxAnyVarValue

Calls 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 more
Source§

fn init(&mut self)

Initializes the node in a new UI context. Read more
Source§

fn deinit(&mut self)

Deinitializes the node in the current UI context. Read more
Source§

fn info(&mut self, info: &mut WidgetInfoBuilder)

Builds widget info. Read more
Source§

fn event(&mut self, update: &EventUpdate)

Receives an event. Read more
Source§

fn update(&mut self, updates: &WidgetUpdates)

Receives variable and other non-event updates. Read more
Source§

fn update_list( &mut self, updates: &WidgetUpdates, observer: &mut dyn UiNodeListObserver, )

Does update and if the node is a list notifies list changes to the observer.
Source§

fn measure(&mut self, wm: &mut WidgetMeasure) -> Size2D<Px, Px>

Computes the widget size given the contextual layout metrics without actually updating the widget layout. Read more
Source§

fn measure_list( &mut self, wm: &mut WidgetMeasure, measure: &(dyn Fn(usize, &mut UiNode, &mut WidgetMeasure) -> Size2D<Px, Px> + Sync), fold_size: &(dyn Fn(Size2D<Px, Px>, Size2D<Px, Px>) -> Size2D<Px, Px> + Sync), ) -> Size2D<Px, Px>

If the node is_list measure each child and combine the size using fold_size. Read more
Source§

fn layout(&mut self, wl: &mut WidgetLayout) -> Size2D<Px, Px>

Computes the widget layout given the contextual layout metrics. Read more
Source§

fn layout_list( &mut self, wl: &mut WidgetLayout, layout: &(dyn Fn(usize, &mut UiNode, &mut WidgetLayout) -> Size2D<Px, Px> + Sync), fold_size: &(dyn Fn(Size2D<Px, Px>, Size2D<Px, Px>) -> Size2D<Px, Px> + Sync), ) -> Size2D<Px, Px>

If the node is_list layout each child and combine the size using fold_size. Read more
Source§

fn render(&mut self, frame: &mut FrameBuilder)

Generates render instructions and updates transforms and hit-test areas. Read more
Source§

fn render_list( &mut self, frame: &mut FrameBuilder, render: &(dyn Fn(usize, &mut UiNode, &mut FrameBuilder) + Sync), )

If the node is_list render each child. Read more
Source§

fn render_update(&mut self, update: &mut FrameUpdate)

Updates values in the last generated frame. Read more
Source§

fn render_update_list( &mut self, update: &mut FrameUpdate, render_update: &(dyn Fn(usize, &mut UiNode, &mut FrameUpdate) + Sync), )

If the node is_list render_update each child. Read more
Source§

fn as_widget(&mut self) -> Option<&mut (dyn WidgetUiNodeImpl + 'static)>

Gets the node implementation as a WidgetUiNodeImpl, if the node defines a widget instance scope.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<U> IntoUiNode for U
where U: UiNodeImpl,

Source§

fn into_node(self) -> UiNode

Instantiate the UI node.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more