2019-12-26 15:33:43 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2014-04-23 17:26:16 -04:00
|
|
|
|
|
|
|
|
#include "RangeStructCustomization.h"
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "Widgets/DeclarativeSyntaxSupport.h"
|
|
|
|
|
#include "Engine/GameViewportClient.h"
|
|
|
|
|
#include "Widgets/SBoxPanel.h"
|
|
|
|
|
#include "Widgets/Layout/SSpacer.h"
|
|
|
|
|
#include "Widgets/Text/STextBlock.h"
|
|
|
|
|
#include "Widgets/Layout/SBox.h"
|
|
|
|
|
#include "Widgets/Input/SComboBox.h"
|
|
|
|
|
#include "DetailWidgetRow.h"
|
|
|
|
|
#include "Editor.h"
|
|
|
|
|
#include "PropertyHandle.h"
|
|
|
|
|
#include "DetailLayoutBuilder.h"
|
|
|
|
|
#include "Widgets/Input/SNumericEntryBox.h"
|
2014-04-23 17:26:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "RangeStructCustomization"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Helper traits for getting a metadata property based on the template parameter type
|
|
|
|
|
*****************************************************************************/
|
2014-06-12 23:22:18 -04:00
|
|
|
|
2014-04-23 17:26:16 -04:00
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
template <typename NumericType>
|
|
|
|
|
struct FGetMetaDataHelper
|
2014-06-12 23:22:18 -04:00
|
|
|
{ };
|
2014-04-23 17:26:16 -04:00
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
struct FGetMetaDataHelper<float>
|
|
|
|
|
{
|
2019-12-13 11:07:03 -05:00
|
|
|
static float GetMetaData(const FProperty* Property, const TCHAR* Key)
|
2014-04-23 17:26:16 -04:00
|
|
|
{
|
2019-09-10 11:35:20 -04:00
|
|
|
return Property->GetFloatMetaData(Key);
|
2014-04-23 17:26:16 -04:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2022-05-03 19:47:22 -04:00
|
|
|
template <>
|
|
|
|
|
struct FGetMetaDataHelper<double>
|
|
|
|
|
{
|
|
|
|
|
static double GetMetaData(const FProperty* Property, const TCHAR* Key)
|
|
|
|
|
{
|
|
|
|
|
return Property->GetDoubleMetaData(Key);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2014-04-23 17:26:16 -04:00
|
|
|
template <>
|
|
|
|
|
struct FGetMetaDataHelper<int32>
|
|
|
|
|
{
|
2019-12-13 11:07:03 -05:00
|
|
|
static int32 GetMetaData(const FProperty* Property, const TCHAR* Key)
|
2014-04-23 17:26:16 -04:00
|
|
|
{
|
2019-09-10 11:35:20 -04:00
|
|
|
return Property->GetIntMetaData(Key);
|
2014-04-23 17:26:16 -04:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* FRangeStructCustomization static interface
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
template <typename NumericType>
|
2014-06-04 10:16:14 -04:00
|
|
|
TSharedRef<IPropertyTypeCustomization> FRangeStructCustomization<NumericType>::MakeInstance()
|
2014-04-23 17:26:16 -04:00
|
|
|
{
|
|
|
|
|
return MakeShareable(new FRangeStructCustomization<NumericType>);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-06-04 10:16:14 -04:00
|
|
|
/* IPropertyTypeCustomization interface
|
2014-04-23 17:26:16 -04:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
template <typename NumericType>
|
2014-06-04 11:16:24 -04:00
|
|
|
void FRangeStructCustomization<NumericType>::CustomizeHeader(TSharedRef<IPropertyHandle> StructPropertyHandle, FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
|
2014-04-23 17:26:16 -04:00
|
|
|
{
|
|
|
|
|
// Get handles to the properties we're interested in
|
|
|
|
|
LowerBoundStructHandle = StructPropertyHandle->GetChildHandle(TEXT("LowerBound"));
|
|
|
|
|
UpperBoundStructHandle = StructPropertyHandle->GetChildHandle(TEXT("UpperBound"));
|
|
|
|
|
check(LowerBoundStructHandle.IsValid());
|
|
|
|
|
check(UpperBoundStructHandle.IsValid());
|
|
|
|
|
|
|
|
|
|
LowerBoundValueHandle = LowerBoundStructHandle->GetChildHandle(TEXT("Value"));
|
|
|
|
|
UpperBoundValueHandle = UpperBoundStructHandle->GetChildHandle(TEXT("Value"));
|
|
|
|
|
LowerBoundTypeHandle = LowerBoundStructHandle->GetChildHandle(TEXT("Type"));
|
|
|
|
|
UpperBoundTypeHandle = UpperBoundStructHandle->GetChildHandle(TEXT("Type"));
|
|
|
|
|
check(LowerBoundValueHandle.IsValid());
|
|
|
|
|
check(UpperBoundValueHandle.IsValid());
|
|
|
|
|
check(LowerBoundTypeHandle.IsValid());
|
|
|
|
|
check(UpperBoundTypeHandle.IsValid());
|
|
|
|
|
|
|
|
|
|
// Get min/max metadata values if defined
|
|
|
|
|
auto Property = StructPropertyHandle->GetProperty();
|
|
|
|
|
if (Property != nullptr)
|
|
|
|
|
{
|
|
|
|
|
if (Property->HasMetaData(TEXT("UIMin")))
|
|
|
|
|
{
|
|
|
|
|
MinAllowedValue = TOptional<NumericType>(FGetMetaDataHelper<NumericType>::GetMetaData(Property, TEXT("UIMin")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Property->HasMetaData(TEXT("UIMax")))
|
|
|
|
|
{
|
|
|
|
|
MaxAllowedValue = TOptional<NumericType>(FGetMetaDataHelper<NumericType>::GetMetaData(Property, TEXT("UIMax")));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Make weak pointers to be passed as payloads to the widgets
|
|
|
|
|
TWeakPtr<IPropertyHandle> LowerBoundValueWeakPtr = LowerBoundValueHandle;
|
|
|
|
|
TWeakPtr<IPropertyHandle> UpperBoundValueWeakPtr = UpperBoundValueHandle;
|
|
|
|
|
TWeakPtr<IPropertyHandle> LowerBoundTypeWeakPtr = LowerBoundTypeHandle;
|
|
|
|
|
TWeakPtr<IPropertyHandle> UpperBoundTypeWeakPtr = UpperBoundTypeHandle;
|
|
|
|
|
|
|
|
|
|
// Generate a list of enum values for the combo box from the LowerBound.Type property
|
|
|
|
|
TArray<bool> RestrictedList;
|
|
|
|
|
LowerBoundTypeHandle->GeneratePossibleValues(ComboBoxList, ComboBoxToolTips, RestrictedList);
|
|
|
|
|
|
|
|
|
|
// Get initial values for the combo box
|
|
|
|
|
uint8 LowerBoundType;
|
|
|
|
|
TSharedPtr<FString> LowerBoundTypeSelectedItem;
|
|
|
|
|
if (ensure(LowerBoundTypeHandle->GetValue(LowerBoundType) == FPropertyAccess::Success))
|
|
|
|
|
{
|
|
|
|
|
check(LowerBoundType < ComboBoxList.Num());
|
|
|
|
|
LowerBoundTypeSelectedItem = ComboBoxList[LowerBoundType];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8 UpperBoundType;
|
|
|
|
|
TSharedPtr<FString> UpperBoundTypeSelectedItem;
|
|
|
|
|
if (ensure(UpperBoundTypeHandle->GetValue(UpperBoundType) == FPropertyAccess::Success))
|
|
|
|
|
{
|
|
|
|
|
check(UpperBoundType < ComboBoxList.Num());
|
|
|
|
|
UpperBoundTypeSelectedItem = ComboBoxList[UpperBoundType];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Build the widgets
|
|
|
|
|
HeaderRow.NameContent()
|
|
|
|
|
[
|
|
|
|
|
StructPropertyHandle->CreatePropertyNameWidget()
|
|
|
|
|
]
|
|
|
|
|
.ValueContent()
|
|
|
|
|
.MinDesiredWidth(200.0f)
|
|
|
|
|
.MaxDesiredWidth(200.0f)
|
|
|
|
|
[
|
|
|
|
|
SNew(SVerticalBox)
|
|
|
|
|
+SVerticalBox::Slot()
|
|
|
|
|
.Padding(FMargin(0.0f, 3.0f, 0.0f, 2.0f))
|
|
|
|
|
[
|
|
|
|
|
SNew(SHorizontalBox)
|
|
|
|
|
+SHorizontalBox::Slot()
|
2020-11-06 16:12:22 -04:00
|
|
|
.Padding(FMargin(0.0f, 0.0f, 6.0f, 0.0f))
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
[
|
|
|
|
|
SNew(STextBlock)
|
|
|
|
|
.Font(IDetailLayoutBuilder::GetDetailFont())
|
|
|
|
|
.Text(LOCTEXT("MinimumBoundLabel", "Min"))
|
|
|
|
|
]
|
|
|
|
|
+SHorizontalBox::Slot()
|
|
|
|
|
.Padding(FMargin(0.0f, 0.0f, 3.0f, 0.0f))
|
2014-04-23 17:26:16 -04:00
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
[
|
|
|
|
|
SNew(SNumericEntryBox<NumericType>)
|
|
|
|
|
.Value(this, &FRangeStructCustomization<NumericType>::OnGetValue, LowerBoundValueWeakPtr, LowerBoundTypeWeakPtr)
|
|
|
|
|
.MinValue(MinAllowedValue)
|
|
|
|
|
.MinSliderValue(MinAllowedValue)
|
|
|
|
|
.MaxValue(this, &FRangeStructCustomization<NumericType>::OnGetValue, UpperBoundValueWeakPtr, UpperBoundTypeWeakPtr)
|
|
|
|
|
.MaxSliderValue(this, &FRangeStructCustomization<NumericType>::OnGetValue, UpperBoundValueWeakPtr, UpperBoundTypeWeakPtr)
|
|
|
|
|
.OnValueCommitted(this, &FRangeStructCustomization<NumericType>::OnValueCommitted, LowerBoundValueWeakPtr)
|
|
|
|
|
.OnValueChanged(this, &FRangeStructCustomization<NumericType>::OnValueChanged, LowerBoundValueWeakPtr)
|
|
|
|
|
.OnBeginSliderMovement(this, &FRangeStructCustomization<NumericType>::OnBeginSliderMovement)
|
|
|
|
|
.OnEndSliderMovement(this, &FRangeStructCustomization<NumericType>::OnEndSliderMovement)
|
|
|
|
|
.IsEnabled(this, &FRangeStructCustomization<NumericType>::OnQueryIfEnabled, LowerBoundTypeWeakPtr)
|
|
|
|
|
.Font(IDetailLayoutBuilder::GetDetailFont())
|
|
|
|
|
.AllowSpin(true)
|
|
|
|
|
]
|
|
|
|
|
+SHorizontalBox::Slot()
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
[
|
2020-11-06 16:12:22 -04:00
|
|
|
SNew(SComboBox<TSharedPtr<FString>>)
|
2014-04-23 17:26:16 -04:00
|
|
|
.OptionsSource(&ComboBoxList)
|
|
|
|
|
.OnGenerateWidget(this, &FRangeStructCustomization<NumericType>::OnGenerateComboWidget)
|
|
|
|
|
.OnSelectionChanged(this, &FRangeStructCustomization<NumericType>::OnComboSelectionChanged, LowerBoundTypeWeakPtr)
|
|
|
|
|
.InitiallySelectedItem(LowerBoundTypeSelectedItem)
|
|
|
|
|
[
|
|
|
|
|
// combo box button intentionally blank to avoid displaying excessive details
|
|
|
|
|
SNew(SSpacer)
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
+SVerticalBox::Slot()
|
|
|
|
|
.Padding(FMargin(0.0f, 2.0f, 0.0f, 3.0f))
|
|
|
|
|
[
|
|
|
|
|
SNew(SHorizontalBox)
|
2020-11-06 16:12:22 -04:00
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.Padding(FMargin(0.0f, 0.0f, 3.0f, 0.0f))
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
[
|
|
|
|
|
SNew(STextBlock)
|
|
|
|
|
.Font(IDetailLayoutBuilder::GetDetailFont())
|
|
|
|
|
.Text(LOCTEXT("MaximumBoundLabel", "Max"))
|
|
|
|
|
]
|
2014-04-23 17:26:16 -04:00
|
|
|
+SHorizontalBox::Slot()
|
2020-11-06 16:12:22 -04:00
|
|
|
.Padding(FMargin(0.0f, 0.0f, 3.0f, 0.0f))
|
2014-04-23 17:26:16 -04:00
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
[
|
|
|
|
|
SNew(SNumericEntryBox<NumericType>)
|
|
|
|
|
.Value(this, &FRangeStructCustomization<NumericType>::OnGetValue, UpperBoundValueWeakPtr, UpperBoundTypeWeakPtr)
|
|
|
|
|
.MinValue(this, &FRangeStructCustomization<NumericType>::OnGetValue, LowerBoundValueWeakPtr, LowerBoundTypeWeakPtr)
|
|
|
|
|
.MinSliderValue(this, &FRangeStructCustomization<NumericType>::OnGetValue, LowerBoundValueWeakPtr, LowerBoundTypeWeakPtr)
|
|
|
|
|
.MaxValue(MaxAllowedValue)
|
|
|
|
|
.MaxSliderValue(MaxAllowedValue)
|
|
|
|
|
.OnValueCommitted(this, &FRangeStructCustomization<NumericType>::OnValueCommitted, UpperBoundValueWeakPtr)
|
|
|
|
|
.OnValueChanged(this, &FRangeStructCustomization<NumericType>::OnValueChanged, UpperBoundValueWeakPtr)
|
|
|
|
|
.OnBeginSliderMovement(this, &FRangeStructCustomization<NumericType>::OnBeginSliderMovement)
|
|
|
|
|
.OnEndSliderMovement(this, &FRangeStructCustomization<NumericType>::OnEndSliderMovement)
|
|
|
|
|
.IsEnabled(this, &FRangeStructCustomization<NumericType>::OnQueryIfEnabled, UpperBoundTypeWeakPtr)
|
|
|
|
|
.Font(IDetailLayoutBuilder::GetDetailFont())
|
|
|
|
|
.AllowSpin(true)
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
+SHorizontalBox::Slot()
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
[
|
|
|
|
|
SNew(SComboBox< TSharedPtr<FString> >)
|
|
|
|
|
.OptionsSource(&ComboBoxList)
|
|
|
|
|
.OnGenerateWidget(this, &FRangeStructCustomization<NumericType>::OnGenerateComboWidget)
|
|
|
|
|
.OnSelectionChanged(this, &FRangeStructCustomization<NumericType>::OnComboSelectionChanged, UpperBoundTypeWeakPtr)
|
|
|
|
|
.InitiallySelectedItem(UpperBoundTypeSelectedItem)
|
|
|
|
|
[
|
|
|
|
|
// combo box button intentionally blank to avoid displaying excessive details
|
|
|
|
|
SNew(SSpacer)
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename NumericType>
|
2014-06-04 11:16:24 -04:00
|
|
|
void FRangeStructCustomization<NumericType>::CustomizeChildren(TSharedRef<IPropertyHandle> StructPropertyHandle, IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
|
2014-04-23 17:26:16 -04:00
|
|
|
{
|
|
|
|
|
// Don't display children, as editing them directly can break the constraints
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* FRangeStructCustomization callbacks
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
template <typename NumericType>
|
|
|
|
|
TOptional<NumericType> FRangeStructCustomization<NumericType>::OnGetValue(TWeakPtr<IPropertyHandle> ValueWeakPtr, TWeakPtr<IPropertyHandle> TypeWeakPtr) const
|
|
|
|
|
{
|
|
|
|
|
auto ValueSharedPtr = ValueWeakPtr.Pin();
|
|
|
|
|
auto TypeSharedPtr = TypeWeakPtr.Pin();
|
|
|
|
|
|
|
|
|
|
if (TypeSharedPtr.IsValid())
|
|
|
|
|
{
|
|
|
|
|
uint8 Type;
|
|
|
|
|
if (ensure(TypeSharedPtr->GetValue(Type) == FPropertyAccess::Success))
|
|
|
|
|
{
|
|
|
|
|
if (Type != ERangeBoundTypes::Open && ValueSharedPtr.IsValid())
|
|
|
|
|
{
|
|
|
|
|
NumericType Value;
|
|
|
|
|
if (ensure(ValueSharedPtr->GetValue(Value) == FPropertyAccess::Success))
|
|
|
|
|
{
|
|
|
|
|
return TOptional<NumericType>(Value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Value couldn't be accessed, or was bound type 'open'. Return an unset value
|
|
|
|
|
return TOptional<NumericType>();
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-12 23:22:18 -04:00
|
|
|
|
2014-04-23 17:26:16 -04:00
|
|
|
template <typename NumericType>
|
|
|
|
|
void FRangeStructCustomization<NumericType>::OnValueCommitted(NumericType NewValue, ETextCommit::Type CommitType, TWeakPtr<IPropertyHandle> HandleWeakPtr)
|
|
|
|
|
{
|
|
|
|
|
auto HandleSharedPtr = HandleWeakPtr.Pin();
|
|
|
|
|
if (HandleSharedPtr.IsValid() && (!bIsUsingSlider || (bIsUsingSlider && ShouldAllowSpin())))
|
|
|
|
|
{
|
|
|
|
|
ensure(HandleSharedPtr->SetValue(NewValue) == FPropertyAccess::Success);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-12 23:22:18 -04:00
|
|
|
|
2014-04-23 17:26:16 -04:00
|
|
|
template <typename NumericType>
|
|
|
|
|
void FRangeStructCustomization<NumericType>::OnValueChanged(NumericType NewValue, TWeakPtr<IPropertyHandle> HandleWeakPtr)
|
|
|
|
|
{
|
|
|
|
|
if (bIsUsingSlider && ShouldAllowSpin())
|
|
|
|
|
{
|
|
|
|
|
auto HandleSharedPtr = HandleWeakPtr.Pin();
|
|
|
|
|
if (HandleSharedPtr.IsValid())
|
|
|
|
|
{
|
|
|
|
|
ensure(HandleSharedPtr->SetValue(NewValue, EPropertyValueSetFlags::InteractiveChange) == FPropertyAccess::Success);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-12 23:22:18 -04:00
|
|
|
|
2014-04-23 17:26:16 -04:00
|
|
|
template <typename NumericType>
|
|
|
|
|
void FRangeStructCustomization<NumericType>::OnBeginSliderMovement()
|
|
|
|
|
{
|
|
|
|
|
bIsUsingSlider = true;
|
|
|
|
|
|
|
|
|
|
if (ShouldAllowSpin())
|
|
|
|
|
{
|
|
|
|
|
GEditor->BeginTransaction(LOCTEXT("SetRangeProperty", "Set Range Property"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-12 23:22:18 -04:00
|
|
|
|
2014-04-23 17:26:16 -04:00
|
|
|
template <typename NumericType>
|
|
|
|
|
void FRangeStructCustomization<NumericType>::OnEndSliderMovement(NumericType /*NewValue*/)
|
|
|
|
|
{
|
|
|
|
|
bIsUsingSlider = false;
|
|
|
|
|
|
|
|
|
|
if (ShouldAllowSpin())
|
|
|
|
|
{
|
|
|
|
|
GEditor->EndTransaction();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-12 23:22:18 -04:00
|
|
|
|
2014-04-23 17:26:16 -04:00
|
|
|
template <typename NumericType>
|
|
|
|
|
bool FRangeStructCustomization<NumericType>::OnQueryIfEnabled(TWeakPtr<IPropertyHandle> HandleWeakPtr) const
|
|
|
|
|
{
|
|
|
|
|
auto PropertyHandle = HandleWeakPtr.Pin();
|
|
|
|
|
if (PropertyHandle.IsValid())
|
|
|
|
|
{
|
|
|
|
|
uint8 BoundType;
|
|
|
|
|
if (ensure(PropertyHandle->GetValue(BoundType) == FPropertyAccess::Success))
|
|
|
|
|
{
|
|
|
|
|
return (BoundType != ERangeBoundTypes::Open);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-12 23:22:18 -04:00
|
|
|
|
2014-04-23 17:26:16 -04:00
|
|
|
template <typename NumericType>
|
|
|
|
|
bool FRangeStructCustomization<NumericType>::ShouldAllowSpin() const
|
|
|
|
|
{
|
|
|
|
|
uint8 LowerBoundType;
|
|
|
|
|
uint8 UpperBoundType;
|
|
|
|
|
if (ensure(LowerBoundTypeHandle->GetValue(LowerBoundType) == FPropertyAccess::Success) &&
|
|
|
|
|
ensure(UpperBoundTypeHandle->GetValue(UpperBoundType) == FPropertyAccess::Success))
|
|
|
|
|
{
|
|
|
|
|
return (LowerBoundType != ERangeBoundTypes::Open && UpperBoundType != ERangeBoundTypes::Open);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-12 23:22:18 -04:00
|
|
|
|
2014-04-23 17:26:16 -04:00
|
|
|
template <typename NumericType>
|
|
|
|
|
TSharedRef<SWidget> FRangeStructCustomization<NumericType>::OnGenerateComboWidget(TSharedPtr<FString> InComboString)
|
|
|
|
|
{
|
2014-12-02 13:48:53 -05:00
|
|
|
FText ToolTip;
|
2014-04-23 17:26:16 -04:00
|
|
|
|
|
|
|
|
// A list of tool tips should have been populated in a 1 to 1 correspondence
|
|
|
|
|
check(ComboBoxList.Num() == ComboBoxToolTips.Num());
|
|
|
|
|
|
|
|
|
|
if (ComboBoxToolTips.Num() > 0)
|
|
|
|
|
{
|
|
|
|
|
int32 Index = ComboBoxList.IndexOfByKey(InComboString);
|
|
|
|
|
if (ensure(Index >= 0))
|
|
|
|
|
{
|
2014-12-02 13:48:53 -05:00
|
|
|
ToolTip = ComboBoxToolTips[Index];
|
2014-04-23 17:26:16 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
SNew(SBox)
|
|
|
|
|
.WidthOverride(150.0f)
|
|
|
|
|
[
|
|
|
|
|
SNew(STextBlock)
|
2015-01-07 09:52:40 -05:00
|
|
|
.Text(FText::FromString(*InComboString))
|
2014-04-23 17:26:16 -04:00
|
|
|
.ToolTipText(ToolTip)
|
|
|
|
|
.Font(IDetailLayoutBuilder::GetDetailFont())
|
|
|
|
|
.IsEnabled(true)
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-12 23:22:18 -04:00
|
|
|
|
2014-04-23 17:26:16 -04:00
|
|
|
template <typename NumericType>
|
|
|
|
|
void FRangeStructCustomization<NumericType>::OnComboSelectionChanged(TSharedPtr<FString> InSelectedItem, ESelectInfo::Type SelectInfo, TWeakPtr<IPropertyHandle> HandleWeakPtr)
|
|
|
|
|
{
|
|
|
|
|
auto PropertyHandle = HandleWeakPtr.Pin();
|
|
|
|
|
if (PropertyHandle.IsValid())
|
|
|
|
|
{
|
|
|
|
|
int32 Index = ComboBoxList.IndexOfByKey(InSelectedItem);
|
|
|
|
|
if (ensure(Index >= 0))
|
|
|
|
|
{
|
|
|
|
|
ensure(PropertyHandle->SetValue(static_cast<uint8>(Index)) == FPropertyAccess::Success);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Only explicitly instantiate the types which are supported
|
|
|
|
|
*****************************************************************************/
|
2014-06-12 23:22:18 -04:00
|
|
|
|
2014-04-23 17:26:16 -04:00
|
|
|
template class FRangeStructCustomization<float>;
|
2022-05-03 19:47:22 -04:00
|
|
|
template class FRangeStructCustomization<double>;
|
2014-04-23 17:26:16 -04:00
|
|
|
template class FRangeStructCustomization<int32>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#undef LOCTEXT_NAMESPACE
|