~saiko/game

c11aa26b4a8d8866d1487be434e52908c03fb7ef — 2xsaiko 2 months ago 38e3150
Don't have this inside the trait
1 files changed, 12 insertions(+), 10 deletions(-)

M src/ui/controller.rs
M src/ui/controller.rs => src/ui/controller.rs +12 -10
@@ 14,16 14,7 @@ pub trait UiController {
    fn get_resize_capabilities(&self, elements: &Self::Elements, g: &DrawPreview) -> ResizeCapabilities;

    fn draw(&mut self, elements: &mut Self::Elements, g: &mut Graphics) {
        self.default_draw(elements, g);
    }

    fn default_draw(&mut self, elements: &mut Self::Elements, g: &mut Graphics) {
        use crate::ui::access::Values;

        let all = <Self::Elements as UiAccess>::Access::values();
        for el in all {
            elements.get_element_mut(*el).draw(g);
        }
        draw_elements(elements, g);
    }

    fn click(&mut self, x: i32, y: i32) -> bool { true }


@@ 35,3 26,14 @@ pub trait UiController {
    // TODO implement redraw on demand
    fn is_animated(&self) -> bool { true }
}

pub fn draw_elements<T>(elements: &mut T, g: &mut Graphics)
    where T: UiAccess + 'static {

    use crate::ui::access::Values;

    let all = T::Access::values();
    for el in all {
        elements.get_element_mut(*el).draw(g);
    }
}
\ No newline at end of file