zng::widget::node

Trait UiNodeListObserver

source
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§

source

fn inserted(&mut self, index: usize)

Called when a node is inserted at index.

source

fn removed(&mut self, index: usize)

Called when a node is removed from index.

source

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.

source

fn reset(&mut self)

Called when large or unspecified changes happen to the list.

source

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)

source§

fn is_reset_only(&self) -> bool

source§

fn reset(&mut self)

source§

fn inserted(&mut self, index: usize)

source§

fn removed(&mut self, index: usize)

source§

fn moved(&mut self, removed_index: usize, inserted_index: usize)

source§

impl UiNodeListObserver for bool

Sets to true for any change.

source§

fn is_reset_only(&self) -> bool

source§

fn reset(&mut self)

source§

fn inserted(&mut self, _: usize)

source§

fn removed(&mut self, _: usize)

source§

fn moved(&mut self, _: usize, _: usize)

source§

impl UiNodeListObserver for ()

Does nothing.

source§

fn is_reset_only(&self) -> bool

source§

fn reset(&mut self)

source§

fn inserted(&mut self, _: usize)

source§

fn removed(&mut self, _: usize)

source§

fn moved(&mut self, _: usize, _: usize)

Implementors§