basic/
basic.rs

1use charm_ui::charms::VStack;
2use charm_ui::component::Parameter;
3use charm_ui::{App, Color, Window};
4
5pub struct Store {
6    count: usize,
7}
8
9pub fn main() {
10    let store = Store { count: 127 };
11    let mut app = App::with_store(store);
12    let mut window: Window<Store> = Window::with_size((1200, 600))
13        .title("My first window")
14        .background((255, 255, 127));
15
16    window.set_root_component(
17        VStack::new()
18            .size(Parameter::constant((600, 400)))
19            .padding(Parameter::constant((64, 16)))
20            .background(Parameter::closure(|store: &Store| {
21                (store.count as u8, 0, 0)
22            }))
23            .add_child(VStack::new().background(Parameter::constant((0, 255, 0)))),
24    );
25
26    app.add_window(window);
27    app.run().unwrap();
28}