mirui 0.1.2

A lightweight, no_std ECS-driven UI framework for embedded, desktop, and WebAssembly
Documentation
pub mod framebuf;
#[cfg(feature = "sdl")]
pub mod sdl;

use crate::types::Rect;

/// Display information
pub struct DisplayInfo {
    pub width: u16,
    pub height: u16,
}

/// Input event from the platform
#[derive(Clone, Debug)]
pub enum InputEvent {
    Touch { x: i32, y: i32 },
    Release { x: i32, y: i32 },
    Key { code: u32, pressed: bool },
    Quit,
}

/// Platform backend trait — abstracts display + input
pub trait Backend {
    /// Get display info
    fn display_info(&self) -> DisplayInfo;

    /// Get a mutable reference to the framebuffer (RGBA8888)
    fn framebuffer(&mut self) -> &mut [u8];

    /// Flush the framebuffer to the display
    fn flush(&mut self);

    /// Poll for input events (non-blocking, returns None when no events)
    fn poll_event(&mut self) -> Option<InputEvent>;

    /// Full screen rect helper
    fn screen_rect(&self) -> Rect {
        let info = self.display_info();
        Rect {
            x: 0,
            y: 0,
            w: info.width,
            h: info.height,
        }
    }
}