macro_rules! float {
( $( $ee:expr ),* ) => { ... };
( $( $ee:expr ),+ , ) => { ... };
}
Expand description
Make a Float
widget
§Syntax
Collection :
float!
[
Items?]
Items :
(Item,
)* Item,
?
§Stand-alone usage
When used as a stand-alone macro, float! [/* ... */]
is just syntactic sugar
for Float::new(kas::collection! [/* ... */])
.
In this case, Item may be:
- A string literal (interpreted as a label widget), optionally followed by
an
align
orpack
method call - An expression yielding an object implementing
Widget<Data = _A>
In case all Item instances are a string literal, the data type of the
float!
widget will be ()
; otherwise the data type of the widget is _A
where _A
is a generic type parameter of the widget.
§Usage within widget layout syntax
When called within widget layout syntax, float!
may be evaluated as a
recursive macro and the result does not have a specified type, except that
methods map_any
, align
and pack
are supported via emulation.
In this case, Item is evaluated using widget layout syntax. This is broadly similar to the above with a couple of exceptions:
- Supported layout macros do not need to be imported to the module scope
- An Item may be a
#[widget]
field of the widget
§Example
let my_widget = kas_widgets::float! [
"one".pack(AlignHints::TOP_LEFT),
"two".pack(AlignHints::BOTTOM_RIGHT),
"some text\nin the\nbackground"
];
§Cost
Warning: each child beyond the first requires a new draw pass. The number of passes used can have a substantial performance impact, potentially more on GPU communication than CPU usage.