summaryrefslogtreecommitdiffstats
path: root/native/src/layout/node.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2021-09-20 15:54:19 +0700
committerLibravatar GitHub <noreply@github.com>2021-09-20 15:54:19 +0700
commit35c4ad6dd950fa91d181f4d3253fcb486bcf1b11 (patch)
tree8420a91cd319a63b1ed257a6334453a1a673bdfb /native/src/layout/node.rs
parent456a3f15e4226cc781a8825bddaaf066476d4351 (diff)
parenta0ad3996225601aaa1ebe051cba115374b55c80e (diff)
downloadiced-35c4ad6dd950fa91d181f4d3253fcb486bcf1b11.tar.gz
iced-35c4ad6dd950fa91d181f4d3253fcb486bcf1b11.tar.bz2
iced-35c4ad6dd950fa91d181f4d3253fcb486bcf1b11.zip
Merge pull request #1044 from tarkah/feature/align-fill-variant
Add Align::Fill variant
Diffstat (limited to 'native/src/layout/node.rs')
-rw-r--r--native/src/layout/node.rs24
1 files changed, 15 insertions, 9 deletions
diff --git a/native/src/layout/node.rs b/native/src/layout/node.rs
index d7666f31..e9e6058e 100644
--- a/native/src/layout/node.rs
+++ b/native/src/layout/node.rs
@@ -1,4 +1,4 @@
-use crate::{Align, Point, Rectangle, Size};
+use crate::{Alignment, Point, Rectangle, Size};
/// The bounds of an element and its children.
#[derive(Debug, Clone, Default)]
@@ -44,28 +44,34 @@ impl Node {
/// Aligns the [`Node`] in the given space.
pub fn align(
&mut self,
- horizontal_alignment: Align,
- vertical_alignment: Align,
+ horizontal_alignment: Alignment,
+ vertical_alignment: Alignment,
space: Size,
) {
match horizontal_alignment {
- Align::Start => {}
- Align::Center => {
+ Alignment::Start => {}
+ Alignment::Center => {
self.bounds.x += (space.width - self.bounds.width) / 2.0;
}
- Align::End => {
+ Alignment::End => {
self.bounds.x += space.width - self.bounds.width;
}
+ Alignment::Fill => {
+ self.bounds.width = space.width;
+ }
}
match vertical_alignment {
- Align::Start => {}
- Align::Center => {
+ Alignment::Start => {}
+ Alignment::Center => {
self.bounds.y += (space.height - self.bounds.height) / 2.0;
}
- Align::End => {
+ Alignment::End => {
self.bounds.y += space.height - self.bounds.height;
}
+ Alignment::Fill => {
+ self.bounds.height = space.height;
+ }
}
}