1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
use crate::renderer::{Renderable, ToHtml}; use crate::node::{Node, NodeContainer}; use std::borrow::BorrowMut; use crate::DefaultModifiers; use crate::component::{Appendable, ChildContainer}; use std::process::Child; #[derive(Debug, Clone)] pub struct View { children: Vec<Box<dyn Renderable>>, pub node: Node, } impl NodeContainer for View { fn get_node(&mut self) -> &mut Node { self.node.borrow_mut() } } impl DefaultModifiers<View> for View {} impl ToHtml for View {} impl View { pub fn new() -> Self { View { children: vec![], node: Default::default(), } } } impl ChildContainer for View { fn get_children(&mut self) -> &mut Vec<Box<dyn Renderable>> { return self.children.borrow_mut(); } } impl Appendable<View> for View {} impl Renderable for View { fn render(&self) -> Node { let mut node = self.clone().node; self.children.iter() .for_each(|child| node.children.push(child.render())); node } }