pub trait AutoLayout {
    fn size_rules(&mut self, size_mgr: SizeMgr<'_>, axis: AxisInfo) -> SizeRules;
    fn set_rect(&mut self, mgr: &mut ConfigMgr<'_>, rect: Rect);
    fn find_id(&mut self, coord: Coord) -> Option<WidgetId>;
    fn draw(&mut self, draw: DrawMgr<'_>);
}
Expand description

Implementation generated by use of layout = .. property of #[widget]

This trait need not be implemented by the user, however it may be useful to adjust the result of an automatic implementation, for example:

use kas::prelude::*;

impl_scope! {
    #[derive(Debug)]
    #[widget {
        layout = "Example";
    }]
    struct Example {
        core: widget_core!(),
    }
    impl Layout for Self {
        fn size_rules(&mut self, size_mgr: SizeMgr, axis: AxisInfo) -> SizeRules {
            let mut rules = kas::layout::AutoLayout::size_rules(self, size_mgr, axis);
            rules.set_stretch(Stretch::High);
            rules
        }
    }
}

It is not recommended to import this trait since method names conflict with Layout.

Required Methods§

Get size rules for the given axis

This functions identically to Layout::size_rules.

Set size and position

This functions identically to Layout::set_rect.

Translate a coordinate to a WidgetId

This functions identically to Layout::find_id.

Draw a widget and its children

This functions identically to Layout::draw.

Implementors§