Skip to content
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

Fix Issues: more and more Wrap are added every time the mouse is moved. #5106

Closed
wants to merge 1 commit into from

Conversation

rustbasic
Copy link
Contributor

@rustbasic rustbasic commented Sep 13, 2024

Fix Issues: more and more Wrap are added every time the mouse is moved.

Using floor() will cause the value of wrap.max_width to keep getting smaller.
You should use round() or ceil() to prevent the value of wrap.max_width from getting smaller.

@emilk emilk closed this in #5161 Sep 25, 2024
@emilk emilk closed this in f97f850 Sep 25, 2024
hacknus pushed a commit to hacknus/egui that referenced this pull request Oct 30, 2024
…k#5161)

* Closes emilk#5106
* Closes emilk#5084


Protect against rounding errors in egui layout code.

Say the user asks to wrap at width 200.0.
The text layout wraps, and reports that the final width was 196.0
points.
This than trickles up the `Ui` chain and gets stored as the width for a
tooltip (say).
On the next frame, this is then set as the max width for the tooltip,
and we end up calling the text layout code again, this time with a wrap
width of 196.0.
Except, somewhere in the `Ui` chain with added margins etc, a rounding
error was introduced,
so that we actually set a wrap-width of 195.9997 instead.
Now the text that fit perfectly at 196.0 needs to wrap one word earlier,
and so the text re-wraps and reports a new width of 185.0 points.
And then the cycle continues.

So this PR limits the text wrap-width to be an integer.

Related issues:
* emilk#4927
* emilk#4928
* emilk#5163

--- 

Pleas test this @rustbasic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

#5077 After update, more and more Wrap are added every time the mouse is moved.
1 participant