Slate: Creating a sortable vertical box widget for UMG

Hello,

I need a UMG widget that acts just like a vertical or horizontal box that can be sorted at runtime, more generally, the slots can be rearranged at runtime. It appears I need to do this in Slate with C++, which is fine, I just have some questions about Slate and UMG to help be understand how it works under the hood.

From what I can tell slate, and by extension UMG widgets are constructed when the widget is created or added to the viewport. The structure does not change again after that. I’ve observed this in the VerticalBox.cpp file. RebuildWidget() is called on construction and not again, it creates a SVerticalBox and returns it.

In order to rearrange slots at runtime it appears I may have to rebuild the widget at runtime. But this doesn’t appear to be a practice commonly used in Slate. I assume this is for performance reasons.

So is this the best way to approach the problem? Or am I misunderstanding Slate? If this is the way to do it, how do I force the widget to rebuild at any time other than construction?

Thanks.

The contents of a vertical box can be rearranged at will, you simply clear the children of the vertical box and re-insert them in the order you want them to be in.

You could also make a new kind of panel in slate if you wanted, a SPriorityPanel, that rearranges their draw order internally based on a Priority value on the the slot containing the widget that you update accordingly. Similar to the ZOrder slot property on a Canvas.

This is for a UMG vertical box? If so that vastly simplified the problem.

This sounds more robust. Where can I find information on how Slate rebuilds UI’s at runtime. All examples seem to build a UI on construct and then bind data to things. Are they drawn somewhere every frame? Or would I need to force rebuild the UI somehow?