View plugins

This commit is contained in:
2026-02-01 17:18:59 +01:00
parent 2ca419bfd4
commit c4addd7f01
5 changed files with 67 additions and 21 deletions
+1 -7
View File
@@ -8,7 +8,7 @@ pub fn main() {
#[component]
fn App(cx: &Arc<Context>) -> View {
rsx! {
impl my_center(11, 1)
impl size_auto, center, redraw
Card { content: "Hello World".to_string() }
}
.view(&cx)
@@ -23,9 +23,3 @@ fn Card(cx: &Arc<Context>, content: String) -> View {
}
.view(&cx)
}
fn my_center(ctx: &mut DrawContext, view: View, w: u16, h: u16) {
let (x, y) = ((ctx.area.width - w) / 2, (ctx.area.height - h) / 2);
let area = ctx.allocate(x, y, w, h);
ctx.draw_view(area, view);
}