Implement alignment support for table::column

This commit is contained in:
Héctor Ramón Jiménez 2025-07-16 04:06:38 +02:00
parent 1e89439aff
commit 6e71c7dd6f
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
3 changed files with 67 additions and 18 deletions

View file

@ -52,22 +52,22 @@ impl Node {
/// Aligns the [`Node`] in the given space.
pub fn align(
mut self,
horizontal_alignment: Alignment,
vertical_alignment: Alignment,
align_x: Alignment,
align_y: Alignment,
space: Size,
) -> Self {
self.align_mut(horizontal_alignment, vertical_alignment, space);
self.align_mut(align_x, align_y, space);
self
}
/// Mutable reference version of [`Self::align`].
pub fn align_mut(
&mut self,
horizontal_alignment: Alignment,
vertical_alignment: Alignment,
align_x: Alignment,
align_y: Alignment,
space: Size,
) {
match horizontal_alignment {
match align_x {
Alignment::Start => {}
Alignment::Center => {
self.bounds.x += (space.width - self.bounds.width) / 2.0;
@ -77,7 +77,7 @@ impl Node {
}
}
match vertical_alignment {
match align_y {
Alignment::Start => {}
Alignment::Center => {
self.bounds.y += (space.height - self.bounds.height) / 2.0;