Making bevy entity hierarchies will never be this easy!
Use the [dsl!
] with any [DslBundle
] type to spawn entities using a
concise yet extensible and explicit syntax.
The [dsl!
] macro transforms an imperative API into a pure declarative syntax,
apt to make a functional programmer sight in satisfaction.
```rust
use cuicui_dsl::dsl;
fn setup(mut cmds: Commands, serv: Res
let bg: Handle<_> = serv.load("background.png"); let board: Handle<_> = serv.load("board.png");
dsl! { &mut cmds, row(screenroot, "root", mainmargin 100., alignstart, image &bg) { button("Button text 1", color Color::BLUE, width px(40), height pct(100)); button("Button text 2", color Color::RED, width px(40), height pct(100)); column("menu", fillmain_axis, image &board) { spawn("Title card", height px(100), width pct(100)); } } } } ```
This would be equivalent to the following:
Click to see the macro expansion code
```rust
fn setup(mut cmds: Commands, serv: Res
let bg = serv.load("background.png"); let board = serv.load("board.png");
let mut x =
let mut x = <Dsl>::default();
let mut leaf_cmd = cmds.to_cmds();
x.color(Color::RED);
x.width(px(40));
x.height(pct(100));
x.insert(&mut leaf_cmd);
x.button("Button text 2", &mut leaf_cmd);
let mut x = <Dsl>::default();
let mut leaf_cmd = cmds.to_cmds();
x.color(Color::BLUE);
x.width(px(40));
x.height(pct(100));
x.insert(&mut leaf_cmd);
x.button("Button text 1", &mut leaf_cmd);
let mut x = <Dsl>::default();
let mut node_cmd = cmds.to_cmds();
x.named("menu");
x.fill_main_axis();
x.image(&board);
x.column();
x.node(cmds.spawn_empty(), |cmds| {
let mut x = <Dsl>::default();
let mut leaf_cmd = cmds.to_cmds();
x.named("Title card");
x.height(px(100));
x.width(pct(100));
x.insert(&mut leaf_cmd);
});
}); } ```
Check the [dsl!
] macro documentation for a very detailed rundown of what it
is possible to do with it.