-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Enables every combination of TextEdit and LayoutJob alignments
#7831
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/7831-TextEdit-fix View snapshot changes at kitdiff |
emilk
left a comment
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.
Very nice; thank you! Could you please also add a snapshot test for this? 🙏
See tests/egui_tests/tests/regression_tests.rs for a template to follow (put yours in tests/egui_tests/tests/test_text_edit.rs)
|
You don't need to test text editing (unless you want to). Just adding your nice 3x3 matrix and snapshot-testing that would be great. See for instance this: egui/tests/egui_tests/tests/regression_tests.rs Lines 38 to 63 in f26d7d8
|
|
I've added the regression test! Ended up settling for a single snapshot, which should be good enough to showcase both visual alignment in a few scenarios as well as correct cursor placement. |


This is a fix/improvement that makes all kinds of alignments work in
TextEditwhen a customLayoutJobwith halign is used.I used the simplest approach possible to avoid unwanted bugs as I wasn't sure what's safe to change, but there's potentially better ways to achieve this. In particular, I'm not sure I fully understand the rationale behind aligning rows in a
Galleybased on the latter's leftmost border, considering the size is what's ultimately used in widgets (inTextEditat least).Regardless, here's a demo of this PR:
text_edit.mp4