[−][src]Trait kas::WidgetChildren
Listing of a widget's children
This trait is part of the Widget
family and is derived by
derive(Widget)
unless #[widget(children = noauto)]
is used.
Dynamic widgets must implement this trait manually, since derive(Widget)
cannot currently handle fields like Vec<SomeWidget>
.
Whenever the number of child widgets changes or child widgets are replaced,
one must send TkAction::Reconfigure
.
(TODO: this is slow. Find an option for partial reconfigures. This requires
better widget identifiers; see #91.)
Required methods
pub fn first_id(&self) -> WidgetId
[src]
Get the first identifier of self or any children
Widget identifiers are assigned sequentially by depth-first-search,
children before parents. Any widget thus has a range of identifiers,
from the first assigned to any descendent (or self) to its own
(WidgetCore::id
). This method must return the first identifier.
pub fn len(&self) -> usize
[src]
Get the number of child widgets
pub fn get(&self, index: usize) -> Option<&dyn WidgetConfig>
[src]
Get a reference to a child widget by index, or None
if the index is
out of bounds.
For convenience, Index<usize>
is implemented via this method.
Required: index < self.len()
.
pub fn get_mut(&mut self, index: usize) -> Option<&mut dyn WidgetConfig>
[src]
Mutable variant of get
Warning: directly adjusting a widget without requiring reconfigure or
redraw may break the UI. If a widget is replaced, a reconfigure must
be requested. This can be done via Manager::send_action
.
This method may be removed in the future.
Provided methods
pub fn record_first_id(&mut self, _id: WidgetId)
[src]
Record first identifier
This is called during WidgetConfig::configure_recurse
with the first
identifier. This may be used to implement WidgetChildren::first_id
,
although in many cases the first identifier can be read directly from
the first child. This method has a default implementation doing nothing.
This method should only be called from configure_recurse
.
pub fn is_ancestor_of(&self, id: WidgetId) -> bool
[src]
Check whether id
is a descendant
This function assumes that id
is a valid widget.
pub fn find(&self, id: WidgetId) -> Option<&dyn WidgetConfig>
[src]
Find a child widget by identifier
This requires that the widget tree has already been configured by
event::ManagerState::configure
.
If the widget is disabled, this returns None
without recursing children.
pub fn find_mut(&mut self, id: WidgetId) -> Option<&mut dyn WidgetConfig>
[src]
Find a child widget by identifier
This requires that the widget tree has already been configured by
ManagerState::configure
.
pub fn walk<F: FnMut(&dyn WidgetConfig)>(&self, f: F) where
Self: Sized,
[src]
Self: Sized,
Walk through all widgets, calling f
once on each.
This walk is iterative (nonconcurrent), depth-first, and always calls
f
on self after walking through all children.
pub fn walk_mut<F: FnMut(&mut dyn WidgetConfig)>(&mut self, f: F) where
Self: Sized,
[src]
Self: Sized,
Walk through all widgets, calling f
once on each.
This walk is iterative (nonconcurrent), depth-first, and always calls
f
on self after walking through all children.