summaryrefslogtreecommitdiffstats
path: root/native/src/layout/node.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-11-11 05:26:08 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-11-11 05:26:08 +0100
commitceb02f4a36769c488c2525db2fb73f092a6c2706 (patch)
treed7a43c6b9444fb3079501e49ca1f80e31f1b4740 /native/src/layout/node.rs
parentbfe19193b95e9d1be0694bbc6a96e20a9aefdc09 (diff)
downloadiced-ceb02f4a36769c488c2525db2fb73f092a6c2706.tar.gz
iced-ceb02f4a36769c488c2525db2fb73f092a6c2706.tar.bz2
iced-ceb02f4a36769c488c2525db2fb73f092a6c2706.zip
Implement `Container` widget
Remove `align_self` and `justify_content` methods
Diffstat (limited to '')
-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 => {}
+ }
+ }
}