Draft custom layout engine based on druid

This commit is contained in:
Héctor Ramón Jiménez 2019-11-10 06:05:20 +01:00
parent 2303111e09
commit 0240c3981b
38 changed files with 974 additions and 249 deletions

37
native/src/layout/node.rs Normal file
View file

@ -0,0 +1,37 @@
use crate::{Rectangle, Size};
#[derive(Debug, Clone, Default)]
pub struct Node {
pub bounds: Rectangle,
children: Vec<Node>,
}
impl Node {
pub fn new(size: Size) -> Self {
Self::with_children(size, Vec::new())
}
pub fn with_children(size: Size, children: Vec<Node>) -> Self {
Node {
bounds: Rectangle {
x: 0.0,
y: 0.0,
width: size.width,
height: size.height,
},
children,
}
}
pub fn size(&self) -> Size {
Size::new(self.bounds.width, self.bounds.height)
}
pub fn bounds(&self) -> Rectangle {
self.bounds
}
pub fn children(&self) -> &[Node] {
&self.children
}
}