1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-05-10 11:28:44 +02:00

Fixed rounding errors causing AutoInline elements to be pushed into the next line with some ui scales

This commit is contained in:
Ell 2021-09-24 16:35:53 +02:00
parent a140e85300
commit 41b924ef34
2 changed files with 5 additions and 1 deletions

View file

@ -37,6 +37,7 @@ Fixes
- Fixed a crash if a paragraph has a link formatting code, but no font
- Fixed tooltips with custom text scale not snapping to the mouse correctly in their first displayed frame
- Fixed tooltips not displaying correctly with auto-hiding paragraphs
- Fixed rounding errors causing AutoInline elements to be pushed into the next line with some ui scales
### MLEM.Extended
Improvements

View file

@ -607,7 +607,9 @@ namespace MLEM.Ui.Elements {
break;
case Anchor.AutoInline:
var newX = prevArea.Right + this.ScaledOffset.X;
if (newX + newSize.X <= parentArea.Right) {
// with awkward ui scale values, floating point rounding can cause an element that would usually be
// positioned correctly to be pushed into the next line due to a very small deviation, so we add 0.01 here
if (newX + newSize.X <= parentArea.Right + 0.01F) {
pos.X = newX;
pos.Y = prevArea.Y + this.ScaledOffset.Y;
} else {
@ -673,6 +675,7 @@ namespace MLEM.Ui.Elements {
autoSize = Vector2.Min(autoSize, actualSize);
}
// we want to leave some leeway to prevent float rounding causing an infinite loop
if (!autoSize.Equals(this.UnscrolledArea.Size, 0.01F)) {
recursion++;
if (recursion >= 16) {