Skip to content

Fix TextEdit's in RTL layouts#5547

Merged
emilk merged 2 commits intoemilk:mainfrom
zakarumych:textedit_layout_fix
Sep 9, 2025
Merged

Fix TextEdit's in RTL layouts#5547
emilk merged 2 commits intoemilk:mainfrom
zakarumych:textedit_layout_fix

Conversation

@zakarumych
Copy link
Copy Markdown
Contributor

TextEdit sometimes allocates extra space if text changes and no longer fits into previously allocated Rect.
It also can happen when rounding error occurs. In this case extra space is extra small.

If extra space is needed, Ui::allocate_rect is used to carve that space from placer.
However it always allocated extra space on the bottom-right from the rect placer returned initially.
This works well on Left-to-Right and Top-to-bottom layouts.
However in case it's Right-to-Left, Ui::allocate_rect updates placer's cursor and puts it to the right side of the initially allocated rect. And next widget is then placed over the TextEdit.

This is hard to notice usually.
However I have scaling that can cause rounding errors, so 0.0003 units of extra space is allocated each frame. Making next widget to overlap the TextEdit almost entirely.

This changes makes extra space allocation aware of the layout main direction and it picks most appropriate side of the widget for the extra space.

@emilk emilk added layout Related to widget layout egui labels Mar 25, 2025
@emilk emilk requested a review from lucasmerlin March 25, 2025 08:18
Copy link
Copy Markdown
Collaborator

@lucasmerlin lucasmerlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@lucasmerlin
Copy link
Copy Markdown
Collaborator

@zakarumych unfortunately there is a merge conflict now 🙁 can you update your branch?

@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 9, 2025

Preview available at https://egui-pr-preview.github.io/pr/5547-texteditlayoutfix
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

@emilk emilk changed the title Allocate TextEdit's extra size on the side depending on the layout direction Fix TextEdit's in RTL layouts Sep 9, 2025
@emilk emilk added the bug Something is broken label Sep 9, 2025
@emilk emilk merged commit 9db0398 into emilk:main Sep 9, 2025
26 checks passed
lucasmerlin pushed a commit that referenced this pull request Sep 11, 2025
Masterchef365 pushed a commit to Masterchef365/egui that referenced this pull request Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something is broken egui layout Related to widget layout

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RTL layout breaks with TextEdit

3 participants