pub struct Conditional<C: RepeatedItemTree> { /* private fields */ }Implementations§
Source§impl<C: RepeatedItemTree + 'static> Conditional<C>
impl<C: RepeatedItemTree + 'static> Conditional<C>
Sourcepub fn track_model_changes(self: Pin<&Self>)
pub fn track_model_changes(self: Pin<&Self>)
Register the condition as a dependency of the current tracking scope (e.g. the redraw tracker) so it is notified when the condition changes.
Sourcepub fn track_instance_changes(self: Pin<&Self>)
pub fn track_instance_changes(self: Pin<&Self>)
Register the instance generation as a dependency of the current
tracking scope. Layout code uses this to re-evaluate only after
ensure_updated materializes instance changes.
Sourcepub fn ensure_updated(
self: Pin<&Self>,
init: impl Fn() -> VRc<ItemTreeVTable, C>,
) -> bool
pub fn ensure_updated( self: Pin<&Self>, init: impl Fn() -> VRc<ItemTreeVTable, C>, ) -> bool
Call this function to make sure that the model is updated.
The init function is the function to create a ItemTree.
Returns true if the instance was created or removed, or any child changed.
Sourcepub fn set_model_binding(&self, binding: impl Fn() -> bool + 'static)
pub fn set_model_binding(&self, binding: impl Fn() -> bool + 'static)
Set the model binding
Sourcepub fn visit(
self: Pin<&Self>,
order: TraversalOrder,
visitor: ItemVisitorRefMut<'_>,
) -> VisitChildrenResult
pub fn visit( self: Pin<&Self>, order: TraversalOrder, visitor: ItemVisitorRefMut<'_>, ) -> VisitChildrenResult
Call the visitor for the root of each instance. Also registers model dependencies so the current tracking scope (e.g. the redraw tracker) is notified when the condition changes.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Return the amount of instances (1 if the conditional is active, 0 otherwise)
Sourcepub fn range(&self) -> Range<usize>
pub fn range(&self) -> Range<usize>
Return the range of indices used by this Conditional.
Similar to Repeater::range, but the range is always [0, 1] if the Conditional is active.
Sourcepub fn instance_at(&self, index: usize) -> Option<VRc<ItemTreeVTable, C>>
pub fn instance_at(&self, index: usize) -> Option<VRc<ItemTreeVTable, C>>
Return the instance for the given model index.
The index should be within Self::range()
Sourcepub fn instances_vec(&self) -> Vec<VRc<ItemTreeVTable, C>>
pub fn instances_vec(&self) -> Vec<VRc<ItemTreeVTable, C>>
Returns a vector containing all instances