How should I expand a custom Container to behave similar to other Control nodes?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By senshellshark

I’m having a problem with a container that has issues with vertical expansion. It doesn’t activate the scroll bars of scroll containers it sits inside. It does not expand and push other elements lower when sitting among other instances inside of a vboxcontainer.

I suspect I’m missing something in regards to changing the size of the container but it doesn’t always push parent control nodes to expand to accommodate it’s size and thus activate scrolling or pushing other elements.

I have a custom container that orders it’s children with this function:

func _on_sort_children():
	var max_width = rect_size.x
	var row_height = min_row_height
	var row_width = 0
	var row_index = 0
	for child in get_children():
		if row_width + child.rect_size.x < max_width:
			child.rect_position = Vector2(row_width, row_index * (row_height + margin.y))
			row_width += child.rect_size.x + margin.x
		else:
			row_index += 1
			child.rect_position = Vector2(0, row_index * (row_height + margin.y))
			row_width = child.rect_size.x + margin.x
	if rect_size.y < (row_index + 1) * row_height:
		rect_size.y = (row_index + 1) * row_height

It orders the dark boxes as it should and wraps them around when it hits the horizontal limit. It also adjusts the vertical height of the box to accommodate each row if needed.

Here is one container filled with boxes to excess where it should be causing a scroll wheel to appear since it is inside of a ScrollContainer:
enter image description here

Here are several of the same container that sits inside a VBoxContainer inside of a ScrollContainer. The scrollbar is there this time though for the whole thing. The first container is filled but doesn’t expand and push it’s siblings down like I would prefer.
enter image description here

Almost every element involved has their SizeFlags set to Fill and Expand at least vertically so I’m not sure what’s happening. Perhaps I am not implementing something I should be with my custom Container?

:bust_in_silhouette: Reply From: senshellshark

With the help of a friend I went through the documentation more thoroughly and spotted on the ScrollContainer page the line that says the rect_min_size needs to be changed in order to activate the scroll wheels showing up. Fixed both the issues updating those on the resized event.