Files
UnrealEngineUWP/Engine/Source/Editor/DetailCustomizations/Private/KeyStructCustomization.cpp
Matthew Griffin bb70b349ce Merging CL 2804086 from //UE4/Release-4.11 to Dev-Main (//UE4/Dev-Main) to isolate copyright update
#lockdown Nick.Penwarden

[CL 2819020 by Matthew Griffin in Main branch]
2016-01-07 08:17:16 -05:00

70 lines
1.9 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#include "DetailCustomizationsPrivatePCH.h"
#include "KeyStructCustomization.h"
#include "ScopedTransaction.h"
#include "SKeySelector.h"
#define LOCTEXT_NAMESPACE "FKeyStructCustomization"
/* FKeyStructCustomization static interface
*****************************************************************************/
TSharedRef<IPropertyTypeCustomization> FKeyStructCustomization::MakeInstance( )
{
return MakeShareable(new FKeyStructCustomization);
}
/* IPropertyTypeCustomization interface
*****************************************************************************/
void FKeyStructCustomization::CustomizeHeader( TSharedRef<class IPropertyHandle> StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils )
{
PropertyHandle = StructPropertyHandle;
// create struct header
HeaderRow.NameContent()
[
StructPropertyHandle->CreatePropertyNameWidget()
]
.ValueContent()
.MinDesiredWidth(125.0f)
.MaxDesiredWidth(325.0f)
[
SNew(SKeySelector)
.CurrentKey(this, &FKeyStructCustomization::GetCurrentKey)
.OnKeyChanged(this, &FKeyStructCustomization::OnKeyChanged)
.Font(StructCustomizationUtils.GetRegularFont())
];
}
TOptional<FKey> FKeyStructCustomization::GetCurrentKey() const
{
TArray<void*> StructPtrs;
PropertyHandle->AccessRawData(StructPtrs);
if (StructPtrs.Num() != 0)
{
FKey* SelectedKey = (FKey*)StructPtrs[0];
for(int32 StructPtrIndex = 1; StructPtrIndex < StructPtrs.Num(); ++StructPtrIndex)
{
if (SelectedKey && *(FKey*)StructPtrs[StructPtrIndex] != *SelectedKey)
{
return TOptional<FKey>();
}
}
return *SelectedKey;
}
return FKey();
}
void FKeyStructCustomization::OnKeyChanged(TSharedPtr<FKey> SelectedKey)
{
PropertyHandle->SetValueFromFormattedString(SelectedKey->ToString());
}
#undef LOCTEXT_NAMESPACE