Files
UnrealEngineUWP/Engine/Source/Editor/DetailCustomizations/Public/KeyStructCustomization.h
Marc Audy a7c9001a94 Merging //UE5/Release-Engine-Staging to Main (//UE5/Main) @ 14075166
#rb
#rnx

[CL 14075271 by Marc Audy in ue5-main branch]
2020-08-11 01:36:57 -04:00

48 lines
1.7 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "InputCoreTypes.h"
#include "IPropertyTypeCustomization.h"
#include "PropertyHandle.h"
/**
* Implements a details panel customization for FKey structures.
* As "Key" <SKeySelector>
*/
class DETAILCUSTOMIZATIONS_API FKeyStructCustomization
: public IPropertyTypeCustomization
{
public:
// IPropertyTypeCustomization interface
virtual void CustomizeHeader(TSharedRef<class IPropertyHandle> StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override;
virtual void CustomizeChildren(TSharedRef<IPropertyHandle> StructPropertyHandle, class IDetailChildrenBuilder& ChildBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override { };
virtual bool ShouldInlineKey() const override { return true; }
// Helper variant that generates the key struct in the header and appends a single button at the end
// TODO: Is there a better way?
void CustomizeHeaderOnlyWithButton(TSharedRef<class IPropertyHandle> StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils, TSharedRef<SWidget> Button);
public:
/**
* Creates a new instance.
*
* @return A new struct customization for Keys.
*/
static TSharedRef<IPropertyTypeCustomization> MakeInstance( );
protected:
/** Gets the current Key being edited. */
TOptional<FKey> GetCurrentKey() const;
/** Updates the property when a new key is selected. */
void OnKeyChanged(TSharedPtr<FKey> SelectedKey);
/** Holds a handle to the property being edited. */
TSharedPtr<IPropertyHandle> PropertyHandle;
};