//! Configuration primitives.

use super::event::Resized;

/// Configures a graphical application.
pub struct GraphicalApplicationOptions {
    pub tick_rate: f64,
    pub width: u32,
    pub height: u32,
}

impl GraphicalApplicationOptions {
    /// Configures [`self`] with a tick rate.
    pub fn with_tick_rate(&mut self, tick_rate: f64) -> &mut Self {
        self.tick_rate = tick_rate;

        self
    }

    /// Configures [`self`] with a physical per-pixel size.
    pub fn with_size(&mut self, width: u32, height: u32) -> &mut Self {
        self.width = width;
        self.height = height;

        self
    }

    /// Creates a [`Resized`] event from [`self`].
    pub fn to_resized(&self) -> Resized {
        Resized::from_size(self.width, self.height)
    }
}

impl Default for GraphicalApplicationOptions {
    fn default() -> Self {
        let tick_rate = 1.;
        let width = 1200;
        let height = 800;

        Self { tick_rate, width, height }
    }
}
