Implement Container widget

Remove `align_self` and `justify_content` methods
This commit is contained in:
Héctor Ramón Jiménez 2019-11-11 05:26:08 +01:00
parent bfe19193b9
commit ceb02f4a36
25 changed files with 310 additions and 205 deletions

View file

@ -1,4 +1,4 @@
use crate::{Rectangle, Size};
use crate::{Align, Rectangle, Size};
#[derive(Debug, Clone, Default)]
pub struct Node {
@ -34,4 +34,27 @@ impl Node {
pub fn children(&self) -> &[Node] {
&self.children
}
pub fn align(
&mut self,
horizontal_alignment: Align,
vertical_alignment: Align,
space: Size,
) {
match horizontal_alignment {
Align::Start => {}
Align::Center => {
self.bounds.x += (space.width - self.bounds.width) / 2.0;
}
Align::End => {}
}
match vertical_alignment {
Align::Start => {}
Align::Center => {
self.bounds.y += (space.height - self.bounds.height) / 2.0;
}
Align::End => {}
}
}
}