layout

Attribute Macro layout 

Source
#[layout]
Expand description

Provide a default implementation of the Layout trait for a widget

The widget macro uses this attribute to implement MacroDefinedLayout for the widget, then adjusts the default implementations of each Layout method to call the corresponding MacroDefinedLayout method.

This attribute may only appear after the widget attribute (it is not a stand-alone macro). It does not need to be imported (it is resolved by widget).

§Layout

Widget layout may be specified by implementing the Layout trait and/or with a #[layout(...)] attribute (this must appear after #[widget] on the type definition). The latter accepts the following syntax, where Layout is any of the below.

Using the #[layout] attribute will also generate a corresponding implementation of Tile::nav_next, with a couple of exceptions (where macro-time analysis is insufficient to implement this method).

Column, Row, List AlignedColumn, AlignedRow, Grid, Float, Frame :
   These stand-alone macros are explicitly supported in this position.\

Single :
   self . Member
   A named child: self.foo (more precisely, this matches any expression starting self, and uses &mut (#expr)).

WidgetConstructor :
   Expr
   An expression yielding a widget, e.g. Label::new("Hello world"). The result must be an object of some type W: Widget<Data = ()>. This widget will be stored in a hidden field and is accessible through Tile::get_child but does not receive input data.

LabelLit :
   StrLit
   A string literal generates a label widget, e.g. “Hello world”. This is an internal type without text wrapping.

Additional syntax rules (not layout items):

Member :
   Ident | Index
   The name of a struct field or an index into a tuple struct.