use winit::{dpi::PhysicalSize, window::WindowAttributes};
use super::event::resize::Resized;
pub struct GraphicalApplicationOptions {
pub tick_rate: f64,
pub title: &'static str,
pub width: u32,
pub height: u32,
}
impl GraphicalApplicationOptions {
pub fn with_tick_rate(&mut self, tick_rate: f64) -> &mut Self {
self.tick_rate = tick_rate;
self
}
pub fn with_title(&mut self, title: &'static str) -> &mut Self {
self.title = title;
self
}
pub fn with_size(&mut self, width: u32, height: u32) -> &mut Self {
self.width = width;
self.height = height;
self
}
pub(crate) fn to_attr(&self) -> WindowAttributes {
WindowAttributes::default()
.with_title(self.title)
.with_inner_size(PhysicalSize::new(self.width, self.height))
}
pub(crate) fn to_resized(&self) -> Resized {
Resized::from_size(self.width, self.height)
}
}
impl Default for GraphicalApplicationOptions {
fn default() -> Self {
let tick_rate = 1.;
let title = "Application";
let width = 1200;
let height = 800;
Self { tick_rate, title, width, height }
}
}