Skip to content

Commit

Permalink
Update window.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
rustbasic authored May 4, 2024
1 parent 394afaf commit 77ef8ed
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions crates/egui/src/containers/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,16 +459,15 @@ impl<'open> Window<'open> {
let resize = resize.resizable(false); // We resize it manually
let mut resize = resize.id(resize_id);

let mut prepared_area = area.begin(ctx);
let last_frame_outer_rect = prepared_area.state().rect();

// Prevent window from becoming larger than the screen rect.
{
let max_size = ctx.screen_rect().size() - margins;
resize.max_size.x = resize.max_size.x.min(max_size.x);
resize.max_size.y = resize.max_size.y.min(max_size.y);
let screen_rect_size = ctx.screen_rect().size() - margins;
resize.max_size = resize.max_size.at_most(screen_rect_size);
}

let mut prepared_area = area.begin(ctx);
let last_frame_outer_rect = prepared_area.state().rect();

if let Some(mut resize_state) = resize::State::load(ctx, resize_id) {
resize_state.desired_size = last_frame_outer_rect.size() - margins;
resize_state.store(ctx, resize_id);
Expand Down

0 comments on commit 77ef8ed

Please sign in to comment.