#[layout]Expand description
Provide a default implementation of the Layout trait for a widget
This attribute macro may be used with the widget macro to provide
an implementation of Layout.
The #[layout] attribute must follow the widget attribute (it
is not a stand-alone macro).
It does not need to be imported (it is resolved by widget).
§Overriding provided fns
This macro implements MacroDefinedLayout for the widget and adjusts the
default implementations of each Layout method to call the corresponding
MacroDefinedLayout method. The user may instead provide a direct
implementation of any Layout method; this implementation may or may not
call the corresponding MacroDefinedLayout method.
§Layout syntax
Syntax is as follows:
Item: MemberItem Call* | LitItem Call* | MacroItem Call* | ExprItem
A single itemMemberItem:
self.Member
A reference to a field (e.g.self.labelorself.0); this field must be a#[widget].LitItem: StrLit
A string literal (e.g."Hello world"). This implicitly constructs a widget roughly equivalent toLabel<'static str>but without text wrapping.MacroItem: (
frame|column|row|list|float|grid)!MacroArgs
These layout macros are natively supported in layout syntax. They are equivalent to the like-named macros inkas::widgetsaside from name resolution.ExprItem: Expr
An expression yielding a widget, e.g.Label::new("Hello world"). The result must be an object of some typeW: Widget<Data = ()>. This widget will be stored in a hidden field and is accessible throughTile::get_childbut does not receive input data.
Call : (
.(align|pack|with_stretch|with_margin_style) MethodArgs)
A method call modifying layout.