Macro impl_layout_builders

Source
macro_rules! impl_layout_builders {
    ($ty:ident) => { ... };
}
Expand description

Implements LayoutExt and consuming size/flex-item builders for a generic widget with layout and flex_item fields.

The target type must have one type parameter and fields of types [LayoutStyle] and [FlexItemStyle], respectively.

ยงExamples

use std::marker::PhantomData;
use ailloli_ui_core::style::{FlexItemStyle, LayoutStyle, Length};
use ailloli_ui_widgets::impl_layout_builders;

struct Example<A> {
    layout: LayoutStyle,
    flex_item: FlexItemStyle,
    action: PhantomData<A>,
}
impl_layout_builders!(Example);
let widget = Example::<()> {
    layout: LayoutStyle::default(),
    flex_item: FlexItemStyle::default(),
    action: PhantomData,
}.width(80.0);
assert_eq!(widget.layout.width, Length::Px(80.0));