Struct zng::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 dummy() -> EditableUiNodeListRef
pub fn dummy() -> EditableUiNodeListRef
New reference to no list.
alive
is always false for the returned list.
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 Box<dyn UiNodeBoxed>) -> bool + Send + 'static,
)
pub fn retain( &self, predicate: impl FnMut(&mut Box<dyn UiNodeBoxed>) -> 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> 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> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for 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> 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