+1 vote

I'm not sure how to phrase this better but, I have an HBoxContainer with two elements in it, both having size flags to fill, expand. The leftmost item contains the spells, abilities, ranged etc. and the rightmost item is just a rectangle right now. The size of the whole container is set using margins, and as you can see something is problematic with the display;

The problem in question

Basically, on really small windows the spells are overflowing and going past the left container. Here's a better breakdown of the structure:
The tree view

And lastly a breakdown of the HotbarAssignMenu control:

More breakdown

Now, I'll mention that I do clear and fill those HotbarAssignMenu dynamically, plopping down instanciated controls in the lowest HBoxContainer at runtime, but I don't think it matters.

So essentially my question is as follows: how do I specify how godot handles the overflow? My guess is the HBoxContainer is just not suited for this, as overflowing on the other line would not make sense if you're trying to lay things down 'horizontally'; but I may be wrong - thoughts

Cheers, and thank you.

in Engine by (19 points)

1 Answer

+1 vote

So I ended up patching a hacky solution for now, perhaps there's a better one out there using natural godot constraints and whatnot; here's for reference:

for cc in $WindowBackground/HBoxContainer/VBoxContainer.get_children():
    cc.get_node("VBoxContainer/Grid").columns = int($WindowBackground/HBoxContainer/VBoxContainer.rect_size.x/24.0)-1
    var child_count = cc.get_node("VBoxContainer/Grid").get_child_count()
    var column_count = cc.get_node("VBoxContainer/Grid").columns
    cc.rect_min_size.y = floor(child_count/column_count)*25.0+60

Basically "magic" values that are roughly a control's width + wiggle room. I don't really like this solution but it'll do for now.

edit: This code is ran each time a "category" ("AssignMenu") is modified/drawn.

Here's how the final result looks:
enter image description here

by (19 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.