Expand description

Make cuicui_layout useable with bevy’s UI library (bevy_ui).

Import this crate’s UiDsl and use cuicui_dsl::dsl! with it to have a fully working UI library.

It contains:

Note that unlike cuicui_layout_bevy_ui, this uses a Y axis down coordinate space, (like bevy_sprite)

Therefore, if you happen to convert your layouts from bevy_ui to bevy_sprite (or vis-versa) what was on top will be at the bottom and vis-versa.

Example

use bevy::prelude::*;
use cuicui_layout::{dsl, LayoutRootCamera, Rule};
// dsl! will use this crate's extensions to DslBundle
// if you import this      vvvvvvvvvvvv
use cuicui_layout_bevy_ui::UiDsl as Dsl;
use cuicui_layout::dsl_functions::{px, pct};

cmds.spawn((Camera2dBundle::default(), LayoutRootCamera));

let title_card = serv.load::<Image>("logo.png");
let menu_buttons = [ "CONTINUE", "NEW GAME" ];
let bg = serv.load("background.png");
let board = serv.load("board.png");
let button = serv.load("button.png");

dsl! {
    &mut cmds.spawn_empty(),
    // Notice the `image` argument                     vvvvvvvvvv
    Root(row screen_root main_margin(100.) align_start image(&bg)) {
        Menu(column width(px(310)) main_margin(40.) fill_main_axis image(&board)) {
            TitleCard(ui(title_card) height(px(100)) width(pct(100)))
            code(let cmds) {
                for n in &menu_buttons {
                    let name = format!("{n} button");
                    dsl!(cmds, Entity(ui(*n) named(name) image(&button) height(px(30))))
                }
            }
        }
    }
};

Re-exports

Modules

Structs

Functions