summaryrefslogtreecommitdiffstats
path: root/native/src/layout/node.rs
diff options
context:
space:
mode:
Diffstat (limited to 'native/src/layout/node.rs')
-rw-r--r--native/src/layout/node.rs25
1 files changed, 24 insertions, 1 deletions
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 => {}
+ }
+ }
}