summaryrefslogtreecommitdiffstats
path: root/core/src/window
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-11-30 23:40:33 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-11-30 23:40:33 +0100
commit67408311f45d341509538f8cc185978da66b6ace (patch)
tree27b020da7eda4c77f07000e49335f5e0d482feba /core/src/window
parent9f29aec128ccf51c620a8b69a9fbd64186ab8c65 (diff)
downloadiced-67408311f45d341509538f8cc185978da66b6ace.tar.gz
iced-67408311f45d341509538f8cc185978da66b6ace.tar.bz2
iced-67408311f45d341509538f8cc185978da66b6ace.zip
Use actual floats for logical coordinates
Diffstat (limited to 'core/src/window')
-rw-r--r--core/src/window/event.rs18
-rw-r--r--core/src/window/position.rs6
-rw-r--r--core/src/window/settings.rs11
3 files changed, 19 insertions, 16 deletions
diff --git a/core/src/window/event.rs b/core/src/window/event.rs
index f7759435..3ab7cd81 100644
--- a/core/src/window/event.rs
+++ b/core/src/window/event.rs
@@ -1,10 +1,10 @@
use crate::time::Instant;
-use crate::Size;
+use crate::{Point, Size};
use std::path::PathBuf;
/// A window-related event.
-#[derive(PartialEq, Eq, Clone, Debug)]
+#[derive(PartialEq, Clone, Debug)]
pub enum Event {
/// A window was moved.
Moved {
@@ -30,22 +30,22 @@ pub enum Event {
/// The user has requested for the window to close.
CloseRequested,
- /// A window was destroyed by the runtime.
- Destroyed,
-
/// A window was created.
- ///
- /// **Note:** this event is not supported on Wayland.
Created {
/// The position of the created window. This is relative to the top-left corner of the desktop
/// the window is on, including virtual desktops. Refers to window's "inner" position,
/// or the client area, in logical pixels.
- position: (i32, i32),
+ ///
+ /// **Note**: Not available in Wayland.
+ position: Option<Point>,
/// The size of the created window. This is its "inner" size, or the size of the
/// client area, in logical pixels.
- size: Size<u32>,
+ size: Size,
},
+ /// A window was destroyed by the runtime.
+ Destroyed,
+
/// A window was focused.
Focused,
diff --git a/core/src/window/position.rs b/core/src/window/position.rs
index c260c29e..73391e75 100644
--- a/core/src/window/position.rs
+++ b/core/src/window/position.rs
@@ -1,5 +1,7 @@
+use crate::Point;
+
/// The position of a window in a given screen.
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Position {
/// The platform-specific default position for a new window.
Default,
@@ -12,7 +14,7 @@ pub enum Position {
/// 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),
+ Specific(Point),
}
impl Default for Position {
diff --git a/core/src/window/settings.rs b/core/src/window/settings.rs
index 25df8159..fbbf86ab 100644
--- a/core/src/window/settings.rs
+++ b/core/src/window/settings.rs
@@ -25,22 +25,23 @@ mod platform;
mod platform;
use crate::window::{Icon, Level, Position};
+use crate::Size;
pub use platform::PlatformSpecific;
/// The window settings of an application.
#[derive(Debug, Clone)]
pub struct Settings {
- /// The initial size of the window.
- pub size: (u32, u32),
+ /// The initial logical dimensions of the window.
+ pub size: Size,
/// The initial position of the window.
pub position: Position,
/// The minimum size of the window.
- pub min_size: Option<(u32, u32)>,
+ pub min_size: Option<Size>,
/// The maximum size of the window.
- pub max_size: Option<(u32, u32)>,
+ pub max_size: Option<Size>,
/// Whether the window should be visible or not.
pub visible: bool,
@@ -77,7 +78,7 @@ pub struct Settings {
impl Default for Settings {
fn default() -> Self {
Self {
- size: (1024, 768),
+ size: Size::new(1024.0, 768.0),
position: Position::default(),
min_size: None,
max_size: None,