From ceb02f4a36769c488c2525db2fb73f092a6c2706 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 11 Nov 2019 05:26:08 +0100 Subject: Implement `Container` widget Remove `align_self` and `justify_content` methods --- native/src/layout/node.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'native/src/layout/node.rs') diff --git a/native/src/layout/node.rs b/native/src/layout/node.rs index 7537ad3b..9d8ad57d 100644 --- a/native/src/layout/node.rs +++ b/native/src/layout/node.rs @@ -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 => {} + } + } } -- cgit