cotis-utils 0.1.0-alpha

Modular Rust UI framework core
Documentation
use crate::math::Dimensions;

/// Combined renderer context required by Cotis integrations.
///
/// This is a marker supertrait over [`CotisWindowContext`] and
/// [`CotisFrameContext`]. Any type that implements both subtraits automatically
/// implements this trait as well; renderers only need to implement window
/// dimensions and delta time.
pub trait CotisRenderContext: CotisWindowContext + CotisFrameContext {}

impl<T> CotisRenderContext for T where T: CotisWindowContext + CotisFrameContext {}

/// Provides current window dimensions in pixels.
pub trait CotisWindowContext {
    /// Returns the current drawable window dimensions.
    ///
    /// Layout managers call this value during frame preparation to size the root
    /// layout context.
    fn window_dimensions(&self) -> Dimensions;
}

/// Provides frame timing data.
pub trait CotisFrameContext {
    /// Returns delta time in seconds since the previous frame.
    fn get_delta_time(&self) -> f32;
}