Merge pull request #1927 from thunderstorm010/master
Add command to retrieve window size
This commit is contained in:
commit
7f805bc5dd
3 changed files with 31 additions and 16 deletions
|
|
@ -1,4 +1,5 @@
|
|||
use crate::core::window::{Icon, Level, Mode, UserAttention};
|
||||
use crate::core::Size;
|
||||
use crate::futures::MaybeSend;
|
||||
use crate::window::Screenshot;
|
||||
|
||||
|
|
@ -15,12 +16,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(Size<u32>) -> T + 'static>),
|
||||
/// Set the window to maximized or back
|
||||
Maximize(bool),
|
||||
/// Set the window to minimized or back
|
||||
|
|
@ -106,7 +104,8 @@ 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),
|
||||
Self::Move { x, y } => Action::Move { x, y },
|
||||
|
|
@ -135,10 +134,8 @@ 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})")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue