Skip to content

🧩 an immediate-mode gui library with a friendly API

License

Notifications You must be signed in to change notification settings

TylerLafayette/charm-ui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

charm-ui

Charm is a (WIP) lightweight immediate-mode GUI framework with a friendly API designed to be familiar.

Example

use charm_ui::{App, Color, Window};
use charm_ui::charms::VStack;
use charm_ui::component::Parameter;

pub struct Store {
    count: usize,
}

pub fn main() {
    let store = Store { count: 127 };
    let mut app = App::with_store(store);
    let mut window: Window<Store> = Window::with_size((1200, 600))
        .title("My first window")
        .background((255, 255, 127));

    window.set_root_component(
        VStack::new()
            .size(Parameter::constant((600, 400)))
            .padding(Parameter::constant((64, 16)))
            .background(Parameter::closure(|store: &Store| {
                (store.count as u8, 0, 0)
            }))
            .add_child(VStack::new().background(Parameter::constant((0, 255, 0)))),
    );

    app.add_window(window);
    app.run().unwrap();
}

Backends

Charm currently only supports SDL2, but the graphics layer is abstracted so more backends will be available shortly!

About

🧩 an immediate-mode gui library with a friendly API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages