Fixed the editor view

This commit is contained in:
MrRobin
2023-10-28 20:43:30 +02:00
parent 1a7c2f384b
commit cf0128db21
8 changed files with 237 additions and 434 deletions

View File

@ -18,9 +18,13 @@
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "DetailLayoutBuilder.h"
#include "Widgets/Input/SNumericEntryBox.h"
#include "Widgets/Input/SVectorInputBox.h"
#include "Widgets/Input/NumericTypeInterface.h"
#include "Widgets/Input/NumericUnitTypeInterface.inl"
#include "Math/UnitConversion.h"
// SExpanderArrow
#define LOCTEXT_NAMESPACE "MyDateTimeDetailCustomization"
@ -36,8 +40,95 @@ void FMyDateTimeDetailCustomization::CustomizeHeader(TSharedRef<IPropertyHandle>
{
PropertyHandle = StructPropertyHandle;
const FSlateColor FgColor = FSlateColor(FColor::Yellow);
const FSlateColor BgColor = FSlateColor(FColor::Blue);
SAssignNew(YearEntryBox, SNumericEntryBox<int32>)
.AllowSpin(true)
.MinValue(1)
.MaxValue(9999)
.MinSliderValue(1)
.MaxSliderValue(9999)
.Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 3)
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 3)
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 3)
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<int32>(EUnit::Years)))
.LinearDeltaSensitivity(1);
SAssignNew(MonthEntryBox, SNumericEntryBox<int32>)
.AllowSpin(true)
.MinValue(1)
.MaxValue(12)
.MinSliderValue(1)
.MaxSliderValue(12)
.Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 4)
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 4)
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 4)
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<int32>(EUnit::Months)))
.LinearDeltaSensitivity(1);
SAssignNew(DayEntryBox, SNumericEntryBox<int32>)
.AllowSpin(true)
.MinValue(1)
.MaxValue(31)
.MinSliderValue(1)
.MaxSliderValue(31)
.Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 5)
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 5)
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 5)
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<int32>(EUnit::Days)))
.LinearDeltaSensitivity(1);
SAssignNew(HourEntryBox, SNumericEntryBox<int32>)
.AllowSpin(true)
.MinValue(0)
.MaxValue(23)
.MinSliderValue(0)
.MaxSliderValue(23)
.Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 0)
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 0)
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 0)
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<int32>(EUnit::Hours)))
.LinearDeltaSensitivity(1);
SAssignNew(MinuteEntryBox, SNumericEntryBox<int32>)
.AllowSpin(true)
.MinValue(0)
.MaxValue(59)
.MinSliderValue(0)
.MaxSliderValue(59)
.Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 1)
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 1)
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 1)
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<int32>(EUnit::Minutes)))
.LinearDeltaSensitivity(1);
SAssignNew(SecondEntryBox, SNumericEntryBox<int32>)
.AllowSpin(true)
.MinValue(0)
.MaxValue(59)
.MinSliderValue(0)
.MaxSliderValue(59)
.Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 2)
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 2)
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 2)
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<int32>(EUnit::Seconds)))
.LinearDeltaSensitivity(1);
HeaderRow
.NameContent()
@ -45,273 +136,54 @@ void FMyDateTimeDetailCustomization::CustomizeHeader(TSharedRef<IPropertyHandle>
StructPropertyHandle->CreatePropertyNameWidget()
]
.ValueContent()
.MaxDesiredWidth(0.f)
.MinDesiredWidth(125.0f * 3.0f)
//.HAlign(HAlign_Fill)
.MaxDesiredWidth(125.0f * 3.0f)
[
SNew(SVerticalBox)
+ SVerticalBox::Slot()
.HAlign(HAlign_Fill)
.AutoHeight()
.Padding(0.0f, 1.0f)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.Padding(0.0f, 2.0f)
.Padding(0.0f, 0.0f, 2.0f, 0.0f)
[
SNew(SNumericEntryBox<int32>)
.AllowSpin(true)
.MinValue(1)
.MaxValue(9999)
.MinSliderValue(1)
.MaxSliderValue(9999)
.Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 3)
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 3)
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 3)
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
.ToolTipText(this, &FMyDateTimeDetailCustomization::GetValueAsText, 3)
//.ToolTipText(MakeAttributeLambda([Value, TooltipText]
//{
// if (Value.Get().IsSet())
// {
// return FText::Format(TooltipText, Value.Get().GetValue());
// }
// return NSLOCTEXT("SVectorInputBox", "MultipleValues", "Multiple Values");
//}))
//.UndeterminedString(NSLOCTEXT("SVectorInputBox", "MultipleValues", "Multiple Values"))
//.ContextMenuExtender(OnContextMenuExtenderComponent)
//.TypeInterface(InArgs._TypeInterface)
//.MinValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MinVector))
//.MaxValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MaxVector))
//.MinSliderValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MinSliderVector))
//.MaxSliderValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MaxSliderVector))
.LinearDeltaSensitivity(1)
/*.Delta(InArgs._SpinDelta)*/
/*.OnBeginSliderMovement(CreatePerComponentSliderMovementEvent(InArgs._OnBeginSliderMovement, OnComponentBeginSliderMovement))*/
/*.OnEndSliderMovement(CreatePerComponentSliderMovementEvent<FOnNumericValueChanged, NumericType>(InArgs._OnEndSliderMovement, OnComponentEndSliderMovement))*/
/*.DisplayToggle(InArgs._DisplayToggle)
.TogglePadding(InArgs._TogglePadding)
.ToggleChecked(ToggleChecked)
.OnToggleChanged(OnToggleChanged)*/
YearEntryBox.ToSharedRef()
]
+ SHorizontalBox::Slot()
.Padding(3.75f, 2.0f)
.Padding(2.0f, 0.0f)
[
SNew(SNumericEntryBox<int32>)
.AllowSpin(true)
.MinValue(1)
.MaxValue(12)
.MinSliderValue(1)
.MaxSliderValue(12)
.Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 4)
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 4)
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 4)
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
.ToolTipText(this, &FMyDateTimeDetailCustomization::GetValueAsText, 4)
//.OnValueChanged(CreatePerComponentChanged(ComponentIndex, OnComponentChanged, InArgs._ConstrainVector))
//.OnValueCommitted(CreatePerComponentCommitted(ComponentIndex, OnComponentCommitted, InArgs._ConstrainVector))
//.ToolTipText(MakeAttributeLambda([Value, TooltipText]
//{
// if (Value.Get().IsSet())
// {
// return FText::Format(TooltipText, Value.Get().GetValue());
// }
// return NSLOCTEXT("SVectorInputBox", "MultipleValues", "Multiple Values");
//}))
//.UndeterminedString(NSLOCTEXT("SVectorInputBox", "MultipleValues", "Multiple Values"))
//.ContextMenuExtender(OnContextMenuExtenderComponent)
//.TypeInterface(InArgs._TypeInterface)
//.MinValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MinVector))
//.MaxValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MaxVector))
//.MinSliderValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MinSliderVector))
//.MaxSliderValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MaxSliderVector))
.LinearDeltaSensitivity(1)
/*.Delta(InArgs._SpinDelta)*/
/*.OnBeginSliderMovement(CreatePerComponentSliderMovementEvent(InArgs._OnBeginSliderMovement, OnComponentBeginSliderMovement))*/
/*.OnEndSliderMovement(CreatePerComponentSliderMovementEvent<FOnNumericValueChanged, NumericType>(InArgs._OnEndSliderMovement, OnComponentEndSliderMovement))*/
/*.DisplayToggle(InArgs._DisplayToggle)
.TogglePadding(InArgs._TogglePadding)
.ToggleChecked(ToggleChecked)
.OnToggleChanged(OnToggleChanged)*/
MonthEntryBox.ToSharedRef()
]
+ SHorizontalBox::Slot()
.Padding(0.0f, 2.0f)
.Padding(2.0f, 0.0f, 0.0f, 0.0f)
[
SNew(SNumericEntryBox<int32>)
.AllowSpin(true)
.MinValue(1)
.MaxValue(31)
.MinSliderValue(1)
.MaxSliderValue(31)
.Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 5)
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 5)
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 5)
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
.ToolTipText(this, &FMyDateTimeDetailCustomization::GetValueAsText, 5)
//.OnValueChanged(CreatePerComponentChanged(ComponentIndex, OnComponentChanged, InArgs._ConstrainVector))
//.OnValueCommitted(CreatePerComponentCommitted(ComponentIndex, OnComponentCommitted, InArgs._ConstrainVector))
//.ToolTipText(MakeAttributeLambda([Value, TooltipText]
//{
// if (Value.Get().IsSet())
// {
// return FText::Format(TooltipText, Value.Get().GetValue());
// }
// return NSLOCTEXT("SVectorInputBox", "MultipleValues", "Multiple Values");
//}))
//.UndeterminedString(NSLOCTEXT("SVectorInputBox", "MultipleValues", "Multiple Values"))
//.ContextMenuExtender(OnContextMenuExtenderComponent)
//.TypeInterface(InArgs._TypeInterface)
//.MinValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MinVector))
//.MaxValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MaxVector))
//.MinSliderValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MinSliderVector))
//.MaxSliderValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MaxSliderVector))
.LinearDeltaSensitivity(1)
/*.Delta(InArgs._SpinDelta)*/
/*.OnBeginSliderMovement(CreatePerComponentSliderMovementEvent(InArgs._OnBeginSliderMovement, OnComponentBeginSliderMovement))*/
/*.OnEndSliderMovement(CreatePerComponentSliderMovementEvent<FOnNumericValueChanged, NumericType>(InArgs._OnEndSliderMovement, OnComponentEndSliderMovement))*/
/*.DisplayToggle(InArgs._DisplayToggle)
.TogglePadding(InArgs._TogglePadding)
.ToggleChecked(ToggleChecked)
.OnToggleChanged(OnToggleChanged)*/
DayEntryBox.ToSharedRef()
]
]
+ SVerticalBox::Slot()
.HAlign(HAlign_Fill)
.AutoHeight()
.Padding(0.0f, 1.0f)
[
SNew(SSpacer)
.Size(FVector2D(8.0f))
]
+ SVerticalBox::Slot()
.AutoHeight()
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.Padding(0.0f, 2.0f)
.Padding(0.0f, 0.0f, 2.0f, 0.0f)
[
SNew(SNumericEntryBox<int32>)
.AllowSpin(true)
.MinValue(0)
.MaxValue(23)
.MinSliderValue(0)
.MaxSliderValue(23)
.Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 0)
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 0)
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 0)
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
.ToolTipText(this, &FMyDateTimeDetailCustomization::GetValueAsText, 0)
//.OnValueChanged(CreatePerComponentChanged(ComponentIndex, OnComponentChanged, InArgs._ConstrainVector))
//.OnValueCommitted(CreatePerComponentCommitted(ComponentIndex, OnComponentCommitted, InArgs._ConstrainVector))
//.ToolTipText(MakeAttributeLambda([Value, TooltipText]
//{
// if (Value.Get().IsSet())
// {
// return FText::Format(TooltipText, Value.Get().GetValue());
// }
// return NSLOCTEXT("SVectorInputBox", "MultipleValues", "Multiple Values");
//}))
//.UndeterminedString(NSLOCTEXT("SVectorInputBox", "MultipleValues", "Multiple Values"))
//.ContextMenuExtender(OnContextMenuExtenderComponent)
//.TypeInterface(InArgs._TypeInterface)
//.MinValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MinVector))
//.MaxValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MaxVector))
//.MinSliderValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MinSliderVector))
//.MaxSliderValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MaxSliderVector))
.LinearDeltaSensitivity(1)
/*.Delta(InArgs._SpinDelta)*/
/*.OnBeginSliderMovement(CreatePerComponentSliderMovementEvent(InArgs._OnBeginSliderMovement, OnComponentBeginSliderMovement))*/
/*.OnEndSliderMovement(CreatePerComponentSliderMovementEvent<FOnNumericValueChanged, NumericType>(InArgs._OnEndSliderMovement, OnComponentEndSliderMovement))*/
/*.DisplayToggle(InArgs._DisplayToggle)
.TogglePadding(InArgs._TogglePadding)
.ToggleChecked(ToggleChecked)
.OnToggleChanged(OnToggleChanged)*/
HourEntryBox.ToSharedRef()
]
+ SHorizontalBox::Slot()
.Padding(3.75f, 2.0f)
.Padding(2.0f, 0.0f)
[
SNew(SNumericEntryBox<int32>)
.AllowSpin(true)
.MinValue(0)
.MaxValue(59)
.MinSliderValue(0)
.MaxSliderValue(59)
.Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 1)
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 1)
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 1)
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
.ToolTipText(this, &FMyDateTimeDetailCustomization::GetValueAsText, 1)
//.OnValueChanged(CreatePerComponentChanged(ComponentIndex, OnComponentChanged, InArgs._ConstrainVector))
//.OnValueCommitted(CreatePerComponentCommitted(ComponentIndex, OnComponentCommitted, InArgs._ConstrainVector))
//.ToolTipText(MakeAttributeLambda([Value, TooltipText]
//{
// if (Value.Get().IsSet())
// {
// return FText::Format(TooltipText, Value.Get().GetValue());
// }
// return NSLOCTEXT("SVectorInputBox", "MultipleValues", "Multiple Values");
//}))
//.UndeterminedString(NSLOCTEXT("SVectorInputBox", "MultipleValues", "Multiple Values"))
//.ContextMenuExtender(OnContextMenuExtenderComponent)
//.TypeInterface(InArgs._TypeInterface)
//.MinValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MinVector))
//.MaxValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MaxVector))
//.MinSliderValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MinSliderVector))
//.MaxSliderValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MaxSliderVector))
.LinearDeltaSensitivity(1)
/*.Delta(InArgs._SpinDelta)*/
/*.OnBeginSliderMovement(CreatePerComponentSliderMovementEvent(InArgs._OnBeginSliderMovement, OnComponentBeginSliderMovement))*/
/*.OnEndSliderMovement(CreatePerComponentSliderMovementEvent<FOnNumericValueChanged, NumericType>(InArgs._OnEndSliderMovement, OnComponentEndSliderMovement))*/
/*.DisplayToggle(InArgs._DisplayToggle)
.TogglePadding(InArgs._TogglePadding)
.ToggleChecked(ToggleChecked)
.OnToggleChanged(OnToggleChanged)*/
MinuteEntryBox.ToSharedRef()
]
+ SHorizontalBox::Slot()
.Padding(0.0f, 2.0f)
.Padding(2.0f, 0.0f, 0.0f, 0.0f)
[
SNew(SNumericEntryBox<int32>)
.AllowSpin(true)
.MinValue(0)
.MaxValue(59)
.MinSliderValue(0)
.MaxSliderValue(59)
.Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 2)
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 2)
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 2)
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
.ToolTipText(this, &FMyDateTimeDetailCustomization::GetValueAsText, 2)
//.OnValueChanged(CreatePerComponentChanged(ComponentIndex, OnComponentChanged, InArgs._ConstrainVector))
//.OnValueCommitted(CreatePerComponentCommitted(ComponentIndex, OnComponentCommitted, InArgs._ConstrainVector))
//.ToolTipText(MakeAttributeLambda([Value, TooltipText]
//{
// if (Value.Get().IsSet())
// {
// return FText::Format(TooltipText, Value.Get().GetValue());
// }
// return NSLOCTEXT("SVectorInputBox", "MultipleValues", "Multiple Values");
//}))
//.UndeterminedString(NSLOCTEXT("SVectorInputBox", "MultipleValues", "Multiple Values"))
//.ContextMenuExtender(OnContextMenuExtenderComponent)
//.TypeInterface(InArgs._TypeInterface)
//.MinValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MinVector))
//.MaxValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MaxVector))
//.MinSliderValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MinSliderVector))
//.MaxSliderValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MaxSliderVector))
.LinearDeltaSensitivity(1)
/*.Delta(InArgs._SpinDelta)*/
/*.OnBeginSliderMovement(CreatePerComponentSliderMovementEvent(InArgs._OnBeginSliderMovement, OnComponentBeginSliderMovement))*/
/*.OnEndSliderMovement(CreatePerComponentSliderMovementEvent<FOnNumericValueChanged, NumericType>(InArgs._OnEndSliderMovement, OnComponentEndSliderMovement))*/
/*.DisplayToggle(InArgs._DisplayToggle)
.TogglePadding(InArgs._TogglePadding)
.ToggleChecked(ToggleChecked)
.OnToggleChanged(OnToggleChanged)*/
SecondEntryBox.ToSharedRef()
]
]
];
@ -359,55 +231,6 @@ TOptional<int32> FMyDateTimeDetailCustomization::OnGetValue(int32 Index) const
}
}
FText FMyDateTimeDetailCustomization::GetValueAsText(int32 Index) const
{
const TOptional<int32>& Value = OnGetValue(Index);
FFormatNamedArguments Args;
switch (Index)
{
case 0:
Args.Add(TEXT("Key"), INVTEXT("Hour"));
Args.Add(TEXT("Desc"), INVTEXT("A hour between 0-23"));
break;
case 1:
Args.Add(TEXT("Key"), INVTEXT("Minute"));
Args.Add(TEXT("Desc"), INVTEXT("A minute between 0-59"));
break;
case 2:
Args.Add(TEXT("Key"), INVTEXT("Second"));
Args.Add(TEXT("Desc"), INVTEXT("A second between 0-59"));
break;
case 3:
Args.Add(TEXT("Key"), INVTEXT("Year"));
Args.Add(TEXT("Desc"), INVTEXT("A year between 1-9999"));
break;
case 4:
Args.Add(TEXT("Key"), INVTEXT("Month"));
Args.Add(TEXT("Desc"), INVTEXT("A month between 1-12"));
break;
case 5:
Args.Add(TEXT("Key"), INVTEXT("Day"));
Args.Add(TEXT("Desc"), INVTEXT("A day between 1-31"));
break;
}
if (Value.IsSet() == true)
{
Args.Add(TEXT("Value"), Value.GetValue());
return FText::Format(LOCTEXT("DateTime", "{Key}: {Value} - {Desc}"), Args);
}
return FText::Format(LOCTEXT("DateTime", "{Key} - {Desc}"), Args);
}
void FMyDateTimeDetailCustomization::OnBeginSliderMovement()
{
bIsUsingSlider = true;

View File

@ -19,6 +19,10 @@
#include "DetailLayoutBuilder.h"
#include "Widgets/Input/SNumericEntryBox.h"
#include "Widgets/Input/SVectorInputBox.h"
#include "Widgets/Input/NumericTypeInterface.h"
#include "Widgets/Input/NumericUnitTypeInterface.inl"
#include "Math/UnitConversion.h"
#define LOCTEXT_NAMESPACE "MyTimespanDetailCustomization"
@ -40,155 +44,75 @@ void FMyTimespanDetailCustomization::CustomizeHeader(
{
PropertyHandle = StructPropertyHandle;
SAssignNew(HourEntryBox, SNumericEntryBox<int32>)
.AllowSpin(true)
.MinValue(0)
.MaxValue(23)
.MinSliderValue(0)
.MaxSliderValue(23)
.Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyTimespanDetailCustomization::OnGetValue, 0)
.OnValueChanged(this, &FMyTimespanDetailCustomization::OnValueChanged, 0)
.OnValueCommitted(this, &FMyTimespanDetailCustomization::OnValueCommitted, 0)
.OnBeginSliderMovement(this, &FMyTimespanDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyTimespanDetailCustomization::OnEndSliderMovement)
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<int32>(EUnit::Hours)))
.LinearDeltaSensitivity(1);
SAssignNew(MinuteEntryBox, SNumericEntryBox<int32>)
.AllowSpin(true)
.MinValue(0)
.MaxValue(59)
.MinSliderValue(0)
.MaxSliderValue(59)
.Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyTimespanDetailCustomization::OnGetValue, 1)
.OnValueChanged(this, &FMyTimespanDetailCustomization::OnValueChanged, 1)
.OnValueCommitted(this, &FMyTimespanDetailCustomization::OnValueCommitted, 1)
.OnBeginSliderMovement(this, &FMyTimespanDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyTimespanDetailCustomization::OnEndSliderMovement)
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<int32>(EUnit::Minutes)))
.LinearDeltaSensitivity(1);
SAssignNew(SecondEntryBox, SNumericEntryBox<int32>)
.AllowSpin(true)
.MinValue(0)
.MaxValue(59)
.MinSliderValue(0)
.MaxSliderValue(59)
.Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyTimespanDetailCustomization::OnGetValue, 2)
.OnValueChanged(this, &FMyTimespanDetailCustomization::OnValueChanged, 2)
.OnValueCommitted(this, &FMyTimespanDetailCustomization::OnValueCommitted, 2)
.OnBeginSliderMovement(this, &FMyTimespanDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyTimespanDetailCustomization::OnEndSliderMovement)
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<int32>(EUnit::Seconds)))
.LinearDeltaSensitivity(1);
HeaderRow
.NameContent()
[
StructPropertyHandle->CreatePropertyNameWidget()
]
.ValueContent()
.MaxDesiredWidth(0.f)
.MinDesiredWidth(125.0f * 3.0f)
//.HAlign(HAlign_Fill)
.MaxDesiredWidth(125.0f * 3.0f)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.Padding(0.0f, 2.0f)
.Padding(0.0f)
[
SNew(SNumericEntryBox<int32>)
.AllowSpin(true)
.MinValue(0)
.MaxValue(23)
.MinSliderValue(0)
.MaxSliderValue(23)
.Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyTimespanDetailCustomization::OnGetValue, 0)
.OnValueChanged(this, &FMyTimespanDetailCustomization::OnValueChanged, 0)
.OnValueCommitted(this, &FMyTimespanDetailCustomization::OnValueCommitted, 0)
.OnBeginSliderMovement(this, &FMyTimespanDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyTimespanDetailCustomization::OnEndSliderMovement)
//.OnValueChanged(CreatePerComponentChanged(ComponentIndex, OnComponentChanged, InArgs._ConstrainVector))
//.OnValueCommitted(CreatePerComponentCommitted(ComponentIndex, OnComponentCommitted, InArgs._ConstrainVector))
//.ToolTipText(MakeAttributeLambda([Value, TooltipText]
//{
// if (Value.Get().IsSet())
// {
// return FText::Format(TooltipText, Value.Get().GetValue());
// }
// return NSLOCTEXT("SVectorInputBox", "MultipleValues", "Multiple Values");
//}))
//.UndeterminedString(NSLOCTEXT("SVectorInputBox", "MultipleValues", "Multiple Values"))
//.ContextMenuExtender(OnContextMenuExtenderComponent)
//.TypeInterface(InArgs._TypeInterface)
//.MinValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MinVector))
//.MaxValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MaxVector))
//.MinSliderValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MinSliderVector))
//.MaxSliderValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MaxSliderVector))
.LinearDeltaSensitivity(1)
/*.Delta(InArgs._SpinDelta)*/
/*.OnBeginSliderMovement(CreatePerComponentSliderMovementEvent(InArgs._OnBeginSliderMovement, OnComponentBeginSliderMovement))*/
/*.OnEndSliderMovement(CreatePerComponentSliderMovementEvent<FOnNumericValueChanged, NumericType>(InArgs._OnEndSliderMovement, OnComponentEndSliderMovement))*/
/*.DisplayToggle(InArgs._DisplayToggle)
.TogglePadding(InArgs._TogglePadding)
.ToggleChecked(ToggleChecked)
.OnToggleChanged(OnToggleChanged)*/
//SNew(SNumericEntryBox<int32>)
// .AllowSpin(true)
// .Font(IDetailLayoutBuilder::GetDetailFont())
// .Value(this, &FMyTimespanDetailCustomization::OnGetValue, 0)
// .MinValue(0)
// .MaxValue(23)
// .MinSliderValue(0)
// .MaxSliderValue(23)
// .LabelPadding(FMargin(3.f))
// .LabelLocation(SNumericEntryBox<int32>::ELabelLocation::Inside)
// .UndeterminedString(NSLOCTEXT("PropertyEditor", "MultipleValues", "Multiple Values"))
// .OnValueCommitted(const_cast<FMyTimespanDetailCustomization*>(this),&FMyTimespanDetailCustomization::OnValueCommitted, 0)
// .OnValueChanged(const_cast<FMyTimespanDetailCustomization*>(this),&FMyTimespanDetailCustomization::OnValueChanged, 0)
// .OnBeginSliderMovement(const_cast<FMyTimespanDetailCustomization*>(this), &FMyTimespanDetailCustomization::OnBeginSliderMovement)
// .OnEndSliderMovement(const_cast<FMyTimespanDetailCustomization*>(this), &FMyTimespanDetailCustomization::OnEndSliderMovement)
HourEntryBox.ToSharedRef()
]
+ SHorizontalBox::Slot()
.Padding(3.75f, 2.0f)
.Padding(2.5f, 0.0f)
[
SNew(SNumericEntryBox<int32>)
.AllowSpin(true)
.MinValue(0)
.MaxValue(59)
.MinSliderValue(0)
.MaxSliderValue(59)
.Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyTimespanDetailCustomization::OnGetValue, 1)
.OnValueChanged(this, &FMyTimespanDetailCustomization::OnValueChanged, 1)
.OnValueCommitted(this, &FMyTimespanDetailCustomization::OnValueCommitted, 1)
.OnBeginSliderMovement(this, &FMyTimespanDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyTimespanDetailCustomization::OnEndSliderMovement)
//.OnValueChanged(CreatePerComponentChanged(ComponentIndex, OnComponentChanged, InArgs._ConstrainVector))
//.OnValueCommitted(CreatePerComponentCommitted(ComponentIndex, OnComponentCommitted, InArgs._ConstrainVector))
//.ToolTipText(MakeAttributeLambda([Value, TooltipText]
//{
// if (Value.Get().IsSet())
// {
// return FText::Format(TooltipText, Value.Get().GetValue());
// }
// return NSLOCTEXT("SVectorInputBox", "MultipleValues", "Multiple Values");
//}))
//.UndeterminedString(NSLOCTEXT("SVectorInputBox", "MultipleValues", "Multiple Values"))
//.ContextMenuExtender(OnContextMenuExtenderComponent)
//.TypeInterface(InArgs._TypeInterface)
//.MinValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MinVector))
//.MaxValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MaxVector))
//.MinSliderValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MinSliderVector))
//.MaxSliderValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MaxSliderVector))
.LinearDeltaSensitivity(1)
/*.Delta(InArgs._SpinDelta)*/
/*.OnBeginSliderMovement(CreatePerComponentSliderMovementEvent(InArgs._OnBeginSliderMovement, OnComponentBeginSliderMovement))*/
/*.OnEndSliderMovement(CreatePerComponentSliderMovementEvent<FOnNumericValueChanged, NumericType>(InArgs._OnEndSliderMovement, OnComponentEndSliderMovement))*/
/*.DisplayToggle(InArgs._DisplayToggle)
.TogglePadding(InArgs._TogglePadding)
.ToggleChecked(ToggleChecked)
.OnToggleChanged(OnToggleChanged)*/
MinuteEntryBox.ToSharedRef()
]
+ SHorizontalBox::Slot()
.Padding(0.0f, 2.0f)
.Padding(0.0f)
[
SNew(SNumericEntryBox<int32>)
.AllowSpin(true)
.MinValue(0)
.MaxValue(59)
.MinSliderValue(0)
.MaxSliderValue(59)
.Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyTimespanDetailCustomization::OnGetValue, 2)
.OnValueChanged(this, &FMyTimespanDetailCustomization::OnValueChanged, 2)
.OnValueCommitted(this, &FMyTimespanDetailCustomization::OnValueCommitted, 2)
.OnBeginSliderMovement(this, &FMyTimespanDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyTimespanDetailCustomization::OnEndSliderMovement)
//.OnValueChanged(CreatePerComponentChanged(ComponentIndex, OnComponentChanged, InArgs._ConstrainVector))
//.OnValueCommitted(CreatePerComponentCommitted(ComponentIndex, OnComponentCommitted, InArgs._ConstrainVector))
//.ToolTipText(MakeAttributeLambda([Value, TooltipText]
//{
// if (Value.Get().IsSet())
// {
// return FText::Format(TooltipText, Value.Get().GetValue());
// }
// return NSLOCTEXT("SVectorInputBox", "MultipleValues", "Multiple Values");
//}))
//.UndeterminedString(NSLOCTEXT("SVectorInputBox", "MultipleValues", "Multiple Values"))
//.ContextMenuExtender(OnContextMenuExtenderComponent)
//.TypeInterface(InArgs._TypeInterface)
//.MinValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MinVector))
//.MaxValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MaxVector))
//.MinSliderValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MinSliderVector))
//.MaxSliderValue(CreatePerComponentGetter(ComponentIndex, TOptional<int32>(), InArgs._MaxSliderVector))
.LinearDeltaSensitivity(1)
/*.Delta(InArgs._SpinDelta)*/
/*.OnBeginSliderMovement(CreatePerComponentSliderMovementEvent(InArgs._OnBeginSliderMovement, OnComponentBeginSliderMovement))*/
/*.OnEndSliderMovement(CreatePerComponentSliderMovementEvent<FOnNumericValueChanged, NumericType>(InArgs._OnEndSliderMovement, OnComponentEndSliderMovement))*/
/*.DisplayToggle(InArgs._DisplayToggle)
.TogglePadding(InArgs._TogglePadding)
.ToggleChecked(ToggleChecked)
.OnToggleChanged(OnToggleChanged)*/
SecondEntryBox.ToSharedRef()
]
];
}

View File

@ -12,7 +12,7 @@ class IPropertyHandle;
class SEditableTextBox;
/**
* Implements a details view customization for the FTimespan structure.
* Implements a details view customization for the FDateTime structure.
*/
class FMyDateTimeDetailCustomization
: public IPropertyTypeCustomization
@ -37,8 +37,6 @@ public:
private:
TOptional<int32> OnGetValue(int32 Index) const;
/** @return the value being observed by the Numeric Entry Box as a FText */
FText GetValueAsText(int32 Index) const;
void OnValueCommitted(int32 NewValue, ETextCommit::Type CommitType, int32 Index);
void OnValueChanged(int32 NewValue, int32 Index);
void OnBeginSliderMovement();
@ -50,4 +48,11 @@ private:
/** True if a value is being changed by dragging a slider */
bool bIsUsingSlider;
TSharedPtr<SWidget> YearEntryBox;
TSharedPtr<SWidget> MonthEntryBox;
TSharedPtr<SWidget> DayEntryBox;
TSharedPtr<SWidget> HourEntryBox;
TSharedPtr<SWidget> MinuteEntryBox;
TSharedPtr<SWidget> SecondEntryBox;
};

View File

@ -47,4 +47,8 @@ private:
/** True if a value is being changed by dragging a slider */
bool bIsUsingSlider;
TSharedPtr<SWidget> HourEntryBox;
TSharedPtr<SWidget> MinuteEntryBox;
TSharedPtr<SWidget> SecondEntryBox;
};