use ascii_forge::prelude::*;
use std::io;
use widget_forge::prelude::*;
#[derive(Default)]
pub struct AppData {
should_exit: bool,
}
fn hello(w: &mut Window, _d: &mut AppData) {
let center = {
let s = w.size();
vec2(s.x / 2, s.y / 2)
};
render!(w, (center.x - 13/2, center.y) => [ "Hello, World!".green() ]);
}
fn quit_handler(w: &mut Window, d: &mut AppData) {
if event!(w, Event::Key(e) => e.code == KeyCode::Char('q')) {
d.should_exit = true;
}
}
fn main() -> io::Result<()> {
let window = Window::init()?;
handle_panics();
Scene::new(window, AppData::default())
.insert_widgets((hello, quit_handler))
.run(100, |scene| !scene.data().should_exit)?;
Ok(())
}