This commit is contained in:
2026-07-14 11:27:42 -04:00
parent 949c03e42f
commit 49c0c586e2
+9 -3
View File
@@ -86,7 +86,7 @@ impl Size {
pub fn get_fixed(&self, alloc: u16) -> u16 { pub fn get_fixed(&self, alloc: u16) -> u16 {
match self { match self {
Self::Fixed(v) => *v, Self::Fixed(v) => *v,
Self::Percent(v) => alloc / (v / 100), Self::Percent(v) => alloc * (*v) / 100,
Self::Flex(_) => 0, Self::Flex(_) => 0,
} }
} }
@@ -101,8 +101,14 @@ impl Size {
pub fn get(&self, alloc: u16, remaining: u16, total_weight: u16) -> u16 { pub fn get(&self, alloc: u16, remaining: u16, total_weight: u16) -> u16 {
match self { match self {
Self::Fixed(v) => *v, Self::Fixed(v) => *v,
Self::Percent(v) => alloc / (v / 100), Self::Percent(v) => alloc * (*v) / 100,
Self::Flex(v) => remaining * v / total_weight, Self::Flex(v) => {
if total_weight == 0 {
0
} else {
remaining * v / total_weight
}
}
} }
} }
} }