use crate::prelude::*; pub struct Masked { pub inner: StrongWidget, } impl Widget for Masked { fn draw(&mut self, painter: &mut Painter) -> Size { painter.set_mask(UiRegion::FULL); painter.widget(&self.inner); // What it occupies is its box, on both axes, for the reason `Scroll` // reports the same: it clips what is inside to that box, so it can // neither take less of one nor honestly ask for more. Passing the // inner size up instead asks to be placed at a length it does not // draw, and the framework would place the drawing it clipped away. Size::LEFTOVER } fn size_hint(&self, _: Axis) -> Option { Some(LayoutLen::LEFTOVER) } }