Having an interesting problem with widget re-positioning.
I have a widget that needs to dynamically grow in size and be positioned at construction time after it’s size increase. Having a container on a canvas allows you to “Size to content” which allows a widget to disregard it’s size instead getting the desired size, but this doesn’t seem to take effect right away. Which is a problem.
Here’s an example widget that I created to demonstrate this:
Here I have a simple CanvasPanel that contains a VerticalBox called container which is set to “Size to Content”
I created a separate widget “WBP_SimpleImage” which contains nothing but a blank image core widget, this was just so I could have something quick to toss inside of the example widget’s VerticalBox. I’m adding 10 of them as children, after which, I print the VerticalBox’s Size as well as Desired Size. Without that delay (arbitrary number) the results are incorrect.
You’ll notice the VerticalBox size is correct in both cases (100, 30) but the DesiredSize is incorrect until it hits that delay.
For my purposes, when I re-position the widget it doesn’t work due to the DesiredSize not being available on the loop’s completion. With the delay there, the widget appears at 0,0 for a fraction of a second before properly being positioned which is just wrong.
What are my options to fix this glitch?