14#include "CoreMinimal.h"
15#include "Widgets/SWidget.h"
16#include "Widgets/SBoxPanel.h"
17#include "Layout/Visibility.h"
33 concept CWidget = CDerivedFrom<T, SWidget>;
37 concept CSlot = CDerivedFrom<T, FSlotBase>;
66 && CDerivedFrom<T, SBoxPanel>
67 &&
requires(T&& t,
typename T::FScopedWidgetSlotArguments& slotArgs)
69 { t.AddSlot() } -> CSameAsDecayed<typename T::FScopedWidgetSlotArguments>;
79 using Type =
typename T::FArguments;
85 using Type =
typename T::FSlotArguments;
100 template <CW
idgetOrSlotArguments T>
105 template <CConvertibleToDecayed<Function> Arg>
130 return attributes(args);
148 return attributes(args);
158 template <CW
idgetOrSlot T>
162 template <CW
idgetOrSlot T>
198 CFunctionLike Transform,
199 CFunctionLike OnEmpty = TUniqueFunction<TFunction_Return<Transform>()>,
205 TSlots(Range
const& range, Transform&& transform, TOptional<OnEmpty>&& onEmpty = {})
206 : RangeRef(const_cast<Range&>(range))
207 , TransformStorage(MoveTemp(transform))
208 , OnEmptyStorage(MoveTemp(onEmpty))
210 TSlots(Range& range, Transform&& transform, TOptional<OnEmpty>&& onEmpty = {})
212 , TransformStorage(MoveTemp(transform))
213 , OnEmptyStorage(MoveTemp(onEmpty))
218 : RangeRef(o.RangeRef)
219 , TransformStorage(MoveTemp(o.TransformStorage))
220 , OnEmptyStorage(MoveTemp(o.OnEmptyStorage))
229 RangeRef = o.RangeRef;
230 TransformStorage = MoveTemp(o.TransformStorage);
231 OnEmptyStorage = MoveTemp(o.OnEmptyStorage);
235 template <CW
idgetArguments Arguments>
239 if (
IteratorEquals(RangeRef.begin(), RangeRef.end()) && OnEmptyStorage.IsSet())
241 args + OnEmptyStorage.GetValue()();
245 for (
auto it = RangeRef.begin(); !
IteratorEquals(it, RangeRef.end()); ++it)
246 args + TransformStorage(*it);
250 template <CW
idgetArguments Arguments>
251 friend Arguments& operator + (Arguments&& args,
TSlots&& slots)
259 Transform TransformStorage;
260 TOptional<OnEmpty> OnEmptyStorage;
300 CFunctionLike Transform,
302 CFunctionLike OnEmpty = TUniqueFunction<TFunction_Return<Transform>()>,
306 auto SlotsFromTuples(Range&& range, Transform&& transform, TOptional<OnEmpty>&& onEmpty = {})
311 return TSlots(
FWD(range), [transform](Tuple
const& tuple)
318 MCRO_API EVisibility
IsVisible(
bool visible, EVisibility hiddenState = EVisibility::Collapsed);
#define FWD(...)
Shorten forwarding expression with this macro so one may not need to specify explicit type.
Constraining given type to the arguments of a slot
Constraining given type to a slot of a widget.
typename TFunctionTraits< std::decay_t< T > >::Return TFunction_Return
Shorthand for getting a function return type.
constexpr size_t TFunction_ArgCount
Shorthand for getting a function argument count.
TFunction_Return< Function > InvokeWithTuple(Function &&function, Tuple &&arguments)
A clone of std::apply for Unreal, STL and RangeV3 tuples which also supports function pointers.
bool IteratorEquals(L const &l, R const &r)
TIteratorElementType< decltype(DeclVal< T >().begin())> TRangeElementType
return a range's associated content type determined by dereferencing their iterator.
Extra functionalities for general Slate programming chores, including enhancements of the Slate decla...
MCRO_API EVisibility IsVisible(bool visible, EVisibility hiddenState=EVisibility::Collapsed)
Convenience function for typing less when widget visibility depends on a boolean.
auto SlotsFromTuples(Range &&range, Transform &&transform, TOptional< OnEmpty > &&onEmpty={})
Create widget slots from ranges of tuples via a transformation with structured binding arguments.
typename TArgumentsOf_Struct< T >::Type TArgumentsOf
Get the type of arguments from either a widget or a slot type (FArguments or FSlotArguments)
TAttributeBlock< T > InertAttributeBlock
An attribute block which does nothing.
typename T::FArguments Type
An attribute block functor which takes in reference of FArguments or FSlotArguments and returns the s...
TAttributeBlockFunctor(Arg &&function)
friend T & operator/(TIdentity_T< T > &&args, TAttributeBlockFunctor const &attributes)
The "append attribute block" operator which allows pre-defined "blocks of slate attributes" naturally...
T & operator()(T &args) const
TFunction< T &(T &)> Function
Add multiple slots at the same time with the declarative syntax derived from an input data array.
TSlots(TSlots const &)=delete
void Append(Arguments &args)
TSlots(TSlots &&o) noexcept
TSlots(Range const &range, Transform &&transform, TOptional< OnEmpty > &&onEmpty={})
TSlots & operator=(TSlots const &)=delete
TSlots & operator=(TSlots &&o) noexcept
TSlots(Range &range, Transform &&transform, TOptional< OnEmpty > &&onEmpty={})