[][src]Trait kas::WidgetChildren

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

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.

Loading content...

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]

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]

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 DragHandle[src]

impl WidgetChildren for Filler[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: FormattableText + 'static> WidgetChildren for Label<T>[src]

impl<T: FormattableText + 'static> WidgetChildren for MessageBox<T>[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...