Skip to content

nicopap/cuicui_layout

Repository files navigation

Bevy tracking Latest version MIT/Apache 2.0 The Book

The Cuicui Framework

The cuicui framework is a collection of rust crates made for bevy.

The Chirpunk demo

For some reasons, the Cyberpunk main menu has become the 7GUI of bevy, so here is the Cyberpunk main menu using cuicui_layout_bevy_ui.

cuicui_layout_2_2023-08-28.mp4
❗ Hot reloading disclaimer ❗

Chirp hot reloading with bevy_ui components (ie: using cuicui_layout_bevy_ui) is broken due to bevyengine/bevy#9621. You may want to work on a local patched version of bevy. A workaround will probably be provided in cuicui 0.10.

The code for the video demo can be read in the chirpunk example.

Hello World

A tinny example to get you an idea of what you can do with cuicui.

Shows a blue box with cyan outline in the center of the screen:

use bevy::prelude::*;
use cuicui_layout::{dsl, LayoutRootCamera};
use cuicui_layout_bevy_ui::UiDsl as Dsl;

fn main() {
    // Do not forget to add cuicui_layout_bevy_{ui,sprite}::Plugin
    App::new()
        .add_plugins((DefaultPlugins, cuicui_layout_bevy_ui::Plugin))
        .add_systems(Startup, setup)
        .run();
}
fn setup(mut commands: Commands) {
    // Use LayoutRootCamera to mark a camera as the screen boundaries.
    commands.spawn((Camera2dBundle::default(), LayoutRootCamera));

    dsl! { &mut commands.spawn_empty(),
        // Use screen_root to follow the screen's boundaries
        Entity(row screen_root) {
            // Stuff is centered by default.
            Entity(row margin(9.) border(5, Color::CYAN) bg(Color::NAVY)) {
                Entity(ui("Hello world!"))
            }
        }
    };
}

Running examples

Use the cargo run --bin command to list possible examples, and run them.

We do this because it allows us to have different dependencies between examples.

Using cuicui_layout

The Usage section of the book is a good starting point.

MOAR DOCS!!

For the lazy

Please read the Usage section of the book. Skip to the code if you don't care for explanations.

Change log

See the ./CHANGELOG.md file.

Version matrix

bevy latest supporting version
0.12 0.12.0
0.11 0.10.2
0.10 0.3.0

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

The dumbest and simplest layouting algorithm for bevy

Topics

Resources

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages