Files
UnrealEngineUWP/Engine/Source/Editor/MovieSceneTools/Private/FrameNumberDetailsCustomization.cpp
max chen 6b7108ed78 Sequencer: Do not clear keyboard focus on commit for frame number text boxes. This fixes an issue where the right click properties popup disappears when you type in a frame number. This was marked as a regression when editing the Start Frame Offset because it used to be a float property but when changing it to a frame number property, it inherited this behavior.
#jira UE-72097
#rb matt.hoffman
#lockdown nick.penwarden

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: max.chen
#ROBOMERGE-SOURCE: CL 5696650 in //UE4/Release-4.22/... via CL 5711364
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR)

[CL 5720415 by max chen in Dev-VR branch]
2019-04-03 21:32:26 -04:00

89 lines
3.1 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "FrameNumberDetailsCustomization.h"
#include "IDetailPropertyRow.h"
#include "Misc/FrameNumber.h"
#include "IDetailChildrenBuilder.h"
#include "DetailLayoutBuilder.h"
#include "Widgets/Text/STextBlock.h"
#include "Widgets/Input/SEditableTextBox.h"
#include "PropertyCustomizationHelpers.h"
#include "Misc/FrameRate.h"
#define LOCTEXT_NAMESPACE "TimeManagement.FrameNumber"
void FFrameNumberDetailsCustomization::CustomizeChildren(TSharedRef<IPropertyHandle> PropertyHandle, IDetailChildrenBuilder& ChildBuilder, IPropertyTypeCustomizationUtils& CustomizationUtils)
{
// Check for Min/Max metadata on the property itself and we'll apply it to the child when changed.
const FString& MetaUIMinString = PropertyHandle->GetMetaData(TEXT("UIMin"));
const FString& MetaUIMaxString = PropertyHandle->GetMetaData(TEXT("UIMax"));
UIClampMin = TNumericLimits<int32>::Lowest();
UIClampMax = TNumericLimits<int32>::Max();
if (!MetaUIMinString.IsEmpty())
{
TTypeFromString<int32>::FromString(UIClampMin, *MetaUIMinString);
}
if (!MetaUIMaxString.IsEmpty())
{
TTypeFromString<int32>::FromString(UIClampMax, *MetaUIMaxString);
}
TMap<FName, TSharedRef<IPropertyHandle>> CustomizedProperties;
uint32 NumChildren = 0;
PropertyHandle->GetNumChildren(NumChildren);
// Add child properties to UI and pick out the properties which need customization
for (uint32 ChildIndex = 0; ChildIndex < NumChildren; ++ChildIndex)
{
TSharedRef<IPropertyHandle> ChildHandle = PropertyHandle->GetChildHandle(ChildIndex).ToSharedRef();
CustomizedProperties.Add(ChildHandle->GetProperty()->GetFName(), ChildHandle);
}
FrameNumberProperty = CustomizedProperties.FindChecked(GET_MEMBER_NAME_CHECKED(FFrameNumber, Value));
ChildBuilder.AddCustomRow(LOCTEXT("TimeLabel", "Time"))
.NameContent()
[
SNew(STextBlock)
.Text(PropertyHandle->GetPropertyDisplayName())
.ToolTipText(LOCTEXT("TimeLabelTooltip", "Time field which takes timecode, frames and seconds formats."))
.Font(CustomizationUtils.GetRegularFont())
]
.ValueContent()
[
SNew(SEditableTextBox)
.Text(this, &FFrameNumberDetailsCustomization::OnGetTimeText)
.OnTextCommitted(this, &FFrameNumberDetailsCustomization::OnTimeTextCommitted)
.SelectAllTextWhenFocused(true)
.ClearKeyboardFocusOnCommit(false)
.RevertTextOnEscape(true)
.Font(IDetailLayoutBuilder::GetDetailFont())
];
}
FText FFrameNumberDetailsCustomization::OnGetTimeText() const
{
int32 CurrentValue = 0.0;
FrameNumberProperty->GetValue(CurrentValue);
return FText::FromString(NumericTypeInterface->ToString(CurrentValue));
}
void FFrameNumberDetailsCustomization::OnTimeTextCommitted(const FText& InText, ETextCommit::Type CommitInfo)
{
int32 ExistingValue = 0.0;
FrameNumberProperty->GetValue(ExistingValue);
TOptional<double> TickResolution = NumericTypeInterface->FromString(InText.ToString(), ExistingValue);
if (TickResolution.IsSet())
{
double ClampedValue = FMath::Clamp(TickResolution.GetValue(), (double)UIClampMin, (double)UIClampMax);
FrameNumberProperty->SetValue((int32)ClampedValue);
}
}
#undef LOCTEXT_NAMESPACE