diff --git a/examples/hello_world.rs b/examples/hello_world.rs index caa780d..9eb4fa7 100644 --- a/examples/hello_world.rs +++ b/examples/hello_world.rs @@ -1,6 +1,12 @@ -use osui::Node; +use osui::{Context, Node}; + +fn app(cx: &mut Context) -> Node { + // Hooks + // Event handlers + // cx.event(|e: &ClickEvent| { + + // }); -fn app() -> Node { Box::new(|renderer| { renderer.draw_text("Hello, World!", 0, 0).unwrap(); }) diff --git a/src/lib.rs b/src/lib.rs index 9e19c9c..020ac87 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,9 @@ pub mod renderer; pub use error::Result; pub type Node = Box; -pub type Component = Box Node>; +pub type Component = Box Node>; + +pub struct Context {} pub struct Osui { node: Node, @@ -15,14 +17,16 @@ pub struct Osui { impl Osui { pub fn new(component: Component) -> Self { + let mut cx = Context {}; Osui { - node: component(), + node: component(&mut cx), renderer: None, } } pub fn with_renderer(component: Component, renderer: Box) -> Self { + let mut cx = Context {}; Osui { - node: component(), + node: component(&mut cx), renderer: Some(renderer), } }