From cc32bd4de09ee58c15d1b3f2cec4a79dc65dd035 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 6 Jul 2023 06:41:28 +0200 Subject: Use `Size` in both `Resize` and `FetchSize` window actions --- runtime/src/window.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'runtime/src/window.rs') diff --git a/runtime/src/window.rs b/runtime/src/window.rs index d4111293..094a713d 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -6,6 +6,7 @@ pub use action::Action; use crate::command::{self, Command}; use crate::core::time::Instant; use crate::core::window::{Event, Icon, Level, Mode, UserAttention}; +use crate::core::Size; use crate::futures::subscription::{self, Subscription}; /// Subscribes to the frames of the window of the running application. @@ -34,8 +35,8 @@ pub fn drag() -> Command { } /// Resizes the window to the given logical dimensions. -pub fn resize(width: u32, height: u32) -> Command { - Command::single(command::Action::Window(Action::Resize { width, height })) +pub fn resize(new_size: Size) -> Command { + Command::single(command::Action::Window(Action::Resize(new_size))) } /// Maximizes the window. -- cgit From f350a2f812487af9a43c36e28d9b904e76a66474 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 6 Jul 2023 06:44:09 +0200 Subject: Add `fetch_size` helper to `runtime::window` --- runtime/src/window.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'runtime/src/window.rs') diff --git a/runtime/src/window.rs b/runtime/src/window.rs index 094a713d..9356581a 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -39,6 +39,13 @@ pub fn resize(new_size: Size) -> Command { Command::single(command::Action::Window(Action::Resize(new_size))) } +/// Fetches the current window size in logical dimensions. +pub fn fetch_size( + f: impl FnOnce(Size) -> Message + 'static, +) -> Command { + Command::single(command::Action::Window(Action::FetchSize(Box::new(f)))) +} + /// Maximizes the window. pub fn maximize(maximized: bool) -> Command { Command::single(command::Action::Window(Action::Maximize(maximized))) -- cgit