[−][src]Trait kas::WidgetCore
Base widget functionality
This trait is almost always implemented via the
derive(Widget)
macro.
Required methods
fn core_data(&self) -> &CoreData
Get direct access to the CoreData
providing property storage.
fn widget_name(&self) -> &'static str
Get the name of the widget struct
fn as_widget(&self) -> &dyn Widget
Erase type
fn as_widget_mut(&mut self) -> &mut dyn Widget
Erase type
fn len(&self) -> usize
Get the number of child widgets
fn get(&self, index: usize) -> Option<&dyn Widget>
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()
.
fn get_mut(&mut self, index: usize) -> Option<&mut dyn Widget>
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.
fn walk(&self, f: &mut dyn FnMut(&dyn Widget))
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.
fn walk_mut(&mut self, f: &mut dyn FnMut(&mut dyn Widget))
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.
Provided methods
fn id(&self) -> WidgetId
Get the widget's numeric identifier
fn rect(&self) -> Rect
Get the widget's region, relative to its parent.
fn find(&self, id: WidgetId) -> Option<&dyn Widget>
Find a child widget by identifier
This requires that the widget tree has already been configured by
[crate::event::ManagerState::configure
].
fn find_mut(&mut self, id: WidgetId) -> Option<&mut dyn Widget>
Find a child widget by identifier
This requires that the widget tree has already been configured by
[crate::event::ManagerState::configure
].