Introduce and use CrossAlign enum for Column and Row
This commit is contained in:
parent
95e4791a1e
commit
5fae6e59ff
33 changed files with 166 additions and 115 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue