You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rust bindings for Clay, a UI layout library written in C.
Usage
# Cargo.toml
[dependencies]
clay-layout = "0.4"
Example usage:
use clay_layout::{fixed,Clay,Declaration};fnmain(){// Create the clay instanceletmut clay = Clay::new((800.,600.).into());// Begin the layoutletmut 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 layoutlet render_commands = clay.end();for command in render_commands {println!("Id of the element: {}", command.id);// Note: Ids are in fact numbers generated by Clayprintln!("Bounding box: {:?}", command.bounding_box);println!("Type and config: {:?}", command.config);}}
Examples
Examples can be found in the examples/ directory. They can be ran using cargo:
cargo run --example basic_rectangle
cargo run --example raylib_renderer --features raylib-renderer
Build bindings
Notice that building the bindings is only required if you update the clay.h
To build bindings you need to use the generate_bindings script.
It needs bindgen installed as a CLI, you can install it with cargo install bindgen.
Calling it will use the clay.h in the project root, or any clay.h file provided with CLAY_HEADER_PATH.
Using the clay header it will generate src/bindings/bindings.rs and src/bindings/bindings_debug.rs.
About
Rust bindings for Clay, a UI layout library written in C.