godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
86.63k stars 19.31k forks source link

Containers do not correctly resize to their contents when their visibility is toggled #93464

Open peter-rocchio opened 2 weeks ago

peter-rocchio commented 2 weeks ago

Tested versions

System information

Windows 11 - Forward +

Issue description

Containers will correctly resize to fit their contents when in the editor and the first time they are made visible while the application is running. However, if the container is hidden, and then shown again, the container will shrink and not resize properly when shown again. This is easiest to see with panel containers. image image image

Steps to reproduce

  1. Create a control scene and add a script to this node
  2. Add a panel container, a grid container as a child, and buttons as children to the grid container
  3. Add a button as the child of the root control node, link its pressed signal to the root script
  4. Have the button's signal turn the panel container's visibility on and off
  5. Observe that the panel container does not consider its child contents when it determines its size after being shown again

Minimal reproduction project (MRP)

container-visibility.zip

anniryynanen commented 2 weeks ago

Probably related to #93386. That fixes it for grids, but not other containers.

anniryynanen commented 2 weeks ago

I can change the other containers too, but should it be SortableVisbilityMode::VISIBLE or SortableVisbilityMode::IGNORE? I used VISIBLE to fix the grids, but going through the others I see some use IGNORE.

huwpascoe commented 2 weeks ago

This happens to me in 4.2. I know there was some kind of workaround I had to do for an overlay.

kitbdev commented 1 day ago

I can change the other containers too, but should it be SortableVisbilityMode::VISIBLE or SortableVisbilityMode::IGNORE? I used VISIBLE to fix the grids, but going through the others I see some use IGNORE.

I think they should use VISIBLE in the minimum size checks so that it matches behavior from before #91613