-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: avoid CentralPanel overflowing in a window #7042
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
base: main
Are you sure you want to change the base?
Conversation
Preview available at https://egui-pr-preview.github.io/pr/7042-window-panel-overflow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix! To add tests, the easiest would be to add a new kittest test to tests/egui_tests, the test could just simply be a screenshot test with the repro you provided.
crates/egui/src/containers/panel.rs
Outdated
let inner_response = frame.show(&mut panel_ui, |ui| { | ||
ui.expand_to_include_rect(ui.max_rect()); // Expand frame to include it all | ||
add_contents(ui) | ||
}) | ||
}); | ||
|
||
ui.expand_to_include_rect(inner_response.response.rect); | ||
|
||
inner_response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think instead of ui.new_child
we could also do ui.scope_builder which should do the expand_to_include_rect
for us. Might be a bit cleaner.
.layout(Layout::top_down(Align::Min)), | ||
); | ||
panel_ui.set_clip_rect(panel_rect); // If we overflow, don't do so visibly (#4475) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me like scope_builder doesn't preserve the same behavior with set_clip_rect. This might break some things, but I'm not sure?
Regarding using scope_builder rather than new_child, the other panel implementations (SidePanel, TopBottomPanel) also use new_child. Is this something we would want to change? |
Old behavior:
New behavior:
I'd ideally add a test for this but I'm not sure how to go about doing that.