Browse Source

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>
pull/4207/head
rustbasic 8 months ago
committed by GitHub
parent
commit
769199648d
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 10
      crates/egui/src/containers/window.rs

10
crates/egui/src/containers/window.rs

@ -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 =

Loading…
Cancel
Save