14#include "CoreMinimal.h"
37 CRangeMember ChildrenRange,
48 TSharedRef<ContainerWidget>
const& container,
53 TSharedRef<ChildWidget>
const& child,
58 TSharedRef<ContainerWidget>
const& container,
59 TSharedRef<ChildWidget>
const& child,
75 if constexpr (
requires(ContainerWidget& container, TSharedRef<SWidget> child)
77 container.RemoveSlot(child);
80 delegate = FRemoveChild::CreateLambda([](
81 TSharedRef<ContainerWidget>
const& container,
82 TSharedRef<ChildWidget>
const& child, int32 at
84 container->RemoveSlot(child);
89 template <CW
idgetArguments ThisArguments>
90 requires requires(ThisArguments& args)
92 { args._State } -> CSameAsDecayed< IStatePtr<Range> >;
93 { args._Container } -> CSameAsDecayed< TSharedPtr<ContainerWidget> >;
94 { args._CreateChild } -> CSameAsDecayed< FCreateChild >;
95 { args._UpdateChild } -> CSameAsDecayed< FUpdateChild >;
96 { args._RemoveChild } -> CSameAsDecayed< FRemoveChild >;
106 State = args._State.ToWeakPtr();
113 args._State->OnChange(
this, [
this](Range
const& next)
120 if (
auto state =
State.Pin())
122 auto [value, lock] = state->GetOnAnyThread();
143 CWidgetWithSlots ContainerWidget = SWidget,
144 CWidget ChildWidget = SWidget,
145 typename Base = Detail::TReactiveWidgetBase<
147 ContainerWidget, ChildWidget, TArray<TSharedRef<ChildWidget>>, int32
160 Base::DefaultRemoveChild(_RemoveChild);
169 void Construct(FArguments const& args) { Base::ConstructBase(args); }
174 for (
int i = 0; i < FMath::Max(next.Num(), Base::Children.Num()); ++i)
176 if (next.IsValidIndex(i) && Base::Children.IsValidIndex(i))
178 Base::UpdateChild.ExecuteIfBound(Base::Children[i], next[i], i);
181 if (next.IsValidIndex(i))
183 typename ContainerWidget::FSlot* newSlot =
nullptr;
184 Base::CreateChild.Execute(Base::Container, next[i], i).Expose(newSlot);
185 Base::Children.Add(StaticCastSharedRef<ChildWidget>(newSlot->GetWidget()));
188 if (Base::Children.IsValidIndex(i))
190 Base::RemoveChild.Execute(Base::Container, Base::Children[i], i);
193 if (Base::Children.Num() > next.Num()) Base::Children.SetNum(next.Num());
208 typename Key,
typename Item,
209 CWidget ContainerWidget = SWidget,
210 CWidget ChildWidget = SWidget,
211 typename Base = Detail::TReactiveWidgetBase<
212 Item, TMap<Key, Item>,
213 ContainerWidget, ChildWidget, TMap<Key, TSharedRef<ChildWidget>>, Key
225 Base::DefaultRemoveChild(_RemoveChild);
234 void Construct(FArguments const& args) { Base::ConstructBase(args); }
240 |
FilterTuple([
this](Key
const& key, Item
const& value)
242 return Base::Children.Contains(key);
246 for (Key
const& updating : update)
248 Base::UpdateChild.ExecuteIfBound(Base::Children[updating], next[updating], updating);
250 auto dismiss = Base::Children
251 |
FilterTuple([&](Key
const& key, Item
const& value)
253 return !next.Contains(key);
258 for (Key
const& dismissing : dismiss)
260 Base::RemoveChild.Execute(Base::Container, Base::Children[dismissing], dismissing);
261 Base::Children.Remove(dismissing);
264 |
FilterTuple([
this](Key
const& key, Item
const& value)
266 return !Base::Children.Contains(key);
270 for (Key
const& adding : add)
272 typename ContainerWidget::FSlot* newSlot =
nullptr;
273 Base::CreateChild.Execute(Base::Container, next[adding], adding).Expose(newSlot);
274 Base::Children.Add(adding, StaticCastSharedRef<ChildWidget>(newSlot->GetWidget()));
#define ASSERT_CRASH(condition,...)
Use this instead of check macro if the checked expression shouldn't be ignored in shipping builds....
Bring modern declarative range operations like views and actions to the Unreal C++ arsenal....
Render a range as the given container.
Contains utilities for structured error handling.
TSharedPtr< IState< T > > IStatePtr
Convenience alias for shared pointer to a base type of TState. Use this in APIs which may modify or g...
TWeakPtr< IState< T > > IStateWeakPtr
Convenience alias for weak pointer to a base type of TState. Use this in APIs which may modify or get...
FORCEINLINE auto GetKeys()
auto FilterTuple(Left &&left, Predicate &&predicate)
Filter a range of tuples with structured binding function arguments, so filter predicates shouldn't b...
auto WeakSelf(const T *self) -> TWeakPtr< T const, Mode >
Same as SharedThis(this) in TSharedFromThis but returning a weak pointer instead.
Extra functionalities for general Slate programming chores, including enhancements of the Slate decla...
typename TArgumentsOf_Struct< T >::Type TArgumentsOf
Get the type of arguments from either a widget or a slot type (FArguments or FSlotArguments)
MCRO_API void RunInGameThread(TUniqueFunction< void()> &&func)
Simply run a lambda function on the game thread but only use AsyncTask if it's not on the game thread...