zintl_widget/
lib.rs

1use zintl_ui::{Context, Metrics, Position, RenderContent, RenderObject, Storage, View};
2
3pub struct Label {
4    context: Context,
5    text: String,
6}
7
8impl Label {
9    pub fn new(text: String) -> Self {
10        Label {
11            context: Context::default(),
12            text,
13        }
14    }
15}
16
17impl View for Label {
18    fn get_context(&self) -> &Context {
19        &self.context
20    }
21
22    fn render(&mut self, _: &mut Storage) -> RenderObject {
23        RenderObject::new(
24            RenderContent::Text(self.text.clone()),
25            Position::new(0., 0.),
26            Metrics::Auto,
27        )
28    }
29}