pub trait AutoLayout {
    // Required methods
    fn size_rules(&mut self, sizer: SizeCx<'_>, axis: AxisInfo) -> SizeRules;
    fn set_rect(&mut self, cx: &mut ConfigCx<'_>, rect: Rect);
    fn find_id(&mut self, coord: Coord) -> Option<Id>;
    fn draw(&mut self, draw: DrawCx<'_>);
}
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! {
    #[widget {
        Data = ();
        layout = "Example";
    }]
    struct Example {
        core: widget_core!(),
    }
    impl Layout for Self {
        fn size_rules(&mut self, sizer: SizeCx, axis: AxisInfo) -> SizeRules {
            let mut rules = kas::layout::AutoLayout::size_rules(self, sizer, axis);
            rules.set_stretch(Stretch::High);
            rules
        }
    }
}

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

Required Methods§

source

fn size_rules(&mut self, sizer: SizeCx<'_>, axis: AxisInfo) -> SizeRules

Get size rules for the given axis

This functions identically to Layout::size_rules.

source

fn set_rect(&mut self, cx: &mut ConfigCx<'_>, rect: Rect)

Set size and position

This functions identically to Layout::set_rect.

source

fn find_id(&mut self, coord: Coord) -> Option<Id>

Translate a coordinate to an Id

This functions identically to Layout::find_id.

source

fn draw(&mut self, draw: DrawCx<'_>)

Draw a widget and its children

This functions identically to Layout::draw.

Implementors§