Struct zng_app::widget::node::EditableUiNodeListRef
source · pub struct EditableUiNodeListRef(/* private fields */);
Expand description
Represents a sender to an EditableUiNodeList
.
Implementations§
source§impl EditableUiNodeListRef
impl EditableUiNodeListRef
sourcepub fn alive(&self) -> bool
pub fn alive(&self) -> bool
Returns true
if the EditableUiNodeList
still exists.
sourcepub fn insert(&self, index: usize, widget: impl UiNode)
pub fn insert(&self, index: usize, widget: impl UiNode)
Request an update for the insertion of the widget
.
The index
is resolved after all remove
requests, if it is out-of-bounds the widget is pushed.
The widget
will be inserted, inited and the info tree updated.
sourcepub fn push(&self, widget: impl UiNode)
pub fn push(&self, widget: impl UiNode)
Request an update for the insertion of the widget
at the end of the list.
The widget will be pushed after all insert
requests.
The widget
will be inserted, inited and the info tree updated.
sourcepub fn remove(&self, id: impl Into<WidgetId>)
pub fn remove(&self, id: impl Into<WidgetId>)
Request an update for the removal of the widget identified by id
.
The widget will be deinited, dropped and the info tree will update. Nothing happens if the widget is not found.
sourcepub fn retain(
&self,
predicate: impl FnMut(&mut BoxedUiNode) -> bool + Send + 'static,
)
pub fn retain( &self, predicate: impl FnMut(&mut BoxedUiNode) -> bool + Send + 'static, )
Request a filtered mass removal of nodes in the list.
Each node not retained will be deinited, dropped and the info tree will update if any was removed.
Note that the predicate
may be called on the same node multiple times or called in any order.
sourcepub fn move_index(&self, remove_index: usize, insert_index: usize)
pub fn move_index(&self, remove_index: usize, insert_index: usize)
Request a widget remove and re-insert.
If the remove_index
is out of bounds nothing happens, if the insert_index
is out-of-bounds
the widget is pushed to the end of the vector, if remove_index
and insert_index
are equal nothing happens.
Move requests happen after all other requests.
sourcepub fn move_id(
&self,
id: impl Into<WidgetId>,
get_move_to: fn(_: usize, _: usize) -> usize,
)
pub fn move_id( &self, id: impl Into<WidgetId>, get_move_to: fn(_: usize, _: usize) -> usize, )
Request a widget move, the widget is searched by id
, if found get_move_to
id called with the index of the widget and length
of the vector, it must return the index the widget is inserted after it is removed.
If the widget is not found nothing happens, if the returned index is the same nothing happens, if the returned index is out-of-bounds the widget if pushed to the end of the vector.
Move requests happen after all other requests.
§Examples
If the widget vectors is layout as a vertical stack to move the widget up by one stopping at the top:
items.move_id("my-widget", |i, _len| i.saturating_sub(1));
And to move down stopping at the bottom:
items.move_id("my-widget", |i, _len| i.saturating_add(1));
Note that if the returned index overflows the length the widget is pushed as the last item.
The length can be used for implementing wrapping move down:
items.move_id("my-widget", |i, len| {
let next = i + 1;
if next < len { next } else { 0 }
});
Trait Implementations§
source§impl Clone for EditableUiNodeListRef
impl Clone for EditableUiNodeListRef
source§fn clone(&self) -> EditableUiNodeListRef
fn clone(&self) -> EditableUiNodeListRef
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for EditableUiNodeListRef
impl !RefUnwindSafe for EditableUiNodeListRef
impl Send for EditableUiNodeListRef
impl Sync for EditableUiNodeListRef
impl Unpin for EditableUiNodeListRef
impl !UnwindSafe for EditableUiNodeListRef
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§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