faststep 0.1.0

UIKit-inspired embedded UI framework built on embedded-graphics
Documentation
use embedded_graphics::primitives::Rectangle;

use crate::{TouchEvent, UiCanvas};

/// Drawing backend provided by an OEM target or simulator.
pub trait DisplayPort {
    /// Canvas type used for drawing frames.
    type Canvas: UiCanvas;
    /// Backend-specific drawing error.
    type Error;

    /// Returns the drawable bounds of the target surface.
    fn bounds(&self) -> Rectangle;

    /// Draws a full frame.
    fn draw_frame<F>(&mut self, draw: F) -> Result<(), Self::Error>
    where
        F: FnOnce(&mut Self::Canvas);

    /// Draws only the specified dirty area.
    ///
    /// The default implementation falls back to [`Self::draw_frame`].
    fn draw_dirty<F>(&mut self, dirty: Rectangle, draw: F) -> Result<(), Self::Error>
    where
        F: FnOnce(&mut Self::Canvas),
    {
        let _ = dirty;
        self.draw_frame(draw)
    }
}

/// Low-level touch polling source.
pub trait TouchPort {
    /// Backend-specific touch error.
    type Error;

    /// Polls the next touch sample for the given time.
    fn poll_touch(&mut self, now_ms: u32) -> Result<Option<TouchEvent>, Self::Error>;
}

/// Monotonic clock abstraction.
pub trait FrameClock {
    /// Returns the current time in milliseconds.
    fn now_ms(&self) -> u32;
}