diff options
| author | 2023-07-06 06:41:28 +0200 | |
|---|---|---|
| committer | 2023-07-06 06:41:28 +0200 | |
| commit | cc32bd4de09ee58c15d1b3f2cec4a79dc65dd035 (patch) | |
| tree | 6b7494f453834a155596daf5c6e885fec44302e8 /runtime/src/window | |
| parent | b394c84b37eacb266d45663d5d6626f1b616af7e (diff) | |
| download | iced-cc32bd4de09ee58c15d1b3f2cec4a79dc65dd035.tar.gz iced-cc32bd4de09ee58c15d1b3f2cec4a79dc65dd035.tar.bz2 iced-cc32bd4de09ee58c15d1b3f2cec4a79dc65dd035.zip | |
Use `Size` in both `Resize` and `FetchSize` window actions
Diffstat (limited to '')
| -rw-r--r-- | runtime/src/window.rs | 5 | ||||
| -rw-r--r-- | runtime/src/window/action.rs | 17 | 
2 files changed, 8 insertions, 14 deletions
| 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<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)))  }  /// Maximizes the window. diff --git a/runtime/src/window/action.rs b/runtime/src/window/action.rs index 551d0a01..d0137895 100644 --- a/runtime/src/window/action.rs +++ b/runtime/src/window/action.rs @@ -1,4 +1,5 @@  use crate::core::window::{Icon, Level, Mode, UserAttention}; +use crate::core::Size;  use crate::futures::MaybeSend;  use std::fmt; @@ -14,14 +15,9 @@ pub enum Action<T> {      /// button was pressed immediately before this function is called.      Drag,      /// Resize the window. -    Resize { -        /// The new logical width of the window -        width: u32, -        /// The new logical height of the window -        height: u32, -    }, +    Resize(Size<u32>),      /// Fetch the current size of the window. -    FetchSize(Box<dyn FnOnce((u32, u32)) -> T + 'static>), +    FetchSize(Box<dyn FnOnce(Size<u32>) -> T + 'static>),      /// Set the window to maximized or back      Maximize(bool),      /// Set the window to minimized or back @@ -105,7 +101,7 @@ impl<T> Action<T> {          match self {              Self::Close => Action::Close,              Self::Drag => Action::Drag, -            Self::Resize { width, height } => Action::Resize { width, height }, +            Self::Resize(size) => Action::Resize(size),              Self::FetchSize(o) => Action::FetchSize(Box::new(move |s| f(o(s)))),              Self::Maximize(maximized) => Action::Maximize(maximized),              Self::Minimize(minimized) => Action::Minimize(minimized), @@ -130,10 +126,7 @@ impl<T> fmt::Debug for Action<T> {          match self {              Self::Close => write!(f, "Action::Close"),              Self::Drag => write!(f, "Action::Drag"), -            Self::Resize { width, height } => write!( -                f, -                "Action::Resize {{ widget: {width}, height: {height} }}" -            ), +            Self::Resize(size) => write!(f, "Action::Resize({size:?})"),              Self::FetchSize(_) => write!(f, "Action::FetchSize"),              Self::Maximize(maximized) => {                  write!(f, "Action::Maximize({maximized})") | 
