diff options
author | 2019-11-10 06:05:20 +0100 | |
---|---|---|
committer | 2019-11-11 03:08:00 +0100 | |
commit | 0240c3981b716c82ecb3364945815335b420a63e (patch) | |
tree | 441eebaa9441649a4e878bde71cdec20d4a67391 /native/src/layout/node.rs | |
parent | 2303111e09d806ef2a652bddc2b73be6dccf6ae2 (diff) | |
download | iced-0240c3981b716c82ecb3364945815335b420a63e.tar.gz iced-0240c3981b716c82ecb3364945815335b420a63e.tar.bz2 iced-0240c3981b716c82ecb3364945815335b420a63e.zip |
Draft custom layout engine based on `druid`
Diffstat (limited to '')
-rw-r--r-- | native/src/layout/node.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/native/src/layout/node.rs b/native/src/layout/node.rs new file mode 100644 index 00000000..7537ad3b --- /dev/null +++ b/native/src/layout/node.rs @@ -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 + } +} |