feather_ui/layout/
root.rs1use super::{Desc, Layout, Renderable, Staged, base};
5use crate::{PxDim, PxRect};
6use std::rc::Rc;
7
8pub trait Prop {
12 fn dim(&self) -> &PxDim;
13}
14
15crate::gen_from_to_dyn!(Prop);
16
17impl Prop for PxDim {
18 fn dim(&self) -> &PxDim {
19 self
20 }
21}
22
23impl Desc for dyn Prop {
24 type Props = dyn Prop;
25 type Child = dyn base::Empty;
26 type Children = Box<dyn Layout<Self::Child>>;
27
28 fn stage<'a>(
29 props: &Self::Props,
30 _: PxRect,
31 _: crate::PxLimits,
32 child: &Self::Children,
33 _: std::sync::Weak<crate::SourceID>,
34 _: Option<Rc<dyn Renderable>>,
35 window: &mut crate::component::window::WindowState,
36 ) -> Box<dyn Staged + 'a> {
37 child.stage(
40 (*props.dim()).cast_unit().into(),
41 Default::default(),
42 window,
43 )
44 }
45}