window tasks for setting min and max size
This commit is contained in:
parent
ca8aaf9b8d
commit
8ebbfa9767
2 changed files with 36 additions and 0 deletions
|
|
@ -158,6 +158,12 @@ pub enum Action {
|
|||
/// This enables mouse events for the window and stops mouse events
|
||||
/// from being passed to whatever is underneath.
|
||||
DisableMousePassthrough(Id),
|
||||
|
||||
/// Set the minimum inner window size.
|
||||
SetMinSize(Id, Option<Size>),
|
||||
|
||||
/// Set the maximum inner window size.
|
||||
SetMaxSize(Id, Option<Size>),
|
||||
}
|
||||
|
||||
/// Subscribes to the frames of the window of the running application.
|
||||
|
|
@ -376,6 +382,16 @@ pub fn change_title<T>(id: Id, title: String) -> Task<T> {
|
|||
task::effect(crate::Action::Window(Action::ChangeTitle(id, title)))
|
||||
}
|
||||
|
||||
/// Set the inner maximum size of the window.
|
||||
pub fn set_max_size<T>(id: Id, size: Option<Size>) -> Task<T> {
|
||||
task::effect(crate::Action::Window(Action::SetMaxSize(id, size)))
|
||||
}
|
||||
|
||||
/// Set the inner minimum size of the window.
|
||||
pub fn set_min_size<T>(id: Id, size: Option<Size>) -> Task<T> {
|
||||
task::effect(crate::Action::Window(Action::SetMinSize(id, size)))
|
||||
}
|
||||
|
||||
/// Show the [system menu] at cursor position.
|
||||
///
|
||||
/// [system menu]: https://en.wikipedia.org/wiki/Common_menus_in_Microsoft_Windows#System_menu
|
||||
|
|
|
|||
|
|
@ -1291,6 +1291,26 @@ fn run_action<P, C>(
|
|||
);
|
||||
}
|
||||
}
|
||||
window::Action::SetMinSize(id, size) => {
|
||||
if let Some(window) = window_manager.get_mut(id) {
|
||||
window.raw.set_min_inner_size(size.map(|x| {
|
||||
winit::dpi::LogicalSize {
|
||||
width: x.width,
|
||||
height: x.height,
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
window::Action::SetMaxSize(id, size) => {
|
||||
if let Some(window) = window_manager.get_mut(id) {
|
||||
window.raw.set_max_inner_size(size.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