#[derive(Clone, Debug)]
pub struct WindowConfig {
pub title: String,
pub width: u32,
pub height: u32,
pub resizable: bool,
pub decorations: bool,
pub transparent: bool,
pub always_on_top: bool,
pub fullscreen: bool,
}
impl Default for WindowConfig {
fn default() -> Self {
Self {
title: "Blinc App".to_string(),
width: 800,
height: 600,
resizable: true,
decorations: true,
transparent: false,
always_on_top: false,
fullscreen: false,
}
}
}
impl WindowConfig {
pub fn new(title: impl Into<String>) -> Self {
Self {
title: title.into(),
..Default::default()
}
}
pub fn title(mut self, title: impl Into<String>) -> Self {
self.title = title.into();
self
}
pub fn size(mut self, width: u32, height: u32) -> Self {
self.width = width;
self.height = height;
self
}
pub fn resizable(mut self, resizable: bool) -> Self {
self.resizable = resizable;
self
}
pub fn decorations(mut self, decorations: bool) -> Self {
self.decorations = decorations;
self
}
pub fn transparent(mut self, transparent: bool) -> Self {
self.transparent = transparent;
self
}
pub fn always_on_top(mut self, always_on_top: bool) -> Self {
self.always_on_top = always_on_top;
self
}
pub fn fullscreen(mut self, fullscreen: bool) -> Self {
self.fullscreen = fullscreen;
self
}
}
pub trait Window: Send {
fn size(&self) -> (u32, u32);
fn logical_size(&self) -> (f32, f32);
fn scale_factor(&self) -> f64;
fn set_title(&self, title: &str);
fn set_cursor(&self, cursor: Cursor);
fn request_redraw(&self);
fn is_focused(&self) -> bool;
fn is_visible(&self) -> bool;
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub enum Cursor {
#[default]
Default,
Pointer,
Text,
Crosshair,
Move,
NotAllowed,
ResizeNS,
ResizeEW,
ResizeNESW,
ResizeNWSE,
Grab,
Grabbing,
Wait,
Progress,
None,
}