[][src]Trait kas::WidgetCore

pub trait WidgetCore: Debug {
    fn core_data(&self) -> &CoreData;
fn widget_name(&self) -> &'static str;
fn as_widget(&self) -> &dyn Widget;
fn as_widget_mut(&mut self) -> &mut dyn Widget;
fn len(&self) -> usize;
fn get(&self, index: usize) -> Option<&dyn Widget>;
fn get_mut(&mut self, index: usize) -> Option<&mut dyn Widget>;
fn walk(&self, f: &mut dyn FnMut(&dyn Widget));
fn walk_mut(&mut self, f: &mut dyn FnMut(&mut dyn Widget)); fn id(&self) -> WidgetId { ... }
fn rect(&self) -> Rect { ... }
fn find(&self, id: WidgetId) -> Option<&dyn Widget> { ... }
fn find_mut(&mut self, id: WidgetId) -> Option<&mut dyn Widget> { ... } }

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.

Loading content...

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].

Loading content...

Implementations on Foreign Types

impl<M> WidgetCore for Box<dyn Handler<Msg = M>>[src]

Loading content...

Implementors

impl WidgetCore for Filler[src]

impl WidgetCore for Label[src]

impl WidgetCore for MessageBox[src]

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

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

impl<H: 'static> WidgetCore for EditBox<H>[src]

impl<M: Clone + Debug> WidgetCore for TextButton<M>[src]

impl<OT: 'static> WidgetCore for CheckBox<OT>[src]

impl<OT: 'static> WidgetCore for CheckBoxBare<OT>[src]

impl<OT: 'static> WidgetCore for RadioBox<OT>[src]

impl<OT: 'static> WidgetCore for RadioBoxBare<OT>[src]

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

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

Loading content...