use crate::prelude::*; pub struct MaxSize { pub inner: StrongWidget, pub x: Option, pub y: Option, } impl Widget for MaxSize { fn draw(&mut self, painter: &mut Painter) -> Size { let child = painter.widget(&self.inner).size(); let output = painter.output_size(); Size { x: capped(child.x, self.x, output.x), y: capped(child.y, self.y, output.y), } } } fn capped(len: Len, max: Option, output: f32) -> Len { match max { Some(max) if len.apply_rest().to_abs(output) > max.apply_rest().to_abs(output) => max, _ => len, } }