diff options
author | 2021-07-21 18:59:24 +0700 | |
---|---|---|
committer | 2021-07-21 18:59:24 +0700 | |
commit | 72b3bf95de3f11812b1541fe2ffea76a515aee79 (patch) | |
tree | 12e353e37b9a1313872edadd64207fe2c1e4ce9f /src/window/position.rs | |
parent | 6793a7e00dc96425ae720309182ec8b03c076111 (diff) | |
download | iced-72b3bf95de3f11812b1541fe2ffea76a515aee79.tar.gz iced-72b3bf95de3f11812b1541fe2ffea76a515aee79.tar.bz2 iced-72b3bf95de3f11812b1541fe2ffea76a515aee79.zip |
Improve `window::Position` API
Diffstat (limited to 'src/window/position.rs')
-rw-r--r-- | src/window/position.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/window/position.rs b/src/window/position.rs new file mode 100644 index 00000000..8535ef6a --- /dev/null +++ b/src/window/position.rs @@ -0,0 +1,33 @@ +/// 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 + } +} + +#[cfg(not(target_arch = "wasm32"))] +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), + } + } +} |