working center

This commit is contained in:
2025-06-26 02:42:27 -05:00
parent 82b847314e
commit dfb17ab48e
3 changed files with 21 additions and 9 deletions
+16 -2
View File
@@ -58,6 +58,11 @@ impl Transform {
self.width.use_dimension(&mut raw.width);
self.height.use_dimension(&mut raw.height);
}
pub fn use_position(&self, parent_width: u16, parent_height: u16, raw: &mut RawTransform) {
self.x.use_position(raw.width, parent_width, &mut raw.x);
self.y.use_position(raw.height, parent_height, &mut raw.y);
}
}
impl RawTransform {
@@ -74,8 +79,17 @@ impl RawTransform {
impl Dimension {
pub fn use_dimension(&self, r: &mut u16) {
match self {
Dimension::Auto => {}
Dimension::Const(n) => *r = *n,
Self::Auto => {}
Self::Const(n) => *r = *n,
}
}
}
impl Position {
pub fn use_position(&self, size: u16, parent: u16, r: &mut u16) {
match self {
Self::Center => *r = (parent - size) / 2,
Self::Const(n) => *r = *n,
}
}
}