2022-04-06 08:17:40 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "MVVMBlueprintViewBinding.h"
|
|
|
|
|
#include "MVVMBlueprintView.h"
|
2022-05-18 12:54:12 -04:00
|
|
|
#include "MVVMWidgetBlueprintExtension_View.h"
|
|
|
|
|
#include "WidgetBlueprintExtension.h"
|
|
|
|
|
|
2022-04-06 08:17:40 -04:00
|
|
|
|
|
|
|
|
FString FMVVMBlueprintViewBinding::GetNameString(const UMVVMBlueprintView* View) const
|
|
|
|
|
{
|
2022-05-20 18:54:05 -04:00
|
|
|
const FMVVMBlueprintViewModelContext* ViewModel = View->FindViewModel(ViewModelPath.GetViewModelId());
|
2022-05-18 12:54:12 -04:00
|
|
|
TStringBuilder<512> BindingName;
|
|
|
|
|
if (ViewModel != nullptr)
|
|
|
|
|
{
|
|
|
|
|
BindingName << ViewModel->GetViewModelName();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BindingName << TEXT("<none>");
|
|
|
|
|
}
|
|
|
|
|
BindingName << TEXT(".");
|
|
|
|
|
BindingName << ViewModelPath.GetBasePropertyPath();
|
2022-04-06 08:17:40 -04:00
|
|
|
|
2022-05-18 12:54:12 -04:00
|
|
|
if (BindingType == EMVVMBindingMode::TwoWay)
|
|
|
|
|
{
|
|
|
|
|
BindingName << TEXT(" <-> ");
|
|
|
|
|
}
|
|
|
|
|
else if (UE::MVVM::IsForwardBinding(BindingType))
|
|
|
|
|
{
|
|
|
|
|
BindingName << TEXT(" -> ");
|
|
|
|
|
}
|
|
|
|
|
else if (UE::MVVM::IsBackwardBinding(BindingType))
|
|
|
|
|
{
|
|
|
|
|
BindingName << TEXT(" <- ");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BindingName << TEXT(" ??? "); // shouldn't happen
|
|
|
|
|
}
|
2022-04-06 08:17:40 -04:00
|
|
|
|
2022-05-20 18:54:05 -04:00
|
|
|
if (View->GetOuterUMVVMWidgetBlueprintExtension_View()->GetWidgetBlueprint()->GetFName() == WidgetPath.GetWidgetName())
|
2022-05-18 12:54:12 -04:00
|
|
|
{
|
|
|
|
|
BindingName << WidgetPath.GetBasePropertyPath();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-05-20 18:54:05 -04:00
|
|
|
if (WidgetPath.GetWidgetName().IsNone())
|
2022-05-18 12:54:12 -04:00
|
|
|
{
|
|
|
|
|
BindingName << TEXT("<none>");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-05-20 18:54:05 -04:00
|
|
|
BindingName << WidgetPath.GetWidgetName();
|
2022-05-18 12:54:12 -04:00
|
|
|
}
|
|
|
|
|
BindingName << TEXT(".");
|
|
|
|
|
BindingName << WidgetPath.GetBasePropertyPath();
|
|
|
|
|
}
|
2022-04-06 08:17:40 -04:00
|
|
|
|
2022-05-18 12:54:12 -04:00
|
|
|
return BindingName.ToString();
|
|
|
|
|
}
|