clay-layout 0.4.0

Rust bindings for Clay, a UI layout library written in C.
Documentation
use clay_layout::{fixed, Clay, Declaration};

#[rustfmt::skip]
fn main() {
    // Create the clay instance
    let mut clay = Clay::new((800., 600.).into());

    // Begin the layout
    let mut clay = clay.begin::<(), ()>();

    // Adds a red rectangle with a corner radius of 5.
    // The Layout makes the rectangle have a width and height of 50.
    clay.with(&Declaration::new()
        .id(clay.id("red_rectangle"))
        .layout()
            .width(fixed!(50.))
            .height(fixed!(50.))
            .end()
        .corner_radius()
            .all(5.)
            .end()
        .background_color((0xFF, 0x00, 0x00).into()), |_| {},
    );

    // Return the list of render commands of your layout
    let render_commands = clay.end();

    for command in render_commands {
        println!("Id of the element: {}", command.id); // Note: Ids are in fact numbers generated by Clay
        println!("Bounding box: {:?}", command.bounding_box);
        println!("Type and config: {:?}", command.config);
    }
}