pub trait UiNodeListObserver {
// Required methods
fn inserted(&mut self, index: usize);
fn removed(&mut self, index: usize);
fn moved(&mut self, removed_index: usize, inserted_index: usize);
fn reset(&mut self);
fn is_reset_only(&self) -> bool;
}
Expand description
Represents an UiNodeList::update_all
observer that can be used to monitor widget insertion, removal and re-order.
All indexes are in the context of the previous changes, if you are maintaining a mirror vector simply using the
Vec::insert
and Vec::remove
commands in the same order as they are received should keep the vector in sync.
This trait is implemented for ()
, to not observe simply pass on a &mut ()
.
This trait is implemented for bool
, if any change happens the flag is set to true
.
Required Methods§
sourcefn moved(&mut self, removed_index: usize, inserted_index: usize)
fn moved(&mut self, removed_index: usize, inserted_index: usize)
Called when a node is removed from removed_index
and re-inserted at inserted_index
.
sourcefn is_reset_only(&self) -> bool
fn is_reset_only(&self) -> bool
Returns true if this observer does not use the item indexes.
When true you can use reset
to notify any changes.
This flag can be used by list implementers to enable parallel processing in more contexts, for example, chain lists cannot parallelize because indexes of subsequent lists are dependent on indexes of previous lists, but if the observer only needs to known that some change happened the chain list can still parallelize.
Implementations on Foreign Types§
source§impl UiNodeListObserver for (&mut dyn UiNodeListObserver, &mut dyn UiNodeListObserver)
impl UiNodeListObserver for (&mut dyn UiNodeListObserver, &mut dyn UiNodeListObserver)
source§impl UiNodeListObserver for bool
impl UiNodeListObserver for bool
Sets to true
for any change.
source§impl UiNodeListObserver for ()
impl UiNodeListObserver for ()
Does nothing.