[][src]Trait kas::WidgetChildren

pub trait WidgetChildren: WidgetCore {
    fn len(&self) -> usize;
fn get(&self, index: usize) -> Option<&dyn WidgetConfig>;
fn get_mut(&mut self, index: usize) -> Option<&mut dyn WidgetConfig>; fn is_ancestor_of(&self, id: WidgetId) -> bool { ... }
fn find(&self, id: WidgetId) -> Option<&dyn WidgetConfig> { ... }
fn find_mut(&mut self, id: WidgetId) -> Option<&mut dyn WidgetConfig> { ... }
fn walk(&self, f: &mut dyn FnMut(&dyn WidgetConfig)) { ... }
fn walk_mut(&mut self, f: &mut dyn FnMut(&mut dyn WidgetConfig)) { ... } }

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

fn len(&self) -> usize

Get the number of child widgets

fn get(&self, index: usize) -> Option<&dyn WidgetConfig>

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 WidgetConfig>

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.

Loading content...

Provided methods

fn is_ancestor_of(&self, id: WidgetId) -> bool

Check whether id is a descendant

This function assumes that id is a valid widget.

fn find(&self, id: WidgetId) -> Option<&dyn WidgetConfig>

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.

fn find_mut(&mut self, id: WidgetId) -> Option<&mut dyn WidgetConfig>

Find a child widget by identifier

This requires that the widget tree has already been configured by ManagerState::configure.

fn walk(&self, f: &mut dyn FnMut(&dyn WidgetConfig))

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 WidgetConfig))

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.

Loading content...

Implementations on Foreign Types

impl<M: 'static> WidgetChildren for Box<dyn Widget<Msg = M>>[src]

impl<M: 'static> WidgetChildren for Box<dyn Menu<Msg = M>>[src]

Loading content...

Implementors

impl WidgetChildren for AccelLabel[src]

impl WidgetChildren for DragHandle[src]

impl WidgetChildren for Filler[src]

impl WidgetChildren for Label[src]

impl WidgetChildren for MessageBox[src]

impl<D: Directional> WidgetChildren for ScrollBar<D>[src]

impl<D: Directional, W: Widget> WidgetChildren for List<D, W>[src]

impl<D: Directional, W: Widget> WidgetChildren for Splitter<D, W>[src]

impl<D: Directional, W: Menu> WidgetChildren for MenuBar<D, W>[src]

impl<D: Directional, W: Menu> WidgetChildren for SubMenu<D, W>[src]

impl<G: 'static> WidgetChildren for EditBox<G>[src]

impl<M: 'static> WidgetChildren for CheckBox<M>[src]

impl<M: 'static> WidgetChildren for CheckBoxBare<M>[src]

impl<M: 'static> WidgetChildren for MenuToggle<M>[src]

impl<M: 'static> WidgetChildren for RadioBox<M>[src]

impl<M: 'static> WidgetChildren for RadioBoxBare<M>[src]

impl<M: Clone + Debug + 'static> WidgetChildren for ComboBox<M>[src]

impl<M: Clone + Debug + 'static> WidgetChildren for MenuEntry<M>[src]

impl<M: Clone + Debug + 'static> WidgetChildren for TextButton<M>[src]

impl<M: Debug + 'static> WidgetChildren for Separator<M>[src]

impl<T: SliderType, D: Directional> WidgetChildren for Slider<T, D>[src]

impl<W: Widget + 'static> WidgetChildren for Window<W>[src]

impl<W: Widget> WidgetChildren for Frame<W>[src]

impl<W: Widget> WidgetChildren for MenuFrame<W>[src]

impl<W: Widget> WidgetChildren for ScrollRegion<W>[src]

impl<W: Widget> WidgetChildren for Stack<W>[src]

Loading content...