+1 vote

I have building a simple notification panel where message tiles appear in a list on the edge of the screen. When notifications expire they are removed from the list, and the other notifications move up to fill the space.

I implemented this with a VBoxContainer for the list of notifications with child scenes for each notification. Each child is a PanelContainer containing an HBoxContainer with TextureRect for an icon, plus a Label for the message. The child has a Timer to trigger deletion and an AnimationPlayer to fade it out (using modulate on the PanelContainer) before calling queue_free()

Everything works beautifully, except when a child notification tile is removed from the VBoxContainer, I would really like the visual effect of the remaining children smoothly scrolling up to fill the space, instead of jumping up when a child above it removed.

I tried animating the scale.y of each child as it is being removed so that it gets smaller vertically (after I fade it out). I cannot get the VBoxContainer to respond to this scaling - the VBoxContainer keeps the same vertical space for the child until it is fully removed, and then all the other children jump up. I also tried using process to change scale.y instead of an animation, with the same result. I also tried forcing the child to emit itemrect_changed or resized signals during the scaling process, however this also did not work.

Is there any way I can make a VBoxContainer respond smoothly to one it's children getting smaller in an animation?


Godot version 3.2.3
in Engine by (611 points)

I think changing the scale doesn't affect rect_size. Can you try changing that instead? Containers override the scale of their children.

Thanks for replying exuin

I tried setting "rectsize". I had not tried that before because I was not able to set that in the editor (it is set by the container). Setting "rectsize" in an animation does reduce the size of the child smoothly, which is good, however I got the same effect with the parent - the VBoxContainer does not update with the new size until the child is removed.

Based on your suggestion, I found a solution - I need to delete all the contents of the child, so it is just an empty container, and set "rectminsize.y" and reduce that over time. It looks like changing this makes the parent VBoxContainer update smoothly.

Thanks very much!

Please log in or register to answer this question.

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.