use rosace_core::render_object::AxisBound;
#[derive(Debug, Clone)]
pub enum Width {
Fixed(f32),
Fill,
Shrink,
Fraction(f32),
Min(f32),
Max(f32),
Range(f32, f32),
}
#[derive(Debug, Clone)]
pub enum Height {
Fixed(f32),
Fill,
Shrink,
Fraction(f32),
Min(f32),
Max(f32),
Range(f32, f32),
}
impl Width {
pub fn to_axis_bound(&self, available: f32) -> AxisBound {
match self {
Width::Fixed(v) => AxisBound::Bounded(*v),
Width::Fill => AxisBound::Bounded(available),
Width::Shrink => AxisBound::Shrink,
Width::Fraction(f) => AxisBound::Bounded(available * f),
Width::Min(v) => AxisBound::Bounded(*v),
Width::Max(v) => AxisBound::Bounded(*v),
Width::Range(_, max) => AxisBound::Bounded(*max),
}
}
}
impl Height {
pub fn to_axis_bound(&self, available: f32) -> AxisBound {
match self {
Height::Fixed(v) => AxisBound::Bounded(*v),
Height::Fill => AxisBound::Bounded(available),
Height::Shrink => AxisBound::Shrink,
Height::Fraction(f) => AxisBound::Bounded(available * f),
Height::Min(v) => AxisBound::Bounded(*v),
Height::Max(v) => AxisBound::Bounded(*v),
Height::Range(_, max) => AxisBound::Bounded(*max),
}
}
}