Files
UnrealEngineUWP/Engine/Source/Editor/PropertyEditor/Private/CustomChildBuilder.cpp
Ben Marsh 149375b14b Update copyright notices to 2015.
[CL 2379638 by Ben Marsh in Main branch]
2014-12-07 19:09:38 -05:00

113 lines
4.0 KiB
C++

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "PropertyEditorPrivatePCH.h"
#include "CustomChildBuilder.h"
#include "DetailGroup.h"
#include "PropertyHandleImpl.h"
#include "DetailPropertyRow.h"
IDetailChildrenBuilder& FCustomChildrenBuilder::AddChildCustomBuilder( TSharedRef<class IDetailCustomNodeBuilder> InCustomBuilder )
{
FDetailLayoutCustomization NewCustomization;
NewCustomization.CustomBuilderRow = MakeShareable( new FDetailCustomBuilderRow( InCustomBuilder ) );
ChildCustomizations.Add( NewCustomization );
return *this;
}
IDetailGroup& FCustomChildrenBuilder::AddChildGroup( FName GroupName, const FText& LocalizedDisplayName )
{
FDetailLayoutCustomization NewCustomization;
NewCustomization.DetailGroup = MakeShareable( new FDetailGroup( GroupName, ParentCategory.Pin().ToSharedRef(), LocalizedDisplayName ) );
ChildCustomizations.Add( NewCustomization );
return *NewCustomization.DetailGroup;
}
FDetailWidgetRow& FCustomChildrenBuilder::AddChildContent( const FText& SearchString )
{
TSharedRef<FDetailWidgetRow> NewRow = MakeShareable( new FDetailWidgetRow );
FDetailLayoutCustomization NewCustomization;
NewRow->FilterString( SearchString );
NewCustomization.WidgetDecl = NewRow;
ChildCustomizations.Add( NewCustomization );
return *NewRow;
}
IDetailPropertyRow& FCustomChildrenBuilder::AddChildProperty( TSharedRef<IPropertyHandle> PropertyHandle )
{
check( PropertyHandle->IsValidHandle() )
FDetailLayoutCustomization NewCustomization;
NewCustomization.PropertyRow = MakeShareable( new FDetailPropertyRow( StaticCastSharedRef<FPropertyHandleBase>( PropertyHandle )->GetPropertyNode(), ParentCategory.Pin().ToSharedRef() ) );
ChildCustomizations.Add( NewCustomization );
return *NewCustomization.PropertyRow;
}
class SStandaloneCustomStructValue : public SCompoundWidget, public IPropertyTypeCustomizationUtils
{
public:
SLATE_BEGIN_ARGS( SStandaloneCustomStructValue )
{}
SLATE_END_ARGS()
void Construct( const FArguments& InArgs, TSharedPtr<IPropertyTypeCustomization> InCustomizationInterface, TSharedRef<IPropertyHandle> InStructPropertyHandle, TSharedRef<FDetailCategoryImpl> InParentCategory )
{
CustomizationInterface = InCustomizationInterface;
StructPropertyHandle = InStructPropertyHandle;
ParentCategory = InParentCategory;
CustomPropertyWidget = MakeShareable(new FDetailWidgetRow);
CustomizationInterface->CustomizeHeader(InStructPropertyHandle, *CustomPropertyWidget, *this);
ChildSlot
[
CustomPropertyWidget->ValueWidget.Widget
];
}
virtual TSharedPtr<FAssetThumbnailPool> GetThumbnailPool() const override
{
TSharedPtr<FDetailCategoryImpl> ParentCategoryPinned = ParentCategory.Pin();
return ParentCategoryPinned.IsValid() ? ParentCategoryPinned->GetParentLayout().GetThumbnailPool() : NULL;
}
private:
TWeakPtr<FDetailCategoryImpl> ParentCategory;
TSharedPtr<IPropertyTypeCustomization> CustomizationInterface;
TSharedPtr<IPropertyHandle> StructPropertyHandle;
TSharedPtr<FDetailWidgetRow> CustomPropertyWidget;
};
TSharedRef<SWidget> FCustomChildrenBuilder::GenerateStructValueWidget( TSharedRef<IPropertyHandle> StructPropertyHandle )
{
UStructProperty* StructProperty = CastChecked<UStructProperty>( StructPropertyHandle->GetProperty() );
FPropertyEditorModule& PropertyEditorModule = FModuleManager::GetModuleChecked<FPropertyEditorModule>("PropertyEditor");
IDetailsViewPrivate& DetailsView = ParentCategory.Pin()->GetDetailsView();
TSharedRef<IDetailsView> DetailsViewPtr = StaticCastSharedRef<IDetailsView>( DetailsView.AsShared() );
FPropertyTypeLayoutCallback LayoutCallback = PropertyEditorModule.GetPropertyTypeCustomization(StructProperty, *StructPropertyHandle, DetailsViewPtr );
if (LayoutCallback.IsValid())
{
TSharedRef<IPropertyTypeCustomization> CustomStructInterface = LayoutCallback.GetCustomizationInstance();
return SNew( SStandaloneCustomStructValue, CustomStructInterface, StructPropertyHandle, ParentCategory.Pin().ToSharedRef() );
}
else
{
// Uncustomized structs have nothing for their value content
return SNullWidget::NullWidget;
}
}