Simple test

This commit is contained in:
2026-01-24 14:26:04 +01:00
parent 979af999e4
commit 49bb99fedb
2 changed files with 18 additions and 9 deletions
+11 -5
View File
@@ -1,24 +1,25 @@
use std::fmt::Debug;
use crate::View;
#[derive(Debug, Clone)]
#[derive(Clone)]
pub enum DrawInstruction {
Text(Point, String),
View(Point, View),
Child(Point, DrawContext),
}
#[derive(Debug, Clone)]
#[derive(Clone)]
pub struct Size {
pub width: u16,
pub height: u16,
}
#[derive(Debug, Clone)]
#[derive(Clone)]
pub struct Point {
pub x: u16,
pub y: u16,
}
#[derive(Debug, Clone)]
#[derive(Clone)]
pub struct DrawContext {
pub available: Size,
pub allocated: Size,
@@ -52,4 +53,9 @@ impl DrawContext {
self.drawing
.push(DrawInstruction::Text(point, text.to_string()));
}
pub fn draw_view(&mut self, point: Point, view: View) {
let ctx = DrawContext::new(self.allocated.width, self.allocated.height);
self.drawing.push(DrawInstruction::Child(point, ctx));
}
}