diff options
Diffstat (limited to '')
-rw-r--r-- | native/src/window/settings.rs (renamed from src/window/settings.rs) | 18 | ||||
-rw-r--r-- | src/window.rs | 11 | ||||
-rw-r--r-- | src/window/position.rs | 32 | ||||
-rw-r--r-- | winit/src/icon.rs (renamed from src/window/icon.rs) | 21 |
4 files changed, 17 insertions, 65 deletions
diff --git a/src/window/settings.rs b/native/src/window/settings.rs index 24d0f4f9..67798fbe 100644 --- a/src/window/settings.rs +++ b/native/src/window/settings.rs @@ -50,21 +50,3 @@ impl Default for Settings { } } } - -impl From<Settings> for iced_winit::settings::Window { - fn from(settings: Settings) -> Self { - Self { - size: settings.size, - position: iced_winit::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.map(Icon::into), - platform_specific: Default::default(), - } - } -} diff --git a/src/window.rs b/src/window.rs index 2018053f..73e90243 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1,12 +1,7 @@ //! Configure the window of your application in native platforms. -mod position; -mod settings; - -pub mod icon; - -pub use icon::Icon; -pub use position::Position; -pub use settings::Settings; +pub use iced_native::window::Icon; +pub use iced_native::window::Position; +pub use iced_native::window::Settings; #[cfg(not(target_arch = "wasm32"))] pub use crate::runtime::window::*; diff --git a/src/window/position.rs b/src/window/position.rs deleted file mode 100644 index 6b9fac41..00000000 --- a/src/window/position.rs +++ /dev/null @@ -1,32 +0,0 @@ -/// The position of a window in a given screen. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum Position { - /// The platform-specific default position for a new window. - Default, - /// The window is completely centered on the screen. - Centered, - /// The window is positioned with specific coordinates: `(X, Y)`. - /// - /// When the decorations of the window are enabled, Windows 10 will add some - /// invisible padding to the window. This padding gets included in the - /// position. So if you have decorations enabled and want the window to be - /// at (0, 0) you would have to set the position to - /// `(PADDING_X, PADDING_Y)`. - Specific(i32, i32), -} - -impl Default for Position { - fn default() -> Self { - Self::Default - } -} - -impl From<Position> for iced_winit::Position { - fn from(position: Position) -> Self { - match position { - Position::Default => Self::Default, - Position::Centered => Self::Centered, - Position::Specific(x, y) => Self::Specific(x, y), - } - } -} diff --git a/src/window/icon.rs b/winit/src/icon.rs index bacad41a..84b88b39 100644 --- a/src/window/icon.rs +++ b/winit/src/icon.rs @@ -7,7 +7,7 @@ use std::path::Path; /// The icon of a window. #[derive(Debug, Clone)] -pub struct Icon(iced_winit::winit::window::Icon); +pub struct Icon(winit::window::Icon); impl Icon { /// Creates an icon from 32bpp RGBA data. @@ -16,8 +16,7 @@ impl Icon { width: u32, height: u32, ) -> Result<Self, Error> { - let raw = - iced_winit::winit::window::Icon::from_rgba(rgba, width, height)?; + let raw = winit::window::Icon::from_rgba(rgba, width, height)?; Ok(Icon(raw)) } @@ -91,9 +90,9 @@ impl From<std::io::Error> for Error { } } -impl From<iced_winit::winit::window::BadIcon> for Error { - fn from(error: iced_winit::winit::window::BadIcon) -> Self { - use iced_winit::winit::window::BadIcon; +impl From<winit::window::BadIcon> for Error { + fn from(error: winit::window::BadIcon) -> Self { + use winit::window::BadIcon; match error { BadIcon::ByteCountNotDivisibleBy4 { byte_count } => { @@ -114,7 +113,7 @@ impl From<iced_winit::winit::window::BadIcon> for Error { } } -impl From<Icon> for iced_winit::winit::window::Icon { +impl From<Icon> for winit::window::Icon { fn from(icon: Icon) -> Self { icon.0 } @@ -170,3 +169,11 @@ impl std::error::Error for Error { Some(self) } } + +impl TryFrom<iced_native::window::Icon> for Icon { + type Error = Error; + + fn try_from(icon: iced_native::window::Icon) -> Result<Self, Self::Error> { + Icon::from_rgba(icon.rgba, icon.width, icon.height) + } +} |