Skip to content

Commit 4a81ca8

Browse files
authored
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.
1 parent bfaf1b4 commit 4a81ca8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

crates/egui/src/containers/panel.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,9 @@ impl Panel {
950950
/// A panel that covers the remainder of the screen,
951951
/// i.e. whatever area is left after adding other panels.
952952
///
953+
/// This acts very similar to [`Frame::central_panel`], but always expands
954+
/// to use up all available space.
955+
///
953956
/// The order in which you add panels matter!
954957
/// The first panel you add will always be the outermost, and the last you add will always be the innermost.
955958
///
@@ -1022,10 +1025,15 @@ impl CentralPanel {
10221025
panel_ui.set_clip_rect(panel_rect); // If we overflow, don't do so visibly (#4475)
10231026

10241027
let frame = frame.unwrap_or_else(|| Frame::central_panel(ui.style()));
1025-
frame.show(&mut panel_ui, |ui| {
1028+
let response = frame.show(&mut panel_ui, |ui| {
10261029
ui.expand_to_include_rect(ui.max_rect()); // Expand frame to include it all
10271030
add_contents(ui)
1028-
})
1031+
});
1032+
1033+
// Use up space in the parent:
1034+
ui.advance_cursor_after_rect(response.response.rect);
1035+
1036+
response
10291037
}
10301038

10311039
/// Show the panel at the top level.

0 commit comments

Comments
 (0)