Add 'transparent' in window setting
This commit is contained in:
parent
00d66da0ce
commit
a490fd54c9
2 changed files with 15 additions and 5 deletions
|
|
@ -18,6 +18,9 @@ pub struct Settings {
|
||||||
/// Whether the window should have a border, a title bar, etc. or not.
|
/// Whether the window should have a border, a title bar, etc. or not.
|
||||||
pub decorations: bool,
|
pub decorations: bool,
|
||||||
|
|
||||||
|
/// Whether the window should be transparent
|
||||||
|
pub transparent: bool,
|
||||||
|
|
||||||
/// The icon of the window.
|
/// The icon of the window.
|
||||||
pub icon: Option<Icon>,
|
pub icon: Option<Icon>,
|
||||||
}
|
}
|
||||||
|
|
@ -30,6 +33,7 @@ impl Default for Settings {
|
||||||
max_size: None,
|
max_size: None,
|
||||||
resizable: true,
|
resizable: true,
|
||||||
decorations: true,
|
decorations: true,
|
||||||
|
transparent: false,
|
||||||
icon: None,
|
icon: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -44,6 +48,7 @@ impl From<Settings> for iced_winit::settings::Window {
|
||||||
max_size: settings.max_size,
|
max_size: settings.max_size,
|
||||||
resizable: settings.resizable,
|
resizable: settings.resizable,
|
||||||
decorations: settings.decorations,
|
decorations: settings.decorations,
|
||||||
|
transparent: settings.transparent,
|
||||||
icon: settings.icon.map(Icon::into),
|
icon: settings.icon.map(Icon::into),
|
||||||
platform_specific: Default::default(),
|
platform_specific: Default::default(),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ pub struct Window {
|
||||||
/// Whether the window should have a border, a title bar, etc.
|
/// Whether the window should have a border, a title bar, etc.
|
||||||
pub decorations: bool,
|
pub decorations: bool,
|
||||||
|
|
||||||
|
pub transparent: bool,
|
||||||
|
|
||||||
/// The window icon, which is also usually used in the taskbar
|
/// The window icon, which is also usually used in the taskbar
|
||||||
pub icon: Option<winit::window::Icon>,
|
pub icon: Option<winit::window::Icon>,
|
||||||
|
|
||||||
|
|
@ -64,11 +66,13 @@ impl Window {
|
||||||
|
|
||||||
let (width, height) = self.size;
|
let (width, height) = self.size;
|
||||||
|
|
||||||
|
println!("patched window with trasparent");
|
||||||
window_builder = window_builder
|
window_builder = window_builder
|
||||||
.with_title(title)
|
.with_title(title)
|
||||||
.with_inner_size(winit::dpi::LogicalSize { width, height })
|
.with_inner_size(winit::dpi::LogicalSize { width, height })
|
||||||
.with_resizable(self.resizable)
|
.with_resizable(self.resizable)
|
||||||
.with_decorations(self.decorations)
|
.with_decorations(self.decorations)
|
||||||
|
.with_transparent(self.transparent)
|
||||||
.with_window_icon(self.icon)
|
.with_window_icon(self.icon)
|
||||||
.with_fullscreen(conversion::fullscreen(primary_monitor, mode));
|
.with_fullscreen(conversion::fullscreen(primary_monitor, mode));
|
||||||
|
|
||||||
|
|
@ -83,13 +87,13 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
use winit::platform::windows::WindowBuilderExtWindows;
|
use winit::platform::windows::WindowBuilderExtWindows;
|
||||||
|
|
||||||
if let Some(parent) = self.platform_specific.parent {
|
if let Some(parent) = self.platform_specific.parent {
|
||||||
window_builder = window_builder.with_parent_window(parent);
|
window_builder = window_builder.with_parent_window(parent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
window_builder
|
window_builder
|
||||||
}
|
}
|
||||||
|
|
@ -103,6 +107,7 @@ impl Default for Window {
|
||||||
max_size: None,
|
max_size: None,
|
||||||
resizable: true,
|
resizable: true,
|
||||||
decorations: true,
|
decorations: true,
|
||||||
|
transparent: false,
|
||||||
icon: None,
|
icon: None,
|
||||||
platform_specific: Default::default(),
|
platform_specific: Default::default(),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue