Add fetch_size helper to runtime::window

This commit is contained in:
Héctor Ramón Jiménez 2023-07-06 06:44:09 +02:00
parent f43a272d7d
commit f350a2f812
No known key found for this signature in database
GPG key ID: 140CC052C94F138E

View file

@ -39,6 +39,13 @@ 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.
pub fn maximize<Message>(maximized: bool) -> Command<Message> {
Command::single(command::Action::Window(Action::Maximize(maximized)))