diff options
author | 2023-11-30 23:40:33 +0100 | |
---|---|---|
committer | 2023-11-30 23:40:33 +0100 | |
commit | 67408311f45d341509538f8cc185978da66b6ace (patch) | |
tree | 27b020da7eda4c77f07000e49335f5e0d482feba /runtime | |
parent | 9f29aec128ccf51c620a8b69a9fbd64186ab8c65 (diff) | |
download | iced-67408311f45d341509538f8cc185978da66b6ace.tar.gz iced-67408311f45d341509538f8cc185978da66b6ace.tar.bz2 iced-67408311f45d341509538f8cc185978da66b6ace.zip |
Use actual floats for logical coordinates
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/src/window.rs | 13 | ||||
-rw-r--r-- | runtime/src/window/action.rs | 25 |
2 files changed, 15 insertions, 23 deletions
diff --git a/runtime/src/window.rs b/runtime/src/window.rs index 375ce889..f46ac1b8 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -10,7 +10,7 @@ pub use screenshot::Screenshot; use crate::command::{self, Command}; use crate::core::time::Instant; use crate::core::window::{self, Event, Icon, Level, Mode, UserAttention}; -use crate::core::Size; +use crate::core::{Point, Size}; use crate::futures::event; use crate::futures::Subscription; @@ -48,17 +48,14 @@ pub fn drag<Message>(id: window::Id) -> Command<Message> { } /// Resizes the window to the given logical dimensions. -pub fn resize<Message>( - id: window::Id, - new_size: Size<u32>, -) -> Command<Message> { +pub fn resize<Message>(id: window::Id, new_size: Size) -> Command<Message> { Command::single(command::Action::Window(id, Action::Resize(new_size))) } /// Fetches the window's size in logical dimensions. pub fn fetch_size<Message>( id: window::Id, - f: impl FnOnce(Size<u32>) -> Message + 'static, + f: impl FnOnce(Size) -> Message + 'static, ) -> Command<Message> { Command::single(command::Action::Window(id, Action::FetchSize(Box::new(f)))) } @@ -74,8 +71,8 @@ pub fn minimize<Message>(id: window::Id, minimized: bool) -> Command<Message> { } /// Moves the window to the given logical coordinates. -pub fn move_to<Message>(id: window::Id, x: i32, y: i32) -> Command<Message> { - Command::single(command::Action::Window(id, Action::Move { x, y })) +pub fn move_to<Message>(id: window::Id, position: Point) -> Command<Message> { + Command::single(command::Action::Window(id, Action::Move(position))) } /// Changes the [`Mode`] of the window. diff --git a/runtime/src/window/action.rs b/runtime/src/window/action.rs index 2a31bbd6..5afe0389 100644 --- a/runtime/src/window/action.rs +++ b/runtime/src/window/action.rs @@ -1,5 +1,5 @@ use crate::core::window::{Icon, Level, Mode, Settings, UserAttention}; -use crate::core::Size; +use crate::core::{Point, Size}; use crate::futures::MaybeSend; use crate::window::Screenshot; @@ -20,23 +20,18 @@ pub enum Action<T> { /// The settings of the window. settings: Settings, }, - /// Resize the window. - Resize(Size<u32>), - /// Fetch the current size of the window. - FetchSize(Box<dyn FnOnce(Size<u32>) -> T + 'static>), + /// Resize the window to the given logical dimensions. + Resize(Size), + /// Fetch the current logical dimensions of the window. + FetchSize(Box<dyn FnOnce(Size) -> T + 'static>), /// Set the window to maximized or back Maximize(bool), /// Set the window to minimized or back Minimize(bool), - /// Move the window. + /// Move the window to the given logical coordinates. /// /// Unsupported on Wayland. - Move { - /// The new logical x location of the window - x: i32, - /// The new logical y location of the window - y: i32, - }, + Move(Point), /// Change the [`Mode`] of the window. ChangeMode(Mode), /// Fetch the current [`Mode`] of the window. @@ -114,7 +109,7 @@ impl<T> Action<T> { Self::FetchSize(o) => Action::FetchSize(Box::new(move |s| f(o(s)))), Self::Maximize(maximized) => Action::Maximize(maximized), Self::Minimize(minimized) => Action::Minimize(minimized), - Self::Move { x, y } => Action::Move { x, y }, + Self::Move(position) => Action::Move(position), Self::ChangeMode(mode) => Action::ChangeMode(mode), Self::FetchMode(o) => Action::FetchMode(Box::new(move |s| f(o(s)))), Self::ToggleMaximize => Action::ToggleMaximize, @@ -151,8 +146,8 @@ impl<T> fmt::Debug for Action<T> { Self::Minimize(minimized) => { write!(f, "Action::Minimize({minimized}") } - Self::Move { x, y } => { - write!(f, "Action::Move {{ x: {x}, y: {y} }}") + Self::Move(position) => { + write!(f, "Action::Move({position})") } Self::ChangeMode(mode) => write!(f, "Action::SetMode({mode:?})"), Self::FetchMode(_) => write!(f, "Action::FetchMode"), |