summaryrefslogtreecommitdiffstats
path: root/runtime/src/window.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2023-07-06 07:00:15 +0200
committerLibravatar GitHub <noreply@github.com>2023-07-06 07:00:15 +0200
commit7f805bc5dd9ed38c904d83f9ea931eed6f3234bf (patch)
tree6f0b38ab20b8fa91e5bbcc001a5738bb83d5f20a /runtime/src/window.rs
parenta057f8811bfc47afc4271f05b92263a19122d888 (diff)
parentf350a2f812487af9a43c36e28d9b904e76a66474 (diff)
downloadiced-7f805bc5dd9ed38c904d83f9ea931eed6f3234bf.tar.gz
iced-7f805bc5dd9ed38c904d83f9ea931eed6f3234bf.tar.bz2
iced-7f805bc5dd9ed38c904d83f9ea931eed6f3234bf.zip
Merge pull request #1927 from thunderstorm010/master
Add command to retrieve window size
Diffstat (limited to 'runtime/src/window.rs')
-rw-r--r--runtime/src/window.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/runtime/src/window.rs b/runtime/src/window.rs
index e448edef..5219fbfd 100644
--- a/runtime/src/window.rs
+++ b/runtime/src/window.rs
@@ -9,6 +9,7 @@ pub use screenshot::Screenshot;
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.
@@ -37,8 +38,15 @@ pub fn drag<Message>() -> Command<Message> {
}
/// Resizes the window to the given logical dimensions.
-pub fn resize<Message>(width: u32, height: u32) -> Command<Message> {
- Command::single(command::Action::Window(Action::Resize { width, height }))
+pub fn resize<Message>(new_size: Size<u32>) -> Command<Message> {
+ Command::single(command::Action::Window(Action::Resize(new_size)))
+}
+
+/// Fetches the current window size in logical dimensions.
+pub fn fetch_size<Message>(
+ f: impl FnOnce(Size<u32>) -> Message + 'static,
+) -> Command<Message> {
+ Command::single(command::Action::Window(Action::FetchSize(Box::new(f))))
}
/// Maximizes the window.