pub struct EditableUiVecRef(/* private fields */);Expand description
Represents a sender to an EditableUiVec.
Implementations§
Source§impl EditableUiVecRef
impl EditableUiVecRef
Sourcepub fn alive(&self) -> bool
pub fn alive(&self) -> bool
Returns true if the EditableUiVec still exists.
Sourcepub fn insert(&self, index: usize, widget: impl IntoUiNode)
pub fn insert(&self, index: usize, widget: impl IntoUiNode)
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 IntoUiNode)
pub fn push(&self, widget: impl IntoUiNode)
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 UiNode) -> bool + Send + 'static,
)
pub fn retain( &self, predicate: impl FnMut(&mut UiNode) -> 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 EditableUiVecRef
impl Clone for EditableUiVecRef
Source§fn clone(&self) -> EditableUiVecRef
fn clone(&self) -> EditableUiVecRef
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 EditableUiVecRef
impl !RefUnwindSafe for EditableUiVecRef
impl Send for EditableUiVecRef
impl Sync for EditableUiVecRef
impl Unpin for EditableUiVecRef
impl !UnwindSafe for EditableUiVecRef
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,
§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