summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Yiğit Özdemir <yigitozdemir1299@gmail.com>2023-06-22 18:28:32 +0300
committerLibravatar Yiğit Özdemir <yigitozdemir1299@gmail.com>2023-06-22 18:28:32 +0300
commitb394c84b37eacb266d45663d5d6626f1b616af7e (patch)
tree2f364d9f5896e52d0185668ffe0c8c83bf7d665c
parent21a71b753d6da2233bce913f4e623ee14859ec23 (diff)
downloadiced-b394c84b37eacb266d45663d5d6626f1b616af7e.tar.gz
iced-b394c84b37eacb266d45663d5d6626f1b616af7e.tar.bz2
iced-b394c84b37eacb266d45663d5d6626f1b616af7e.zip
Add FetchSize command - apply the changes discussed at #water-cooler
-rw-r--r--core/src/window.rs4
-rw-r--r--core/src/window/fetch_size.rs8
-rw-r--r--runtime/src/window/action.rs18
-rw-r--r--winit/src/application.rs15
4 files changed, 7 insertions, 38 deletions
diff --git a/core/src/window.rs b/core/src/window.rs
index cd343893..4beebf9f 100644
--- a/core/src/window.rs
+++ b/core/src/window.rs
@@ -6,12 +6,10 @@ mod level;
mod mode;
mod redraw_request;
mod user_attention;
-mod fetch_size;
pub use event::Event;
pub use icon::Icon;
pub use level::Level;
pub use mode::Mode;
pub use redraw_request::RedrawRequest;
-pub use user_attention::UserAttention;
-pub use fetch_size::SizeType; \ No newline at end of file
+pub use user_attention::UserAttention; \ No newline at end of file
diff --git a/core/src/window/fetch_size.rs b/core/src/window/fetch_size.rs
deleted file mode 100644
index aa3431aa..00000000
--- a/core/src/window/fetch_size.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-/// A `struct` defining which size to fetch.
-#[derive(Debug, Clone, Copy)]
-pub enum SizeType {
- /// Inner size. (not including title bars and so other OS decorations)
- Inner,
- /// Outer size. (including everything)
- Outer,
-} \ No newline at end of file
diff --git a/runtime/src/window/action.rs b/runtime/src/window/action.rs
index 4ea9d474..551d0a01 100644
--- a/runtime/src/window/action.rs
+++ b/runtime/src/window/action.rs
@@ -1,7 +1,3 @@
-
-
-use iced_core::window::SizeType;
-
use crate::core::window::{Icon, Level, Mode, UserAttention};
use crate::futures::MaybeSend;
@@ -25,12 +21,7 @@ pub enum Action<T> {
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>,
- },
+ FetchSize(Box<dyn FnOnce((u32, u32)) -> T + 'static>),
/// Set the window to maximized or back
Maximize(bool),
/// Set the window to minimized or back
@@ -115,10 +106,7 @@ 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::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 },
@@ -146,7 +134,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::FetchSize(_) => write!(f, "Action::FetchSize"),
Self::Maximize(maximized) => {
write!(f, "Action::Maximize({maximized})")
}
diff --git a/winit/src/application.rs b/winit/src/application.rs
index ff5afa69..b0824e0e 100644
--- a/winit/src/application.rs
+++ b/winit/src/application.rs
@@ -3,7 +3,6 @@
mod profiler;
mod state;
-use iced_graphics::core::window::SizeType;
pub use state::State;
use crate::conversion;
@@ -748,19 +747,11 @@ pub fn run_command<A, E>(
height,
});
}
- window::Action::FetchSize {
- size_type,
- callback,
- } => {
- let width_height = match size_type {
- SizeType::Inner => window.inner_size(),
- SizeType::Outer => window.outer_size(),
- };
- let width_height =
- (width_height.width, width_height.height);
+ window::Action::FetchSize(callback) => {
+ let size = window.inner_size();
proxy
- .send_event(callback(width_height))
+ .send_event(callback((size.width, size.height)))
.expect("Send message to event loop")
}
window::Action::Maximize(maximized) => {