Add MenuConfig::submenu_gap to override the hardcoded gap between a menu and its submenus - #8338
Open
kiwirm wants to merge 1 commit into
Open
Add MenuConfig::submenu_gap to override the hardcoded gap between a menu and its submenus#8338kiwirm wants to merge 1 commit into
MenuConfig::submenu_gap to override the hardcoded gap between a menu and its submenus#8338kiwirm wants to merge 1 commit into
Conversation
… menu and its submenus
|
Preview is being built... Preview will be available at https://egui-pr-preview.github.io/pr/8338-submenu-gap View snapshot changes at kitdiff |
lucasmerlin
reviewed
Aug 5, 2026
Comment on lines
+512
to
515
| let gap = menu_config | ||
| .submenu_gap | ||
| .unwrap_or_else(|| frame.total_margin().sum().x / 2.0 + 2.0); | ||
|
|
Collaborator
There was a problem hiding this comment.
Should this be
Suggested change
| let gap = menu_config | |
| .submenu_gap | |
| .unwrap_or_else(|| frame.total_margin().sum().x / 2.0 + 2.0); | |
| let gap = frame.total_margin().sum().x / 2.0 + menu_config | |
| .submenu_gap | |
| .unwrap_or(2.0); |
instead?
frame.total_margin().sum().x / 2.0 should basically mean "0 visual gap between the menus" which I think is what you'd expect when setting the gap to 0? Otherwise at 0 there would be some overlap.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The gap between a menu and the submenu it opens is hardcoded in
SubMenu::show(
frame.total_margin().sum().x / 2.0 + 2.0), so a submenu can't be placed flushagainst its parent — even with a zero menu margin a ~2px gap remains.
This adds an optional
submenu_gap: Option<f32>toMenuConfig(plus aMenuConfig::submenu_gap(f32)builder). When set it overrides the offset; whenNoneit falls back to the existing computed value, so existing menus areunaffected. Because a menu's
MenuConfigpropagates to its submenus, setting itonce on the root menu applies to the whole tree.