use crate::{PrimitiveHandle, UiRegion}; /// Retains which box geometry follows when only the extent changes. #[derive(Clone, Copy, Debug)] pub enum DrawRegion { Frame(UiRegion), Extent(UiRegion), } impl DrawRegion { pub(crate) fn resolve(self, frame: UiRegion, extent: UiRegion) -> UiRegion { match self { Self::Frame(local) => local.within(&frame), Self::Extent(local) => local.within(&extent).within(&frame), } } pub(crate) fn map(self, f: impl FnOnce(UiRegion) -> UiRegion) -> Self { match self { Self::Frame(local) => Self::Frame(f(local)), Self::Extent(local) => Self::Extent(f(local)), } } } impl From for DrawRegion { fn from(region: UiRegion) -> Self { Self::Frame(region) } } #[derive(Debug)] pub struct RetainedPrimitive { pub handle: PrimitiveHandle, pub region: DrawRegion, }