Prevent egui::Window from becoming larger than Viewport (#4199)

* Closes #3987  

* Closes #3988

There is a need to prevent egui::Window from becoming larger than the
Viewport.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
rustbasic 2024-03-21 21:47:25 +09:00 committed by GitHub
parent 0299663cdd
commit 769199648d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 0 deletions

View File

@ -431,6 +431,16 @@ impl<'open> Window<'open> {
(0.0, 0.0)
};
{
// Prevent window from becoming larger than the constraint rect and/or screen rect.
let screen_rect = ctx.screen_rect();
let max_rect = area.constrain_rect().unwrap_or(screen_rect);
let max_width = max_rect.width();
let max_height = max_rect.height() - title_bar_height;
resize.max_size.x = resize.max_size.x.min(max_width);
resize.max_size.y = resize.max_size.y.min(max_height);
}
// First check for resize to avoid frame delay:
let last_frame_outer_rect = area.state().rect();
let resize_interaction =