logo
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
use std::{fmt, rc::Rc};

use crate::prelude::color;

use crate::{
    elements::NavigationRailElement,
    engine::d2::Painter,
    platform::gles::{core30::gl, enums::*},
    rendering::backend::WidgetRenderer,
};

pub struct NavigationRailRender {
    painter: Rc<Painter>,
}

impl NavigationRailRender {
    pub fn new(painter: Rc<Painter>) -> Self {
        Self { painter }
    }
}

impl WidgetRenderer<NavigationRailElement> for NavigationRailRender {
    fn render(&self, widget: &NavigationRailElement) {
        let comp = widget.as_ref().borrow();

        // println!("Node {:?}", widget.node);
        // println!("NavigationRailRender {}x{} {}x{}", comp.x, comp.y, comp.w, comp.h);

        self.painter.set_color(color::GRAY_7);

        self.painter.fill_rect(comp.x, comp.y, comp.w, comp.h);

        self.painter.flush();
    }
}

impl fmt::Debug for NavigationRailRender {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        f.debug_struct("NavigationRailRender").finish()
    }
}