u3d-community / U3D

Open-source, cross-platform 2D and 3D game engine built in C++
https://u3d.io
MIT License
160 stars 26 forks source link

UI: Loading UI layout with wordwrap Text inside vertical layout adds huge spaces #61

Closed lucasvinbr closed 6 months ago

lucasvinbr commented 7 months ago

Layout as set up in editor, and saved: Urho3DPlayer_2024-02-29_16-14-04

Layout after loading the saved data: Urho3DPlayer_2024-02-29_16-14-33

The texts inside the layout in the pictures do not have a fixed width (I haven't set their max and min widths).

Any update to the layout after the load, like manually editing the text in any of the entries in the editor, corrects the spaces, but the vertical layout can remain huge if there is an element, like a button, set with infinite max vertical scale.

A word-wrapped text does not set its own width based on its content, so, when not inside a layout, it becomes a very tall zero-width column until you set a different width for it. This width also won't be saved unless you make it fixed (set min and max width to the same value).

Fixing the text's width also does not cause the spaces to appear in a vertical layout, so it's one of the ways to avoid the problem. However, I find it a bit cumbersome to fix all texts' widths inside a layout, especially when the layout seems to already handle that for you (all elements are stretched to fit horizontally if you don't limit their widths... including word-wrapped texts)