From be51cac3d71d5eb49e266d0d2aae6ab945caf560 Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Tue, 14 Sep 2021 09:10:37 -0700 Subject: Add Align::Fill variant --- native/src/layout/node.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'native/src/layout/node.rs') diff --git a/native/src/layout/node.rs b/native/src/layout/node.rs index d7666f31..bee5e64e 100644 --- a/native/src/layout/node.rs +++ b/native/src/layout/node.rs @@ -56,6 +56,9 @@ impl Node { Align::End => { self.bounds.x += space.width - self.bounds.width; } + Align::Fill => { + self.bounds.width = space.width; + } } match vertical_alignment { @@ -66,6 +69,9 @@ impl Node { Align::End => { self.bounds.y += space.height - self.bounds.height; } + Align::Fill => { + self.bounds.height = space.height; + } } } -- cgit From 5fae6e59ffbc5913761df638dc7f0c35b7f43bc9 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 20 Sep 2021 14:33:02 +0700 Subject: Introduce and use `CrossAlign` enum for `Column` and `Row` --- native/src/layout/node.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'native/src/layout/node.rs') diff --git a/native/src/layout/node.rs b/native/src/layout/node.rs index bee5e64e..2239a654 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::{CrossAlign, Point, Rectangle, Size}; /// The bounds of an element and its children. #[derive(Debug, Clone, Default)] @@ -44,32 +44,32 @@ impl Node { /// Aligns the [`Node`] in the given space. pub fn align( &mut self, - horizontal_alignment: Align, - vertical_alignment: Align, + horizontal_alignment: CrossAlign, + vertical_alignment: CrossAlign, space: Size, ) { match horizontal_alignment { - Align::Start => {} - Align::Center => { + CrossAlign::Start => {} + CrossAlign::Center => { self.bounds.x += (space.width - self.bounds.width) / 2.0; } - Align::End => { + CrossAlign::End => { self.bounds.x += space.width - self.bounds.width; } - Align::Fill => { + CrossAlign::Fill => { self.bounds.width = space.width; } } match vertical_alignment { - Align::Start => {} - Align::Center => { + CrossAlign::Start => {} + CrossAlign::Center => { self.bounds.y += (space.height - self.bounds.height) / 2.0; } - Align::End => { + CrossAlign::End => { self.bounds.y += space.height - self.bounds.height; } - Align::Fill => { + CrossAlign::Fill => { self.bounds.height = space.height; } } -- cgit From a0ad3996225601aaa1ebe051cba115374b55c80e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 20 Sep 2021 15:09:55 +0700 Subject: Refactor alignment types into an `alignment` module --- native/src/layout/node.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'native/src/layout/node.rs') diff --git a/native/src/layout/node.rs b/native/src/layout/node.rs index 2239a654..e9e6058e 100644 --- a/native/src/layout/node.rs +++ b/native/src/layout/node.rs @@ -1,4 +1,4 @@ -use crate::{CrossAlign, Point, Rectangle, Size}; +use crate::{Alignment, Point, Rectangle, Size}; /// The bounds of an element and its children. #[derive(Debug, Clone, Default)] @@ -44,32 +44,32 @@ impl Node { /// Aligns the [`Node`] in the given space. pub fn align( &mut self, - horizontal_alignment: CrossAlign, - vertical_alignment: CrossAlign, + horizontal_alignment: Alignment, + vertical_alignment: Alignment, space: Size, ) { match horizontal_alignment { - CrossAlign::Start => {} - CrossAlign::Center => { + Alignment::Start => {} + Alignment::Center => { self.bounds.x += (space.width - self.bounds.width) / 2.0; } - CrossAlign::End => { + Alignment::End => { self.bounds.x += space.width - self.bounds.width; } - CrossAlign::Fill => { + Alignment::Fill => { self.bounds.width = space.width; } } match vertical_alignment { - CrossAlign::Start => {} - CrossAlign::Center => { + Alignment::Start => {} + Alignment::Center => { self.bounds.y += (space.height - self.bounds.height) / 2.0; } - CrossAlign::End => { + Alignment::End => { self.bounds.y += space.height - self.bounds.height; } - CrossAlign::Fill => { + Alignment::Fill => { self.bounds.height = space.height; } } -- cgit