Godot seems to approach UI from the top down: parents manage their children. But very often it's useful to let some layout information flow upward, from child to parent. The only way I see to do this currently is via rect_min_size
-- but it would be really nice to avoid having to measure and force min size via specialized script every time I want a control to use its natural size. Controls "know" how big they need to be, and they size themselves sensibly when not in box containers, but I see no way to indicate to the box container that the child should preserve its inherent size.
Here's a simple example: I have an HBoxContainer with two buttons, Left and Right. I want Right to be just wide enough to contain its text, which can change at runtime. Then I want Left to expand to fill the remaining space. On left I set size_flags_horizontal
to Fill and Expand, but it goes too far. Right gets squashed down to almost nothing, and I have to force its rect_min_size
with script. I know I can set Right to expand with a ratio, but that is not what I'm looking for. Is it possible to have the button size itself according to its text as normal and then ask the parent box container to not force shrink it?