use crate::color::sRGB;
use crate::layout::{Layout, base};
use crate::{PxPoint, SourceID, layout};
use derive_where::derive_where;
use std::rc::Rc;
use std::sync::Arc;
#[derive(feather_macro::StateMachineChild)]
#[derive_where(Clone)]
pub struct Line<T> {
pub id: Arc<SourceID>,
pub start: PxPoint,
pub end: PxPoint,
pub props: Rc<T>,
pub fill: sRGB,
}
impl<T: base::Empty + 'static> super::Component for Line<T>
where
for<'a> &'a T: Into<&'a (dyn base::Empty + 'static)>,
{
type Props = T;
fn layout(
&self,
_: &mut crate::StateManager,
_: &crate::graphics::Driver,
_window: &Arc<SourceID>,
) -> Box<dyn Layout<T>> {
Box::new(layout::Node::<T, dyn base::Empty> {
props: self.props.clone(),
children: Default::default(),
id: Arc::downgrade(&self.id),
renderable: Some(Rc::new(crate::render::line::Instance {
start: self.start,
end: self.end,
color: self.fill,
})),
layer: None,
})
}
}