Trait kas::layout::AutoLayout
source · pub trait AutoLayout {
// Required methods
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§
sourcefn size_rules(&mut self, size_mgr: SizeMgr<'_>, axis: AxisInfo) -> SizeRules
fn size_rules(&mut self, size_mgr: SizeMgr<'_>, axis: AxisInfo) -> SizeRules
Get size rules for the given axis
This functions identically to Layout::size_rules
.
sourcefn set_rect(&mut self, mgr: &mut ConfigMgr<'_>, rect: Rect)
fn set_rect(&mut self, mgr: &mut ConfigMgr<'_>, rect: Rect)
Set size and position
This functions identically to Layout::set_rect
.
sourcefn find_id(&mut self, coord: Coord) -> Option<WidgetId>
fn find_id(&mut self, coord: Coord) -> Option<WidgetId>
Translate a coordinate to a WidgetId
This functions identically to Layout::find_id
.
sourcefn draw(&mut self, draw: DrawMgr<'_>)
fn draw(&mut self, draw: DrawMgr<'_>)
Draw a widget and its children
This functions identically to Layout::draw
.