0 votes

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.

asked Aug 31, 2018 in Engine by reightb (16 points)

1 Answer

0 votes

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

answered Aug 31, 2018 by reightb (16 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 How to use this Q&A? before posting your first questions.