use crate::geometry::{PhysicalSize, ScaleFactor, Size};
use crate::platform::event::WindowId;
use crate::render::Surface;
#[derive(Clone, Debug)]
pub struct WindowAttributes {
pub title: String,
pub logical_size: Size,
pub resizable: bool,
pub position: Option<(i32, i32)>,
}
impl Default for WindowAttributes {
fn default() -> Self {
Self {
title: "Stipple".to_string(),
logical_size: Size::new(800.0, 600.0),
resizable: true,
position: None,
}
}
}
impl WindowAttributes {
pub fn new() -> Self {
Self::default()
}
pub fn with_title(mut self, title: impl Into<String>) -> Self {
self.title = title.into();
self
}
pub fn with_logical_size(mut self, size: Size) -> Self {
self.logical_size = size;
self
}
pub fn resizable(mut self, resizable: bool) -> Self {
self.resizable = resizable;
self
}
pub fn with_position(mut self, x: i32, y: i32) -> Self {
self.position = Some((x, y));
self
}
}
pub trait Window {
fn id(&self) -> WindowId;
fn inner_size(&self) -> PhysicalSize;
fn scale_factor(&self) -> ScaleFactor;
fn request_redraw(&self);
fn set_title(&self, title: &str);
fn set_accessibility_tree(&self, _root: &crate::platform::access::A11yNode) {}
fn create_surface(&self) -> Box<dyn Surface>;
fn clipboard(&self) -> Option<String> {
None
}
fn set_clipboard(&self, _text: &str) {}
fn open_window(&self, _attrs: WindowAttributes) -> Option<WindowId> {
None
}
fn close_window(&self) {}
}