I have the following Control hierarchy:
- ScrollContainer: min size: 468x372, Horizontal Enabled
- A nested HBox: min size: 468x372 (
Then, dynamically, I add Grid containers items inside the HBox, where it grows horizontally:
The problem is that both the size of the ScrollContainer and the HBox do not change dynamically, then in order to scroll to work, I have to change the size with code, as items are added/removed from the HBox.
I always knew that:
The size of the node's bounding rectangle, in pixels. Container nodes update this property automatically.
But for some reason for this specific setup I'm having to do that with code:
# HACK: Update the size of the container of grids
# Is this a bug? Container nodes should have this updated automatically.
var ui_grid_item_size = _ui_inventory_grid_item.instance().get_size()
var padding = (_item_grids_container.get_constant("separation") * (_item_grids_container.get_child_count() - 1))
var base_width = (ui_grid_item_size.x * _item_grids_container.get_child_count())
_item_grids_container.set_size(Vector2(base_width + padding, _item_grids_container.get_size().y))