summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-06-28 01:02:59 +0200
committerHampusM <hampus@hampusmat.com>2026-06-30 18:24:47 +0200
commit4935059726af72434cb6803e1ebd5e4430183b9f (patch)
tree24db976146d9e08c1a68f8a993ea1738fb844936
parent9df8a4d197e66accb389edb5a5c54117933f157e (diff)
feat(engine): add fields to window creation attrs
-rw-r--r--engine/src/windowing/dpi.rs2
-rw-r--r--engine/src/windowing/window.rs31
2 files changed, 29 insertions, 4 deletions
diff --git a/engine/src/windowing/dpi.rs b/engine/src/windowing/dpi.rs
index 2bac619..e11fa25 100644
--- a/engine/src/windowing/dpi.rs
+++ b/engine/src/windowing/dpi.rs
@@ -180,3 +180,5 @@ pub enum Size
Physical(PhysicalSize<u32>),
Logical(LogicalSize<f64>)
}
+
+gen_enum_from_to_impls!(Size, variants=(Physical, Logical));
diff --git a/engine/src/windowing/window.rs b/engine/src/windowing/window.rs
index 039d98a..93cb233 100644
--- a/engine/src/windowing/window.rs
+++ b/engine/src/windowing/window.rs
@@ -2,7 +2,7 @@ use std::borrow::Cow;
use crate::ecs::Component;
use crate::reflection::Reflection;
-use crate::windowing::dpi::PhysicalSize;
+use crate::windowing::dpi::{PhysicalSize, Position, Size};
pub mod platform;
@@ -28,6 +28,10 @@ pub struct CreationAttributes
pub transparent: bool,
pub maximized: bool,
pub fullscreen: Option<Fullscreen>,
+ pub visible: bool,
+ pub resizable: bool,
+ pub position: Option<Position>,
+ pub inner_size: Option<Size>,
pub x_visual_id: Option<XVisualID>,
}
@@ -50,20 +54,29 @@ gen_creation_attrs_with_fn!(title, Cow<'static, str>);
gen_creation_attrs_with_fn!(transparent, bool);
gen_creation_attrs_with_fn!(maximized, bool);
gen_creation_attrs_with_fn!(fullscreen, Option<Fullscreen>);
+gen_creation_attrs_with_fn!(visible, bool);
+gen_creation_attrs_with_fn!(resizable, bool);
+gen_creation_attrs_with_fn!(position, Option<Position>);
+gen_creation_attrs_with_fn!(inner_size, Option<Size>);
gen_creation_attrs_with_fn!(x_visual_id, Option<XVisualID>);
impl CreationAttributes
{
pub(crate) fn into_window_attrs(self) -> winit::window::WindowAttributes
{
- let window_attrs = winit::window::WindowAttributes::default()
+ let mut window_attrs = winit::window::WindowAttributes::default()
.with_title(self.title.into_owned())
.with_transparent(self.transparent)
.with_maximized(self.maximized)
.with_fullscreen(match self.fullscreen {
Some(Fullscreen::Borderless) => Some(winit::window::Fullscreen::Borderless(None)),
None => None
- });
+ })
+ .with_visible(self.visible)
+ .with_resizable(self.resizable);
+
+ window_attrs.position = self.position.map(Into::into);
+ window_attrs.inner_size = self.inner_size.map(Into::into);
#[cfg(target_os = "linux")]
if let Some(visual_id) = self.x_visual_id {
@@ -78,7 +91,17 @@ impl Default for CreationAttributes
{
fn default() -> Self
{
- Self { title: "Unnamed window".into(), transparent: false, maximized: false, fullscreen: None, x_visual_id: None }
+ Self {
+ title: "Unnamed window".into(),
+ transparent: false,
+ maximized: false,
+ fullscreen: None,
+ visible: true,
+ resizable: true,
+ position: None,
+ inner_size: None,
+ x_visual_id: None
+ }
}
}