Work around ComboBox's vertical misalignment on horizontal layouts - #8375
Open
justincredible wants to merge 4 commits into
Open
Work around ComboBox's vertical misalignment on horizontal layouts#8375justincredible wants to merge 4 commits into
ComboBox's vertical misalignment on horizontal layouts#8375justincredible wants to merge 4 commits into
Conversation
|
Preview available at https://egui-pr-preview.github.io/pr/8375-combo-box-align View snapshot changes at kitdiff |
justincredible
marked this pull request as ready for review
August 6, 2026 00:29
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.
Summary
The interact sized button is correctly aligned, but when the contents are added it grows downward from top, where the cross alignment could dictate upward from bottom or outward from middle growth. As noted in the issue, the alignment works with defaults styles because they satisfy the interact height and font size relationship, and the alignment can also be broken by reducing
Spacing::interact_size::ywithout modifying theFontId::sizeofTextStyle::Button.These changes simulate the three growth directions by mucking with the cursor.
Unaddressed Behaviour
"Currently" assumes the existing behaviour when the interact height and font size relationship is not satisfied, that is,
Spacing::interact_size::y< 1.2 *FontId::size.Vertical and Grid Layouts
Vertical layouts don't exhibit this issue, but can be included. I'm unfamiliar with grid layouts but this is mostly an issue with using multiple combo-boxes in a line.
Text Alignment
Currently, the
ComboBox's label and selected text are centered regardless of cross alignment; this is always the case. Moving the inner horizontalUiintocombo_box_dynfixes the label only and completely breaks wrapped widgets. I haven't considered it much.Nested Horizontals
Currently, a
horizontal()contained within a larger horizontal layout will misalign the outer layout in the same way a singlehorizontal()misaligns its widgets. Ironically, this behaviour improves the "horizontal_bottom()" layout. These changes fix the solitary bottom layout, but nesting a horizontal, while still aligned, is not correctly adjusted.Center Wrapped
Currently, I cannot reproduce this. So this is an introduced misbehaviour, but is still corrected when the relationship is satisfied.
Other Styles
The alignment could break again with some other combination of styles and layouts, but the style configurations that are explicitly referenced by the
ComboBoxhave been accounted for and re-establishing the interact height and font size relationship is likely to correct those situations.Alternatives
Other attempts solely within the
combo_box.rsfile were unfruitful, except for incorporating the user-level workaround:Integrated User-level Workaround
The oversized button is correctly cross-aligned (it goes below the other buttons for
Align::Minan equally above and below forAlign::Center). The button is no longer oversized when the user re-establishes the interact-font relationship.Extended MRE
This is a modified version of @J2ane's MRE which allows more convenient testing of the known configuration options. This was used for the above screnshots.
main.rs.tar.gz