From 00d6baf861ba57984a341283823e9fea3c262130 Mon Sep 17 00:00:00 2001 From: Richard Date: Wed, 15 Jun 2022 20:10:15 -0300 Subject: fix: temporalily remove the unsafe pointer `HWND` --- winit/src/settings.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'winit/src/settings.rs') diff --git a/winit/src/settings.rs b/winit/src/settings.rs index 9bbdef5c..94d243a7 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -154,9 +154,9 @@ impl Window { { use winit::platform::windows::WindowBuilderExtWindows; - if let Some(parent) = self.platform_specific.parent { - window_builder = window_builder.with_parent_window(parent); - } + // if let Some(parent) = self.platform_specific.parent { + // window_builder = window_builder.with_parent_window(parent); + // } window_builder = window_builder .with_drag_and_drop(self.platform_specific.drag_and_drop); -- cgit From dc86bd03733969033df7389c3d21e78ecc6291bb Mon Sep 17 00:00:00 2001 From: Richard Date: Wed, 27 Jul 2022 15:37:48 -0300 Subject: Introduce `close_requested` for `multi-window` --- winit/src/settings.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'winit/src/settings.rs') diff --git a/winit/src/settings.rs b/winit/src/settings.rs index 94d243a7..ea0ba361 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -46,6 +46,10 @@ pub struct Settings { /// Whether the [`Application`] should exit when the user requests the /// window to close (e.g. the user presses the close button). /// + /// NOTE: This is not used for `multi-window`, instead check [`Application::close_requested`]. + /// + /// [`close_requested`]: crate::multi_window::Application::close_requested + /// /// [`Application`]: crate::Application pub exit_on_close_request: bool, -- cgit From 1bc0c480f9747826b244c30e92d8c4a29b576e4a Mon Sep 17 00:00:00 2001 From: Richard Date: Wed, 19 Oct 2022 22:56:00 -0300 Subject: move window settings to `iced_native` --- winit/src/settings.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'winit/src/settings.rs') diff --git a/winit/src/settings.rs b/winit/src/settings.rs index ea0ba361..78c8c156 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -22,6 +22,7 @@ mod platform; pub use platform::PlatformSpecific; use crate::conversion; +use crate::Icon; use crate::Position; use winit::monitor::MonitorHandle; use winit::window::WindowBuilder; @@ -201,3 +202,23 @@ impl Default for Window { } } } + +impl From for Window { + fn from(settings: iced_native::window::Settings) -> Self { + Self { + size: settings.size, + position: Position::from(settings.position), + min_size: settings.min_size, + max_size: settings.max_size, + visible: settings.visible, + resizable: settings.resizable, + decorations: settings.decorations, + transparent: settings.transparent, + always_on_top: settings.always_on_top, + icon: settings.icon.and_then(|icon| { + Icon::try_from(icon).map(winit::window::Icon::from).ok() + }), + platform_specific: Default::default(), + } + } +} -- cgit From e36daa6f937abd7cb2071fd8852a3c12263944ea Mon Sep 17 00:00:00 2001 From: bungoboingo Date: Tue, 28 Feb 2023 13:44:36 -0800 Subject: Removed glutin MW support and reverted glutin changes back to Iced master since it's being axed as we speak. --- winit/src/settings.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'winit/src/settings.rs') diff --git a/winit/src/settings.rs b/winit/src/settings.rs index b26de542..88d7c1de 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -179,9 +179,9 @@ impl Window { { use winit::platform::windows::WindowBuilderExtWindows; - // if let Some(parent) = self.platform_specific.parent { - // window_builder = window_builder.with_parent_window(parent); - // } + if let Some(parent) = self.platform_specific.parent { + window_builder = window_builder.with_parent_window(parent); + } window_builder = window_builder .with_drag_and_drop(self.platform_specific.drag_and_drop); @@ -227,7 +227,7 @@ impl From for Window { fn from(settings: iced_native::window::Settings) -> Self { Self { size: settings.size, - position: Position::from(settings.position), + position: settings.position, min_size: settings.min_size, max_size: settings.max_size, visible: settings.visible, -- cgit From d53ccc857da4d4cda769904342aeb5a82a64f146 Mon Sep 17 00:00:00 2001 From: Bingus Date: Wed, 12 Jul 2023 19:21:05 -0700 Subject: refactored window storage; new helper window events (Destroyed, Created); clippy + fmt; --- winit/src/settings.rs | 246 +++++++++++++++----------------------------------- 1 file changed, 74 insertions(+), 172 deletions(-) (limited to 'winit/src/settings.rs') diff --git a/winit/src/settings.rs b/winit/src/settings.rs index 40b3d487..2b846fbd 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -1,35 +1,10 @@ //! Configure your application. -#[cfg(target_os = "windows")] -#[path = "settings/windows.rs"] -mod platform; - -#[cfg(target_os = "macos")] -#[path = "settings/macos.rs"] -mod platform; - -#[cfg(target_arch = "wasm32")] -#[path = "settings/wasm.rs"] -mod platform; - -#[cfg(not(any( - target_os = "windows", - target_os = "macos", - target_arch = "wasm32" -)))] -#[path = "settings/other.rs"] -mod platform; - -pub use platform::PlatformSpecific; - use crate::conversion; -use crate::core::window::{Icon, Level}; -use crate::Position; +use crate::core::window; use winit::monitor::MonitorHandle; use winit::window::WindowBuilder; -use std::fmt; - /// The settings of an application. #[derive(Debug, Clone, Default)] pub struct Settings { @@ -40,7 +15,7 @@ pub struct Settings { pub id: Option, /// The [`Window`] settings. - pub window: Window, + pub window: window::Settings, /// The data needed to initialize an [`Application`]. /// @@ -50,166 +25,93 @@ pub struct Settings { /// Whether the [`Application`] should exit when the user requests the /// window to close (e.g. the user presses the close button). /// + /// With a [`multi_window::Application`] this will instead be used to determine whether the + /// application should exit when the "main"" window is closed, i.e. the first window created on + /// app launch. + /// /// [`Application`]: crate::Application pub exit_on_close_request: bool, } -/// The window settings of an application. -#[derive(Clone)] -pub struct Window { - /// The size of the window. - pub size: (u32, u32), - - /// The position of the window. - pub position: Position, - - /// The minimum size of the window. - pub min_size: Option<(u32, u32)>, - - /// The maximum size of the window. - pub max_size: Option<(u32, u32)>, - - /// Whether the window should be visible or not. - pub visible: bool, - - /// Whether the window should be resizable or not. - pub resizable: bool, - - /// Whether the window should have a border, a title bar, etc. - pub decorations: bool, - - /// Whether the window should be transparent. - pub transparent: bool, - - /// The window [`Level`]. - pub level: Level, - - /// The window icon, which is also usually used in the taskbar - pub icon: Option, - - /// Platform specific settings. - pub platform_specific: platform::PlatformSpecific, -} - -impl fmt::Debug for Window { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Window") - .field("size", &self.size) - .field("position", &self.position) - .field("min_size", &self.min_size) - .field("max_size", &self.max_size) - .field("visible", &self.visible) - .field("resizable", &self.resizable) - .field("decorations", &self.decorations) - .field("transparent", &self.transparent) - .field("level", &self.level) - .field("icon", &self.icon.is_some()) - .field("platform_specific", &self.platform_specific) - .finish() +/// Converts the window settings into a `WindowBuilder` from `winit`. +pub fn window_builder( + settings: window::Settings, + title: &str, + monitor: Option, + _id: Option, +) -> WindowBuilder { + let mut window_builder = WindowBuilder::new(); + + let (width, height) = settings.size; + + window_builder = window_builder + .with_title(title) + .with_inner_size(winit::dpi::LogicalSize { width, height }) + .with_resizable(settings.resizable) + .with_decorations(settings.decorations) + .with_transparent(settings.transparent) + .with_window_icon(settings.icon.and_then(conversion::icon)) + .with_window_level(conversion::window_level(settings.level)) + .with_visible(settings.visible); + + if let Some(position) = + conversion::position(monitor.as_ref(), settings.size, settings.position) + { + window_builder = window_builder.with_position(position); } -} - -impl Window { - /// Converts the window settings into a `WindowBuilder` from `winit`. - pub fn into_builder( - self, - title: &str, - primary_monitor: Option, - _id: Option, - ) -> WindowBuilder { - let mut window_builder = WindowBuilder::new(); - - let (width, height) = self.size; + if let Some((width, height)) = settings.min_size { window_builder = window_builder - .with_title(title) - .with_inner_size(winit::dpi::LogicalSize { width, height }) - .with_resizable(self.resizable) - .with_decorations(self.decorations) - .with_transparent(self.transparent) - .with_window_icon(self.icon.and_then(conversion::icon)) - .with_window_level(conversion::window_level(self.level)) - .with_visible(self.visible); - - if let Some(position) = conversion::position( - primary_monitor.as_ref(), - self.size, - self.position, - ) { - window_builder = window_builder.with_position(position); - } - - if let Some((width, height)) = self.min_size { - window_builder = window_builder - .with_min_inner_size(winit::dpi::LogicalSize { width, height }); - } + .with_min_inner_size(winit::dpi::LogicalSize { width, height }); + } - if let Some((width, height)) = self.max_size { - window_builder = window_builder - .with_max_inner_size(winit::dpi::LogicalSize { width, height }); - } + if let Some((width, height)) = settings.max_size { + window_builder = window_builder + .with_max_inner_size(winit::dpi::LogicalSize { width, height }); + } - #[cfg(any( - target_os = "linux", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", - target_os = "openbsd" - ))] - { - // `with_name` is available on both `WindowBuilderExtWayland` and `WindowBuilderExtX11` and they do - // exactly the same thing. We arbitrarily choose `WindowBuilderExtWayland` here. - use ::winit::platform::wayland::WindowBuilderExtWayland; - - if let Some(id) = _id { - window_builder = window_builder.with_name(id.clone(), id); - } + #[cfg(any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd", + target_os = "openbsd" + ))] + { + // `with_name` is available on both `WindowBuilderExtWayland` and `WindowBuilderExtX11` and they do + // exactly the same thing. We arbitrarily choose `WindowBuilderExtWayland` here. + use ::winit::platform::wayland::WindowBuilderExtWayland; + + if let Some(id) = _id { + window_builder = window_builder.with_name(id.clone(), id); } + } - #[cfg(target_os = "windows")] - { - use winit::platform::windows::WindowBuilderExtWindows; - #[allow(unsafe_code)] - unsafe { - window_builder = window_builder - .with_parent_window(self.platform_specific.parent); - } + #[cfg(target_os = "windows")] + { + use winit::platform::windows::WindowBuilderExtWindows; + #[allow(unsafe_code)] + unsafe { window_builder = window_builder - .with_drag_and_drop(self.platform_specific.drag_and_drop); + .with_parent_window(settings.platform_specific.parent); } + window_builder = window_builder + .with_drag_and_drop(settings.platform_specific.drag_and_drop); + } - #[cfg(target_os = "macos")] - { - use winit::platform::macos::WindowBuilderExtMacOS; - - window_builder = window_builder - .with_title_hidden(self.platform_specific.title_hidden) - .with_titlebar_transparent( - self.platform_specific.titlebar_transparent, - ) - .with_fullsize_content_view( - self.platform_specific.fullsize_content_view, - ); - } + #[cfg(target_os = "macos")] + { + use winit::platform::macos::WindowBuilderExtMacOS; - window_builder + window_builder = window_builder + .with_title_hidden(settings.platform_specific.title_hidden) + .with_titlebar_transparent( + settings.platform_specific.titlebar_transparent, + ) + .with_fullsize_content_view( + settings.platform_specific.fullsize_content_view, + ); } -} -impl Default for Window { - fn default() -> Window { - Window { - size: (1024, 768), - position: Position::default(), - min_size: None, - max_size: None, - visible: true, - resizable: true, - decorations: true, - transparent: false, - level: Level::default(), - icon: None, - platform_specific: Default::default(), - } - } + window_builder } -- cgit From 83c7870c569a2976923ee6243a19813094d44673 Mon Sep 17 00:00:00 2001 From: Bingus Date: Mon, 24 Jul 2023 14:32:59 -0700 Subject: Moved `exit_on_close_request` to window settings. This now controls whether each INDIVIDUAL window should close on CloseRequested events. --- winit/src/settings.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'winit/src/settings.rs') diff --git a/winit/src/settings.rs b/winit/src/settings.rs index 2b846fbd..c0b3b047 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -1,6 +1,6 @@ //! Configure your application. -use crate::conversion; use crate::core::window; +use crate::conversion; use winit::monitor::MonitorHandle; use winit::window::WindowBuilder; @@ -21,16 +21,6 @@ pub struct Settings { /// /// [`Application`]: crate::Application pub flags: Flags, - - /// Whether the [`Application`] should exit when the user requests the - /// window to close (e.g. the user presses the close button). - /// - /// With a [`multi_window::Application`] this will instead be used to determine whether the - /// application should exit when the "main"" window is closed, i.e. the first window created on - /// app launch. - /// - /// [`Application`]: crate::Application - pub exit_on_close_request: bool, } /// Converts the window settings into a `WindowBuilder` from `winit`. -- cgit From e7326f0af6f16cf2ff04fbac93bf296a044923f4 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 18 Sep 2023 19:07:41 +0200 Subject: Flesh out the `editor` example a bit more --- winit/src/settings.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'winit/src/settings.rs') diff --git a/winit/src/settings.rs b/winit/src/settings.rs index 8d3e1b47..b4a1dd61 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -33,6 +33,7 @@ use crate::Position; use winit::monitor::MonitorHandle; use winit::window::WindowBuilder; +use std::borrow::Cow; use std::fmt; /// The settings of an application. @@ -52,6 +53,9 @@ pub struct Settings { /// [`Application`]: crate::Application pub flags: Flags, + /// The fonts to load on boot. + pub fonts: Vec>, + /// Whether the [`Application`] should exit when the user requests the /// window to close (e.g. the user presses the close button). /// -- cgit From c07315b84eb59daeb9bbe7480f30dc0937ceca13 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 27 Oct 2023 05:53:29 +0200 Subject: Disable maximize window button if `Settings::resizable` is `false` --- winit/src/settings.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'winit/src/settings.rs') diff --git a/winit/src/settings.rs b/winit/src/settings.rs index 867dad0f..16c9fcdc 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -130,6 +130,12 @@ impl Window { .with_title(title) .with_inner_size(winit::dpi::LogicalSize { width, height }) .with_resizable(self.resizable) + .with_enabled_buttons(if self.resizable { + winit::window::WindowButtons::all() + } else { + winit::window::WindowButtons::CLOSE + | winit::window::WindowButtons::MINIMIZE + }) .with_decorations(self.decorations) .with_transparent(self.transparent) .with_window_icon(self.icon.and_then(conversion::icon)) -- cgit From 6740c2c5d6b24399dab1343abdfec5daf4b03c98 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 29 Nov 2023 22:46:47 +0100 Subject: Fix broken intra-doc links --- winit/src/settings.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'winit/src/settings.rs') diff --git a/winit/src/settings.rs b/winit/src/settings.rs index dc0f65a5..2e541128 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -12,7 +12,7 @@ pub struct Settings { /// communicate with it through the windowing system. pub id: Option, - /// The [`Window`] settings. + /// The [`window::Settings`]. pub window: window::Settings, /// The data needed to initialize an [`Application`]. -- cgit