summaryrefslogtreecommitdiffstats
path: root/runtime/src/window
diff options
context:
space:
mode:
authorLibravatar Yiğit Özdemir <yigitozdemir1299@gmail.com>2023-06-21 19:43:20 +0300
committerLibravatar Yiğit Özdemir <yigitozdemir1299@gmail.com>2023-06-21 19:43:20 +0300
commit21a71b753d6da2233bce913f4e623ee14859ec23 (patch)
tree5293118e70f65b4f3805b508dad9a8185e260e32 /runtime/src/window
parent59bb5a99aaefa13f01735e0b6b127fa498be902f (diff)
downloadiced-21a71b753d6da2233bce913f4e623ee14859ec23.tar.gz
iced-21a71b753d6da2233bce913f4e623ee14859ec23.tar.bz2
iced-21a71b753d6da2233bce913f4e623ee14859ec23.zip
Add command to retrieve window size
Diffstat (limited to 'runtime/src/window')
-rw-r--r--runtime/src/window/action.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/runtime/src/window/action.rs b/runtime/src/window/action.rs
index a9d2a3d0..4ea9d474 100644
--- a/runtime/src/window/action.rs
+++ b/runtime/src/window/action.rs
@@ -1,3 +1,7 @@
+
+
+use iced_core::window::SizeType;
+
use crate::core::window::{Icon, Level, Mode, UserAttention};
use crate::futures::MaybeSend;
@@ -20,6 +24,13 @@ pub enum Action<T> {
/// The new logical height of the window
height: u32,
},
+ /// Fetch the current size of the window.
+ FetchSize {
+ /// Which size to fetch
+ size_type: SizeType,
+ /// Callback function
+ callback: Box<dyn FnOnce((u32, u32)) -> T + 'static>,
+ },
/// Set the window to maximized or back
Maximize(bool),
/// Set the window to minimized or back
@@ -104,6 +115,10 @@ impl<T> Action<T> {
Self::Close => Action::Close,
Self::Drag => Action::Drag,
Self::Resize { width, height } => Action::Resize { width, height },
+ Self::FetchSize { size_type, callback } => Action::FetchSize {
+ size_type: size_type,
+ callback: Box::new(move |s| f(callback(s))),
+ },
Self::Maximize(maximized) => Action::Maximize(maximized),
Self::Minimize(minimized) => Action::Minimize(minimized),
Self::Move { x, y } => Action::Move { x, y },
@@ -131,6 +146,7 @@ impl<T> fmt::Debug for Action<T> {
f,
"Action::Resize {{ widget: {width}, height: {height} }}"
),
+ Self::FetchSize { size_type, .. } => write!(f, "Action::FetchSize {{ size_type: {size_type:?} }}"),
Self::Maximize(maximized) => {
write!(f, "Action::Maximize({maximized})")
}