use crate::{
environment::LayoutEnvironment,
layout::{Layout, LayoutDirection, ResolvedLayout},
primitives::{Dimensions, ProposedDimensions},
render::NullRender,
};
#[derive(Default, PartialEq)]
pub struct Spacer {
min_length: u16,
}
impl Layout for Spacer {
type Sublayout = ();
fn layout(
&self,
offer: &ProposedDimensions,
env: &impl LayoutEnvironment,
) -> ResolvedLayout<()> {
let size = match env.layout_direction() {
LayoutDirection::Horizontal => Dimensions {
width: offer.width.resolve_most_flexible(0, self.min_length),
height: 0.into(),
},
LayoutDirection::Vertical => Dimensions {
width: 0.into(),
height: offer.height.resolve_most_flexible(0, self.min_length),
},
};
ResolvedLayout {
sublayouts: (),
resolved_size: size,
}
}
fn priority(&self) -> i8 {
i8::MIN
}
}
impl NullRender for Spacer {}