egui/crates/epaint/src
Emil Ernerfeldt f97f85089d
Prevent text shrinking in tooltips; round wrap-width to integer (#5161)
* Closes https://github.com/emilk/egui/pull/5106
* Closes https://github.com/emilk/egui/issues/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:
* https://github.com/emilk/egui/issues/4927
* https://github.com/emilk/egui/issues/4928
* https://github.com/emilk/egui/issues/5163

--- 

Pleas test this @rustbasic
2024-09-25 11:31:41 +02:00
..
text Prevent text shrinking in tooltips; round wrap-width to integer (#5161) 2024-09-25 11:31:41 +02:00
util Add `emath::OrderedFloat` (moved from `epaint::util::OrderedFloat`) (#4389) 2024-04-21 20:36:32 +02:00
bezier.rs Remove wildcard imports (#5018) 2024-08-28 12:18:42 +02:00
color.rs Added ability to define colors at UV coordinates along a path (#4353) 2024-04-22 18:35:09 +02:00
image.rs Add `ColorImage::from_gray_iter` (#3536) 2024-02-20 15:29:23 +01:00
lib.rs Fix some minor clippy lints from the future 2024-09-18 09:44:23 +02:00
margin.rs Overload operators for `Rect + Margin`, `Rect - Margin` etc (#4277) 2024-03-30 14:03:41 +01:00
mesh.rs Fix some minor clippy lints from the future 2024-09-18 09:44:23 +02:00
mutex.rs Make `epaint::mutex::RwLock` allow `?Sized` types (#4485) 2024-05-13 12:49:31 +02:00
shadow.rs Fix typo 2024-09-01 10:23:40 +02:00
shape.rs Remove wildcard imports (#5018) 2024-08-28 12:18:42 +02:00
shape_transform.rs Remove wildcard imports (#5018) 2024-08-28 12:18:42 +02:00
stats.rs Remove wildcard imports (#5018) 2024-08-28 12:18:42 +02:00
stroke.rs Fix blurry lines (#4943) 2024-08-30 09:57:32 +02:00
tessellator.rs Fix some minor clippy lints from the future 2024-09-18 09:44:23 +02:00
texture_atlas.rs Fix buggy text withviewports on monitors with different scales (#3666) 2023-11-30 15:56:05 +01:00
texture_handle.rs Improved texture loading (#3315) 2023-09-12 10:39:17 +02:00
textures.rs Add support for mipmap textures. (#5146) 2024-09-22 19:16:16 +02:00