summaryrefslogtreecommitdiffstats
path: root/winit/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-05-25 23:14:07 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-05-25 23:14:07 +0200
commita7fa7e40058188c95a790712e11b863a9f84cecb (patch)
tree988852e1e54e4af416332108983ee4ccf91e912a /winit/src
parentb924e866308d60432729932afc4c642a00575c43 (diff)
downloadiced-a7fa7e40058188c95a790712e11b863a9f84cecb.tar.gz
iced-a7fa7e40058188c95a790712e11b863a9f84cecb.tar.bz2
iced-a7fa7e40058188c95a790712e11b863a9f84cecb.zip
Introduce `window::Level` enum
... and add `level` field to `window::Settings`
Diffstat (limited to 'winit/src')
-rw-r--r--winit/src/conversion.rs13
-rw-r--r--winit/src/settings.rs18
2 files changed, 20 insertions, 11 deletions
diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs
index a9262184..904aa184 100644
--- a/winit/src/conversion.rs
+++ b/winit/src/conversion.rs
@@ -140,6 +140,19 @@ pub fn window_event(
}
}
+/// Converts a [`window::Level`] to a [`winit`] window level.
+///
+/// [`winit`]: https://github.com/rust-windowing/winit
+pub fn window_level(level: window::Level) -> winit::window::WindowLevel {
+ match level {
+ window::Level::Normal => winit::window::WindowLevel::Normal,
+ window::Level::AlwaysOnBottom => {
+ winit::window::WindowLevel::AlwaysOnBottom
+ }
+ window::Level::AlwaysOnTop => winit::window::WindowLevel::AlwaysOnTop,
+ }
+}
+
/// Converts a [`Position`] to a [`winit`] logical position for a given monitor.
///
/// [`winit`]: https://github.com/rust-windowing/winit
diff --git a/winit/src/settings.rs b/winit/src/settings.rs
index 13be3932..40b3d487 100644
--- a/winit/src/settings.rs
+++ b/winit/src/settings.rs
@@ -22,11 +22,11 @@ mod platform;
pub use platform::PlatformSpecific;
use crate::conversion;
-use crate::core::window::Icon;
+use crate::core::window::{Icon, Level};
use crate::Position;
use winit::monitor::MonitorHandle;
-use winit::window::{WindowBuilder, WindowLevel};
+use winit::window::WindowBuilder;
use std::fmt;
@@ -81,8 +81,8 @@ pub struct Window {
/// Whether the window should be transparent.
pub transparent: bool,
- /// Whether the window will always be on top of other windows.
- pub always_on_top: bool,
+ /// The window [`Level`].
+ pub level: Level,
/// The window icon, which is also usually used in the taskbar
pub icon: Option<Icon>,
@@ -102,7 +102,7 @@ impl fmt::Debug for Window {
.field("resizable", &self.resizable)
.field("decorations", &self.decorations)
.field("transparent", &self.transparent)
- .field("always_on_top", &self.always_on_top)
+ .field("level", &self.level)
.field("icon", &self.icon.is_some())
.field("platform_specific", &self.platform_specific)
.finish()
@@ -121,10 +121,6 @@ impl Window {
let (width, height) = self.size;
- let window_level = match self.always_on_top {
- true => WindowLevel::AlwaysOnTop,
- false => WindowLevel::Normal,
- };
window_builder = window_builder
.with_title(title)
.with_inner_size(winit::dpi::LogicalSize { width, height })
@@ -132,7 +128,7 @@ impl Window {
.with_decorations(self.decorations)
.with_transparent(self.transparent)
.with_window_icon(self.icon.and_then(conversion::icon))
- .with_window_level(window_level)
+ .with_window_level(conversion::window_level(self.level))
.with_visible(self.visible);
if let Some(position) = conversion::position(
@@ -211,7 +207,7 @@ impl Default for Window {
resizable: true,
decorations: true,
transparent: false,
- always_on_top: false,
+ level: Level::default(),
icon: None,
platform_specific: Default::default(),
}