window task for setting resize increments
This commit is contained in:
parent
f5f075e5cd
commit
00b60d819b
2 changed files with 22 additions and 0 deletions
|
|
@ -167,6 +167,9 @@ pub enum Action {
|
|||
|
||||
/// Set the window to be resizable or not.
|
||||
SetResizable(Id, bool),
|
||||
|
||||
/// Set the window size increment.
|
||||
SetResizeIncrements(Id, Option<Size>),
|
||||
}
|
||||
|
||||
/// Subscribes to the frames of the window of the running application.
|
||||
|
|
@ -400,6 +403,15 @@ pub fn set_min_size<T>(id: Id, size: Option<Size>) -> Task<T> {
|
|||
task::effect(crate::Action::Window(Action::SetMinSize(id, size)))
|
||||
}
|
||||
|
||||
/// Set the window size increment.
|
||||
///
|
||||
/// This is usually used by apps such as terminal emulators that need "blocky" resizing.
|
||||
pub fn set_resize_increments<T>(id: Id, increments: Option<Size>) -> Task<T> {
|
||||
task::effect(crate::Action::Window(Action::SetResizeIncrements(
|
||||
id, increments,
|
||||
)))
|
||||
}
|
||||
|
||||
/// Show the [system menu] at cursor position.
|
||||
///
|
||||
/// [system menu]: https://en.wikipedia.org/wiki/Common_menus_in_Microsoft_Windows#System_menu
|
||||
|
|
|
|||
|
|
@ -1311,6 +1311,16 @@ fn run_action<P, C>(
|
|||
}));
|
||||
}
|
||||
}
|
||||
window::Action::SetResizeIncrements(id, increments) => {
|
||||
if let Some(window) = window_manager.get_mut(id) {
|
||||
window.raw.set_resize_increments(increments.map(|x| {
|
||||
winit::dpi::LogicalSize {
|
||||
width: x.width,
|
||||
height: x.height,
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
window::Action::ChangeTitle(id, title) => {
|
||||
if let Some(window) = window_manager.get_mut(id) {
|
||||
window.raw.set_title(&title);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue