Replies: 3 comments 3 replies
-
Since this is so generic I think it's best implemented by using custom functionality, as someone already pointed out:
My suggestion would be to simply add a |
Beta Was this translation helpful? Give feedback.
-
Looking at how sorting works in a GridContainer. A NOTIFICATION_SORT_CHILDREN notification is sent, set in the Container class. Not sure where what I want would fit in here really. I'd want all the children and their calculated positions available to be acted upon and that's not really how the logic works. Not sure where the results I'd want are I assume at the very end in the _compute_offsets is where the results I'd want are finally calculated. As always it's more complicated than at first thought. |
Beta Was this translation helpful? Give feedback.
-
I am facing the same problem but I have come up with a workaround. Of course the key is For example. I'm making a chat app like UI. I want to play a fly-in tween when new message is added to the container. Here is what I have done: private void MessageContainer_SortChildren()
{
if (messageContainer.GetChildren().Count == 0)
{
return;
}
var lastChildren = messageContainer.GetChildren().Last() as Control;
var actualPosition = lastChildren.Position;
// Only tween x here, so I keep the y
// Actually only y matters here. Cuz the x is always 0
lastChildren.Position = new Vector2(-100f, actualPosition.Y);
var tween = GetTree().CreateTween();
tween.TweenProperty(lastChildren, "position:x", 0, 0.5f);
} Well it works just fine (at least for my purpose). But I am always looking for a more proper way to do this. |
Beta Was this translation helpful? Give feedback.
-
When a child is removed from a container such as the HBoxContainer its other children snap to their new positions.
It would be nice if there was a way we could override or augment how we want our children to be moved into their new positions. This could also be expanded to include tweening for container resizes.
Options I can think of:
Problems:
Interested in what others think. Currently the kind of solutions are to create your own container system or just make non-contained control nodes that use invisible container layout as a positioning refererence. The Containers are built around static children.
I had a discussion about this on the GodotForums.
Beta Was this translation helpful? Give feedback.
All reactions