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
53
54
55
56
57
58
59
use crate::draw::Primitive;
use crate::layout::{Rectangle, Size};
use crate::node::{GenericNode, IntoNode, Node};
use crate::style::Stylesheet;
use crate::widget::Widget;
pub struct Dummy {
    widget: &'static str,
}
impl Dummy {
    
    pub fn new(widget: &'static str) -> Self {
        Self { widget }
    }
    
    pub fn widget(mut self, widget: &'static str) -> Self {
        self.widget = widget;
        self
    }
}
impl Default for Dummy {
    fn default() -> Self {
        Dummy { widget: "" }
    }
}
impl<'a, T: 'a> Widget<'a, T> for Dummy {
    type State = ();
    fn mount(&self) {}
    fn widget(&self) -> &'static str {
        self.widget
    }
    fn len(&self) -> usize {
        0
    }
    fn visit_children(&mut self, _: &mut dyn FnMut(&mut dyn GenericNode<'a, T>)) {}
    fn size(&self, _: &(), style: &Stylesheet) -> (Size, Size) {
        (style.width, style.height)
    }
    fn draw(&mut self, _: &mut (), layout: Rectangle, _: Rectangle, style: &Stylesheet) -> Vec<Primitive<'a>> {
        style.background.render(layout).into_iter().collect()
    }
}
impl<'a, T: 'a> IntoNode<'a, T> for Dummy {
    fn into_node(self) -> Node<'a, T> {
        Node::from_widget(self)
    }
}