I don't understand ChildSlot[...]
So, I am using Slate a bit and it works, but I really don't understand it. Here is working code:
It does what I want. But, what is happening here, C++ wise? Childslot is a member of type FSimpleSlot.
I use that member, behind I do what? I start an array with '['? Or is that some kind of initialization? What is the +Overlay doing?
I understand what is happending, I think.
I do not understand why it is happening. I have problems with the C++ here. I think the answer could be something very basic, which i just don't get yet.
asked Oct 23 '17 at 07:34 PM in C++ Programming
This is "hack" in C++ using operator overloads which allows to modify behavior of operators, also add support of operators to structs and classes (that why you can use them with FVector or FRotator for example even thru they are custom structs inside UE4).
Slate using it to create this nice looking layout definition syntax that looks nice in C++, because using function or setting varbales would be annoying to write entire layout in, the final result of it is constructed widget class based on that layout data. so + SOverlay::Slot() is just + operator overload of slot builder which adds slots together (SOverlay::Slot() + SOverlay::Slot() that what really happening here). the array brackets "" are operator too, this allows to make custom array system (in fact UE4 got it's own array implementations TArray, TMap, TSet etc.), slate use this to contain layout definition of widgets inside the slot Slot
It's kind of more fancy looking chained builder pattern if you ever seen those in C++
So yes, even thru Slate do those twists here it is still 100% valid C++ syntax and any today compiler by standard should deal with it without any issue.
The tabulation might be what confusing you, remember that in most languages "new lines", tabs and spaces (outside quotes) are ignored, you can hit enter after every space all the time, compiler will still compiler it normally as it process everything as single stream of characters. it actually prime reason why you need to place ";" after everything and yes you can place everything in single line (except preprocessor instruction like #include), compiler have 0 issue with that. This is something you wont see in UE4, but for example some C/C++ projects place enter and tabs on each argument of a function definition so it is not cut by text editor and all of them are visible all at once, compiler will process that normally without any issue. It is recmanded to do new lines and tabs like that so Slate layout information is more readable to programmers
Follow this question
Once you sign in you will be able to subscribe for any updates here