diff --git a/src/app.rs b/src/app.rs index 6451c000..f9dd7aef 100644 --- a/src/app.rs +++ b/src/app.rs @@ -4,6 +4,7 @@ use once_cell::sync::Lazy; use parking_lot::Mutex; use winit::{ event_loop::{ControlFlow, EventLoop, EventLoopBuilder, EventLoopProxy}, + monitor::MonitorHandle, window::WindowId, }; @@ -143,6 +144,14 @@ impl Application { f(proxy); } } + + pub fn available_monitors(&self) -> impl Iterator { + self.event_loop.available_monitors() + } + + pub fn primary_monitor(&self) -> Option { + self.event_loop.primary_monitor() + } } pub fn quit_app() { diff --git a/src/app_handle.rs b/src/app_handle.rs index 6e2fb21e..8eb6e0c4 100644 --- a/src/app_handle.rs +++ b/src/app_handle.rs @@ -194,6 +194,18 @@ impl ApplicationHandle { window_builder = window_builder.with_decorations(false); } } + if let Some(transparent) = config.with_transparency { + window_builder = window_builder.with_transparent(transparent); + } + if let Some(fullscreen) = config.fullscreen { + window_builder = window_builder.with_fullscreen(Some(fullscreen)); + } + if let Some(window_level) = config.window_level { + window_builder = window_builder.with_window_level(window_level); + } + if let Some(title) = config.title { + window_builder = window_builder.with_title(title); + } } let result = window_builder.build(event_loop); let window = match result { diff --git a/src/window.rs b/src/window.rs index 05a1c838..548a31cf 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1,7 +1,10 @@ use kurbo::{Point, Size}; +pub use winit::window::Fullscreen; pub use winit::window::ResizeDirection; pub use winit::window::Theme; +pub use winit::window::WindowButtons; pub use winit::window::WindowId; +pub use winit::window::WindowLevel; use crate::{ app::{add_app_update_event, AppUpdateEvent}, @@ -13,6 +16,13 @@ pub struct WindowConfig { pub(crate) size: Option, pub(crate) position: Option, pub(crate) show_titlebar: Option, + pub(crate) with_transparency: Option, + pub(crate) fullscreen: Option, + pub(crate) window_icon: Option, + pub(crate) title: Option, + pub(crate) enabled_buttons: Option, + pub(crate) resizable: Option, + pub(crate) window_level: Option, } impl WindowConfig { @@ -30,6 +40,41 @@ impl WindowConfig { self.show_titlebar = Some(show_titlebar); self } + + pub fn with_transparency(mut self, with_transparency: bool) -> Self { + self.with_transparency = Some(with_transparency); + self + } + + pub fn fullscreen(mut self, fullscreen: Fullscreen) -> Self { + self.fullscreen = Some(fullscreen); + self + } + + pub fn window_icon(mut self, window_icon: bool) -> Self { + self.window_icon = Some(window_icon); + self + } + + pub fn title(mut self, title: impl Into) -> Self { + self.title = Some(title.into()); + self + } + + pub fn enabled_buttons(mut self, enabled_buttons: WindowButtons) -> Self { + self.enabled_buttons = Some(enabled_buttons); + self + } + + pub fn resizable(mut self, resizable: bool) -> Self { + self.resizable = Some(resizable); + self + } + + pub fn window_level(mut self, window_level: WindowLevel) -> Self { + self.window_level = Some(window_level); + self + } } /// create a new window. You'll need to create Application first, otherwise it diff --git a/vger/src/lib.rs b/vger/src/lib.rs index d4d82b79..d819686d 100644 --- a/vger/src/lib.rs +++ b/vger/src/lib.rs @@ -442,7 +442,12 @@ impl Renderer for VgerRenderer { view: &texture_view, resolve_target: None, ops: wgpu::Operations { - load: wgpu::LoadOp::Clear(wgpu::Color::WHITE), + load: wgpu::LoadOp::Clear(wgpu::Color { + r: 0.0, + g: 0.0, + b: 0.0, + a: 0.0, + }), store: StoreOp::Store, }, })],