Fix gap
This commit is contained in:
+14
-1
@@ -9,6 +9,7 @@ pub enum Size {
|
||||
Fixed(u16),
|
||||
Flex(u16),
|
||||
Percent(u16),
|
||||
Fill,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
@@ -20,17 +21,22 @@ pub struct Rect {
|
||||
}
|
||||
|
||||
impl Size {
|
||||
pub fn is_fill(&self) -> bool {
|
||||
matches!(self, Self::Fill)
|
||||
}
|
||||
|
||||
pub fn get_fixed(&self, alloc: u16) -> u16 {
|
||||
match self {
|
||||
Self::Fixed(v) => *v,
|
||||
Self::Percent(v) => alloc * (*v) / 100,
|
||||
Self::Flex(_) => 0,
|
||||
Self::Flex(_) | Self::Fill => 0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_flex(&self) -> u16 {
|
||||
match self {
|
||||
Self::Flex(f) => *f,
|
||||
Self::Fill => 1,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
@@ -46,6 +52,13 @@ impl Size {
|
||||
remaining * v / total_weight
|
||||
}
|
||||
}
|
||||
Self::Fill => {
|
||||
if total_weight == 0 {
|
||||
0
|
||||
} else {
|
||||
remaining / total_weight
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user