8000 Bug fix: report latest area size in `Area::show` response by emilk · Pull Request #4710 · emilk/egui · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Bug fix: report latest area size in Area::show response #4710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions crates/egui/src/containers/area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,15 +544,21 @@ impl Prepared {
kind: _,
layer_id,
mut state,
move_response,
move_response: mut response,
..
} = self;

state.size = content_ui.min_size();

// Make sure we report back the correct size.
// Very important after the initial sizing pass, when the initial estimate of the size is way off.
let final_rect = state.rect();
response.rect = final_rect;
response.interact_rect = final_rect;

ctx.memory_mut(|m| m.areas_mut().set_state(layer_id, state));

move_response
response
}
}

Expand Down
6 changes: 4 additions & 2 deletions crates/egui/src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,17 @@ fn menu_popup<'c, R>(
.inner
});

let area_rect = area_response.response.rect;

menu_state_arc.write().rect = if sizing_pass {
// During the sizing pass we didn't know the size yet,
// so we might have just constrained the position unnecessarily.
// Therefore keep the original=desired position until the next frame.
Rect::from_min_size(pos, area_response.response.rect.size())
Rect::from_min_size(pos, area_rect.size())
} else {
// We knew the size, and this is where it ended up (potentially constrained to screen).
// Remember it for the future:
area_response.response.rect
area_rect
};

area_response
Expand Down
Loading
0