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

@ -1,20 +1,18 @@
{ {
"FileVersion": 3, "FileVersion": 3,
"Version": 1, "Version": 1,
"VersionName": "1.0", "VersionName": "0.1.0",
"FriendlyName": "CommonTime", "FriendlyName": "CommonTime",
"Description": "", "Description": "Provides an editor view for editing DateTime and Timespan values.",
"Category": "Editor", "Category": "Editor",
"CreatedBy": "MrRobinOfficial", "CreatedBy": "MrRobinOfficial",
"CreatedByURL": "https://github.com/MrRobinOfficial", "CreatedByURL": "https://github.com/MrRobinOfficial",
"DocsURL": "", "DocsURL": "https://github.com/MrRobinOfficial/Unreal-CommonTime",
"MarketplaceURL": "", "MarketplaceURL": "",
"SupportURL": "", "SupportURL": "https://github.com/MrRobinOfficial/Unreal-CommonTime/issues",
"EnabledByDefault": true, "EngineVersion": "5.3.0",
"CanContainContent": true, "CanContainContent": true,
"IsBetaVersion": false, "Installed": true,
"IsExperimentalVersion": false,
"Installed": false,
"Modules": [ "Modules": [
{ {
"Name": "CommonTime", "Name": "CommonTime",

8
Config/FilterPlugin.ini Normal file
View File

@ -0,0 +1,8 @@
[FilterPlugin]
; This section lists additional files which will be packaged along with your plugin. Paths should be listed relative to the root plugin directory, and
; may include "...", "*", and "?" wildcards to match directories, files, and individual characters respectively.
;
; Examples:
; /README.txt
; /Extras/...
; /Binaries/ThirdParty/*.dll

View File

@ -1 +1,42 @@
# Unreal-CommonTime <!-- markdownlint-disable-next-line -->
<p align="center">
<a href="#" rel="noopener" target="_blank"><img width="150" src="/Resources/Icon128.png" alt="CommonTime logo"></a>
</p>
<h1 align="center">CommonTime [Unreal Engine]</h1>
<div align="center">
*Provides an editor view for editing DateTime and Timespan values.*
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/mrrobinofficial/unreal-commontime/blob/HEAD/LICENSE.txt)
![plugin-status](https://img.shields.io/badge/plugin_status-ready_to_use-green)
![maintenance-status](https://img.shields.io/badge/maintenance-passively--maintained-yellowgreen.svg)
</div>
#
## ⚙️ Supported Platforms
This plug-in was last built against Unreal Engine 5.3.
## ⚒️ Installation
You can install from the <a href="https://github.com/MrRobinOfficial/Unreal-CommonTime/releases/latest">release section</a>.
Alternatively, you can install this plugin via terminal with [*git*](https://git-scm.com/). **Here is the command for installing it**.
```console
git clone git@github.com:MrRobinOfficial/Unreal-CommonTime.git CommonTime
```
#
<details open>
<summary><h2>🖼️ Screenshots</h2></summary>
</details>
#
## 🆘 Support
If you have any questions or issue, just write either to my [YouTube channel](https://www.youtube.com/@mrrobinofficial), [Email](mailto:mrrobin123mail@gmail.com) or [Twitter DM](https://twitter.com/MrRobinOfficial).

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

View File

@ -18,9 +18,13 @@
#include "Widgets/DeclarativeSyntaxSupport.h" #include "Widgets/DeclarativeSyntaxSupport.h"
#include "DetailLayoutBuilder.h" #include "DetailLayoutBuilder.h"
#include "Widgets/Input/SNumericEntryBox.h" #include "Widgets/Input/SNumericEntryBox.h"
#include "Widgets/Input/SVectorInputBox.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" #define LOCTEXT_NAMESPACE "MyDateTimeDetailCustomization"
@ -36,8 +40,95 @@ void FMyDateTimeDetailCustomization::CustomizeHeader(TSharedRef<IPropertyHandle>
{ {
PropertyHandle = StructPropertyHandle; PropertyHandle = StructPropertyHandle;
const FSlateColor FgColor = FSlateColor(FColor::Yellow); SAssignNew(YearEntryBox, SNumericEntryBox<int32>)
const FSlateColor BgColor = FSlateColor(FColor::Blue); .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 HeaderRow
.NameContent() .NameContent()
@ -45,273 +136,54 @@ void FMyDateTimeDetailCustomization::CustomizeHeader(TSharedRef<IPropertyHandle>
StructPropertyHandle->CreatePropertyNameWidget() StructPropertyHandle->CreatePropertyNameWidget()
] ]
.ValueContent() .ValueContent()
.MaxDesiredWidth(0.f)
.MinDesiredWidth(125.0f * 3.0f) .MinDesiredWidth(125.0f * 3.0f)
//.HAlign(HAlign_Fill) .MaxDesiredWidth(125.0f * 3.0f)
[ [
SNew(SVerticalBox) SNew(SVerticalBox)
+ SVerticalBox::Slot() + SVerticalBox::Slot()
.HAlign(HAlign_Fill)
.AutoHeight() .AutoHeight()
.Padding(0.0f, 1.0f)
[ [
SNew(SHorizontalBox) SNew(SHorizontalBox)
+ SHorizontalBox::Slot() + SHorizontalBox::Slot()
.Padding(0.0f, 2.0f) .Padding(0.0f, 0.0f, 2.0f, 0.0f)
[ [
SNew(SNumericEntryBox<int32>) YearEntryBox.ToSharedRef()
.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)*/
] ]
+ SHorizontalBox::Slot() + SHorizontalBox::Slot()
.Padding(3.75f, 2.0f) .Padding(2.0f, 0.0f)
[ [
SNew(SNumericEntryBox<int32>) MonthEntryBox.ToSharedRef()
.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)*/
] ]
+ SHorizontalBox::Slot() + SHorizontalBox::Slot()
.Padding(0.0f, 2.0f) .Padding(2.0f, 0.0f, 0.0f, 0.0f)
[ [
SNew(SNumericEntryBox<int32>) DayEntryBox.ToSharedRef()
.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)*/
] ]
] ]
+ SVerticalBox::Slot() + SVerticalBox::Slot()
.HAlign(HAlign_Fill)
.AutoHeight() .AutoHeight()
.Padding(0.0f, 1.0f) [
SNew(SSpacer)
.Size(FVector2D(8.0f))
]
+ SVerticalBox::Slot()
.AutoHeight()
[ [
SNew(SHorizontalBox) SNew(SHorizontalBox)
+ SHorizontalBox::Slot() + SHorizontalBox::Slot()
.Padding(0.0f, 2.0f) .Padding(0.0f, 0.0f, 2.0f, 0.0f)
[ [
SNew(SNumericEntryBox<int32>) HourEntryBox.ToSharedRef()
.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)*/
] ]
+ SHorizontalBox::Slot() + SHorizontalBox::Slot()
.Padding(3.75f, 2.0f) .Padding(2.0f, 0.0f)
[ [
SNew(SNumericEntryBox<int32>) MinuteEntryBox.ToSharedRef()
.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)*/
] ]
+ SHorizontalBox::Slot() + SHorizontalBox::Slot()
.Padding(0.0f, 2.0f) .Padding(2.0f, 0.0f, 0.0f, 0.0f)
[ [
SNew(SNumericEntryBox<int32>) SecondEntryBox.ToSharedRef()
.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)*/
] ]
] ]
]; ];
@ -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() void FMyDateTimeDetailCustomization::OnBeginSliderMovement()
{ {
bIsUsingSlider = true; bIsUsingSlider = true;

View File

@ -19,6 +19,10 @@
#include "DetailLayoutBuilder.h" #include "DetailLayoutBuilder.h"
#include "Widgets/Input/SNumericEntryBox.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" #define LOCTEXT_NAMESPACE "MyTimespanDetailCustomization"
@ -40,155 +44,75 @@ void FMyTimespanDetailCustomization::CustomizeHeader(
{ {
PropertyHandle = StructPropertyHandle; 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 HeaderRow
.NameContent() .NameContent()
[ [
StructPropertyHandle->CreatePropertyNameWidget() StructPropertyHandle->CreatePropertyNameWidget()
] ]
.ValueContent() .ValueContent()
.MaxDesiredWidth(0.f)
.MinDesiredWidth(125.0f * 3.0f) .MinDesiredWidth(125.0f * 3.0f)
//.HAlign(HAlign_Fill) .MaxDesiredWidth(125.0f * 3.0f)
[ [
SNew(SHorizontalBox) SNew(SHorizontalBox)
+ SHorizontalBox::Slot() + SHorizontalBox::Slot()
.Padding(0.0f, 2.0f) .Padding(0.0f)
[ [
SNew(SNumericEntryBox<int32>) HourEntryBox.ToSharedRef()
.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)
] ]
+ SHorizontalBox::Slot() + SHorizontalBox::Slot()
.Padding(3.75f, 2.0f) .Padding(2.5f, 0.0f)
[ [
SNew(SNumericEntryBox<int32>) MinuteEntryBox.ToSharedRef()
.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)*/
] ]
+ SHorizontalBox::Slot() + SHorizontalBox::Slot()
.Padding(0.0f, 2.0f) .Padding(0.0f)
[ [
SNew(SNumericEntryBox<int32>) SecondEntryBox.ToSharedRef()
.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)*/
] ]
]; ];
} }

View File

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