Skip to content

Commit

Permalink
Update window.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
rustbasic authored Jun 1, 2024
1 parent d9610dd commit 0cb50d2
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions crates/egui/src/containers/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,18 +469,6 @@ impl<'open> Window<'open> {
resize.is_manually = true;
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 constrain rect.
let constrain_rect = prepared_area.constrain_rect();
let max_width = constrain_rect.width();
let max_height = constrain_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);
}

if let Some(mut resize_state) = resize::State::load(ctx, resize_id) {
let resizable = resize.is_resizable();
let scroll_enabled = scroll.scroll_enabled;
Expand All @@ -497,6 +485,18 @@ impl<'open> Window<'open> {
resize_state.store(ctx, 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 constrain rect.
let constrain_rect = prepared_area.constrain_rect();
let max_width = constrain_rect.width();
let max_height = constrain_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 resize_interaction =
resize_interaction(ctx, possible, area_layer_id, last_frame_outer_rect);
Expand Down

0 comments on commit 0cb50d2

Please sign in to comment.