You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Update GetBindingInfoFromFieldPath to support viewmodel inside another viewmodel. Add unittest for the function. Add DoesInitializeAtConstruction on the view class. That is to support manual initialization. When the flag is false, the user is responsible for initializing the view. Add ReevaluateSourceCreator. A source that was discovered at compile time and added to the list of SourceCreator may need to be evaluated if the path contains notify. That function is similar to SetViewModel but finds the new value from the SourceCreator. Fix issue when a binding destination can't be evaluated at initialization. Since we only reactivate the bindings link to a source in SetViewModel, some bindings were never registered and never executed after the SetViewModel properly set the binding destination. Update the view class ToString functions with the new flags. Prevent adding a new binding when the editor data contains a conversion function and a regular function. That may occur when the user started with a regular binding and changed it afterward for a conversion function. We may not want to reset the binding to be non destructive. #prefligth 6419e837bb1320be412d274d, 641b068aee0aed13479e6ea3 [CL 24750233 by patrick boutot in ue5-main branch]
203 lines
4.1 KiB
C++
203 lines
4.1 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "Bindings/MVVMCompiledBindingLibrary.h"
|
|
|
|
namespace UE::MVVM { struct FMVVMConstFieldVariant; }
|
|
template <typename T> class TSubclassOf;
|
|
|
|
|
|
namespace UE::MVVM::Private
|
|
{
|
|
class FCompiledBindingLibraryCompilerImpl;
|
|
} //namespace UE::MVVM::Private
|
|
|
|
|
|
namespace UE::MVVM
|
|
{
|
|
|
|
/** */
|
|
class MODELVIEWVIEWMODELBLUEPRINT_API FCompiledBindingLibraryCompiler
|
|
{
|
|
public:
|
|
/** */
|
|
struct FFieldPathHandle
|
|
{
|
|
public:
|
|
explicit FFieldPathHandle()
|
|
: Id(0)
|
|
{
|
|
}
|
|
|
|
static FFieldPathHandle MakeHandle()
|
|
{
|
|
FFieldPathHandle Handle;
|
|
++IdGenerator;
|
|
Handle.Id = IdGenerator;
|
|
return Handle;
|
|
}
|
|
|
|
bool IsValid() const
|
|
{
|
|
return Id != 0;
|
|
}
|
|
|
|
bool operator==(const FFieldPathHandle& Other) const
|
|
{
|
|
return Id == Other.Id;
|
|
}
|
|
|
|
bool operator!=(const FFieldPathHandle& Other) const
|
|
{
|
|
return Id != Other.Id;
|
|
}
|
|
|
|
friend uint32 GetTypeHash(const FFieldPathHandle& Handle)
|
|
{
|
|
return ::GetTypeHash(Handle.Id);
|
|
}
|
|
|
|
private:
|
|
static int32 IdGenerator;
|
|
int32 Id;
|
|
};
|
|
|
|
|
|
/** */
|
|
struct FBindingHandle
|
|
{
|
|
public:
|
|
explicit FBindingHandle()
|
|
: Id(0)
|
|
{
|
|
}
|
|
|
|
static FBindingHandle MakeHandle()
|
|
{
|
|
FBindingHandle Handle;
|
|
++IdGenerator;
|
|
Handle.Id = IdGenerator;
|
|
return Handle;
|
|
}
|
|
|
|
bool IsValid() const
|
|
{
|
|
return Id != 0;
|
|
}
|
|
|
|
bool operator==(const FBindingHandle& Other) const
|
|
{
|
|
return Id == Other.Id;
|
|
}
|
|
|
|
bool operator!=(const FBindingHandle& Other) const
|
|
{
|
|
return Id != Other.Id;
|
|
}
|
|
|
|
friend uint32 GetTypeHash(const FBindingHandle& Handle)
|
|
{
|
|
return ::GetTypeHash(Handle.Id);
|
|
}
|
|
|
|
private:
|
|
static int32 IdGenerator;
|
|
int32 Id;
|
|
};
|
|
|
|
/** */
|
|
struct FFieldIdHandle
|
|
{
|
|
public:
|
|
explicit FFieldIdHandle()
|
|
: Id(0)
|
|
{
|
|
}
|
|
|
|
static FFieldIdHandle MakeHandle()
|
|
{
|
|
FFieldIdHandle Handle;
|
|
++IdGenerator;
|
|
Handle.Id = IdGenerator;
|
|
return Handle;
|
|
}
|
|
|
|
bool IsValid() const
|
|
{
|
|
return Id != 0;
|
|
}
|
|
|
|
bool operator==(const FFieldIdHandle& Other) const
|
|
{
|
|
return Id == Other.Id;
|
|
}
|
|
|
|
bool operator!=(const FFieldIdHandle& Other) const
|
|
{
|
|
return Id != Other.Id;
|
|
}
|
|
|
|
friend uint32 GetTypeHash(const FFieldIdHandle& Handle)
|
|
{
|
|
return ::GetTypeHash(Handle.Id);
|
|
}
|
|
|
|
private:
|
|
static int32 IdGenerator;
|
|
int32 Id;
|
|
};
|
|
|
|
public:
|
|
FCompiledBindingLibraryCompiler();
|
|
|
|
public:
|
|
/** */
|
|
TValueOrError<FFieldIdHandle, FText> AddFieldId(const UClass* SourceClass, FName FieldName);
|
|
|
|
/** */
|
|
TValueOrError<FFieldPathHandle, FText> AddFieldPath(TArrayView<const UE::MVVM::FMVVMConstFieldVariant> FieldPath, bool bRead);
|
|
|
|
/** */
|
|
TValueOrError<FFieldPathHandle, FText> AddObjectFieldPath(TArrayView<const UE::MVVM::FMVVMConstFieldVariant> FieldPath, UClass* ExpectedType, bool bRead);
|
|
|
|
/** */
|
|
TValueOrError<FFieldPathHandle, FText> AddConversionFunctionFieldPath(const UClass* SourceClass, const UFunction* Function);
|
|
|
|
/** */
|
|
TValueOrError<FBindingHandle, FText> AddBinding(FFieldPathHandle Source, FFieldPathHandle Destination);
|
|
|
|
/** */
|
|
TValueOrError<FBindingHandle, FText> AddBinding(FFieldPathHandle Source, FFieldPathHandle Destination, FFieldPathHandle ConversionFunction);
|
|
|
|
/** */
|
|
TValueOrError<FBindingHandle, FText> AddComplexBinding(FFieldPathHandle Destination, FFieldPathHandle ConversionFunction);
|
|
|
|
struct FCompileResult
|
|
{
|
|
FMVVMCompiledBindingLibrary Library;
|
|
TMap<FFieldPathHandle, FMVVMVCompiledFieldPath> FieldPaths;
|
|
TMap<FBindingHandle, FMVVMVCompiledBinding> Bindings;
|
|
TMap<FFieldIdHandle, FMVVMVCompiledFieldId> FieldIds;
|
|
};
|
|
|
|
/** */
|
|
TValueOrError<FCompileResult, FText> Compile();
|
|
|
|
private:
|
|
/** */
|
|
TValueOrError<FFieldPathHandle, FText> AddFieldPathImpl(TArrayView<const UE::MVVM::FMVVMConstFieldVariant> FieldPath, bool bRead);
|
|
TValueOrError<FBindingHandle, FText> AddBindingImpl(FFieldPathHandle Source, FFieldPathHandle Destination, FFieldPathHandle ConversionFunction, bool bIsComplexBinding);
|
|
|
|
TPimplPtr<Private::FCompiledBindingLibraryCompilerImpl> Impl;
|
|
};
|
|
|
|
} //namespace UE::MVVM
|
|
|
|
#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_2
|
|
#include "CoreMinimal.h"
|
|
#include "MVVMSubsystem.h"
|
|
#include "Templates/ValueOrError.h"
|
|
#include "Types/MVVMFieldVariant.h"
|
|
#endif
|