1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 14:49:06 -04:00

Fix: ensure CentralPanel::show_inside allocates space in parent (#7778)

If the `CentralPanel` is the only thing in e.g. a `Window`, it needs to
let the parent `Ui` know how much space was used. Now it does.
This commit is contained in:
Emil Ernerfeldt
2025-12-15 18:20:55 +01:00
committed by GitHub
parent bfaf1b44f2
commit 4a81ca8dcf

View File

@@ -950,6 +950,9 @@ impl Panel {
/// A panel that covers the remainder of the screen,
/// i.e. whatever area is left after adding other panels.
///
/// This acts very similar to [`Frame::central_panel`], but always expands
/// to use up all available space.
///
/// The order in which you add panels matter!
/// The first panel you add will always be the outermost, and the last you add will always be the innermost.
///
@@ -1022,10 +1025,15 @@ impl CentralPanel {
panel_ui.set_clip_rect(panel_rect); // If we overflow, don't do so visibly (#4475)
let frame = frame.unwrap_or_else(|| Frame::central_panel(ui.style()));
frame.show(&mut panel_ui, |ui| {
let response = frame.show(&mut panel_ui, |ui| {
ui.expand_to_include_rect(ui.max_rect()); // Expand frame to include it all
add_contents(ui)
})
});
// Use up space in the parent:
ui.advance_cursor_after_rect(response.response.rect);
response
}
/// Show the panel at the top level.