Simple test
This commit is contained in:
+11
-5
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user