use super::{Desc, Layout, Renderable, Staged, base};
use crate::{PxDim, PxRect};
use std::rc::Rc;
pub trait Prop {
fn dim(&self) -> &PxDim;
}
crate::gen_from_to_dyn!(Prop);
impl Prop for PxDim {
fn dim(&self) -> &PxDim {
self
}
}
impl Desc for dyn Prop {
type Props = dyn Prop;
type Child = dyn base::Empty;
type Children = Box<dyn Layout<Self::Child>>;
fn stage<'a>(
props: &Self::Props,
_: PxRect,
_: crate::PxLimits,
child: &Self::Children,
_: std::sync::Weak<crate::SourceID>,
_: Option<Rc<dyn Renderable>>,
window: &mut crate::component::window::WindowState,
) -> Box<dyn Staged + 'a> {
child.stage(
(*props.dim()).cast_unit().into(),
Default::default(),
window,
)
}
}