MVVM: Add function to get the available bindings from class that implements the UNotifyFieldValueChanged interface.

#rb sebastian.nordgren

#ROBOMERGE-AUTHOR: patrick.boutot
#ROBOMERGE-SOURCE: CL 20488767 via CL 20488791 via CL 20488807
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v954-20466795)

[CL 20490251 by patrick boutot in ue5-main branch]
This commit is contained in:
patrick boutot
2022-06-03 14:26:53 -04:00
parent 4dd263e358
commit 5a70e6a3be
2 changed files with 22 additions and 8 deletions
@@ -191,15 +191,16 @@ namespace UE::MVVM::Private
return Result;
}
template<typename TClassType>
TArray<FMVVMAvailableBinding> GetAvailableBindings(TSubclassOf<TClassType> InSubClass)
TArray<FMVVMAvailableBinding> GetAvailableBindings(TSubclassOf<UObject> InSubClass)
{
if (InSubClass.Get() == nullptr)
if (InSubClass.Get() && InSubClass.Get()->ImplementsInterface(UNotifyFieldValueChanged::StaticClass()))
{
return TArray<FMVVMAvailableBinding>();
TScriptInterface<INotifyFieldValueChanged> DefaultObject = InSubClass.GetDefaultObject();
const UE::FieldNotification::IClassDescriptor& ClassDescriptor = DefaultObject->GetFieldNotificationDescriptor();
return GetAvailableBindings(InSubClass.Get(), ClassDescriptor);
}
const UE::FieldNotification::IClassDescriptor& ClassDescriptor = InSubClass.GetDefaultObject()->GetFieldNotificationDescriptor();
return GetAvailableBindings(InSubClass.Get(), ClassDescriptor);
return TArray<FMVVMAvailableBinding>();
}
} //namespace
@@ -216,6 +217,12 @@ TArray<FMVVMAvailableBinding> UMVVMSubsystem::GetWidgetAvailableBindings(TSubcla
}
TArray<FMVVMAvailableBinding> UMVVMSubsystem::GetAvailableBindings(TSubclassOf<UObject> Class) const
{
return UE::MVVM::Private::GetAvailableBindings(Class);
}
TValueOrError<bool, FString> UMVVMSubsystem::IsBindingValid(FBindingArgs Args) const
{
if (UE::MVVM::IsForwardBinding(Args.Mode))
@@ -49,14 +49,21 @@ public:
UFUNCTION(BlueprintCallable, Category = "MVVM")
bool DoesWidgetTreeContainedWidget(const UWidgetTree* WidgetTree, const UWidget* ViewWidget) const;
/** Returns the list of all the binding that are available for the ViewModel. */
/** Returns the list of all the bindings that are available for the ViewModel. */
UFUNCTION(BlueprintCallable, Category = "MVVM")
TArray<FMVVMAvailableBinding> GetViewModelAvailableBindings(TSubclassOf<UMVVMViewModelBase> ViewModelClass) const;
/** Returns the list of all the binding that are available for the Widget. */
/** Returns the list of all the bindings that are available for the Widget. */
UFUNCTION(BlueprintCallable, Category = "MVVM")
TArray<FMVVMAvailableBinding> GetWidgetAvailableBindings(TSubclassOf<UWidget> WidgetClass) const;
/**
* Returns the list of all the bindings that are available for the Class.
* The class must implement the UNotifyFieldValueChanged interface.
*/
UFUNCTION(BlueprintCallable, Category = "MVVM")
TArray<FMVVMAvailableBinding> GetAvailableBindings(TSubclassOf<UObject> Class) const;
public:
UFUNCTION(BlueprintCallable, Category = "MVVM")
UMVVMViewModelCollectionObject* GetGlobalViewModelCollection() const