diff --git a/examples/hello_world.rs b/examples/hello_world.rs index dc65101..fc998cd 100644 --- a/examples/hello_world.rs +++ b/examples/hello_world.rs @@ -46,7 +46,7 @@ fn app(cx: &Arc) -> View { scope.child( my_component, Some(Arc::new(|ctx, view| { - let area = ctx.allocate(0, 0, 0, 0); + let area = ctx.allocate(5, 0, 0, 0); ctx.draw_view(area, view) })), ); @@ -62,7 +62,7 @@ fn app(cx: &Arc) -> View { scope.child( my_component, Some(Arc::new(|ctx, view| { - let area = ctx.allocate(0, 2, 0, 0); + let area = ctx.allocate(5, 2, 0, 0); ctx.draw_view(area, view) })), ); @@ -76,6 +76,27 @@ fn app(cx: &Arc) -> View { ); } + { + cx.dyn_scope( + { + let count = count.clone(); + move |scope| { + scope.children.lock().unwrap().clear(); + + for i in 0..count.get_dl() { + scope.child( + my_component, + Some(Arc::new(move |ctx, _| { + ctx.draw_text(Point { x: 0, y: i }, &format!("{i}")); + })), + ); + } + } + }, + &[&count], + ); + } + Arc::new({ let cx = cx.clone();