// 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 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 NewRow = MakeShareable( new FDetailWidgetRow ); FDetailLayoutCustomization NewCustomization; NewRow->FilterString( SearchString ); NewCustomization.WidgetDecl = NewRow; ChildCustomizations.Add( NewCustomization ); return *NewRow; } IDetailPropertyRow& FCustomChildrenBuilder::AddChildProperty( TSharedRef PropertyHandle ) { check( PropertyHandle->IsValidHandle() ) FDetailLayoutCustomization NewCustomization; NewCustomization.PropertyRow = MakeShareable( new FDetailPropertyRow( StaticCastSharedRef( 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 InCustomizationInterface, TSharedRef InStructPropertyHandle, TSharedRef InParentCategory ) { CustomizationInterface = InCustomizationInterface; StructPropertyHandle = InStructPropertyHandle; ParentCategory = InParentCategory; CustomPropertyWidget = MakeShareable(new FDetailWidgetRow); CustomizationInterface->CustomizeHeader(InStructPropertyHandle, *CustomPropertyWidget, *this); ChildSlot [ CustomPropertyWidget->ValueWidget.Widget ]; } virtual TSharedPtr GetThumbnailPool() const override { TSharedPtr ParentCategoryPinned = ParentCategory.Pin(); return ParentCategoryPinned.IsValid() ? ParentCategoryPinned->GetParentLayout().GetThumbnailPool() : NULL; } private: TWeakPtr ParentCategory; TSharedPtr CustomizationInterface; TSharedPtr StructPropertyHandle; TSharedPtr CustomPropertyWidget; }; TSharedRef FCustomChildrenBuilder::GenerateStructValueWidget( TSharedRef StructPropertyHandle ) { UStructProperty* StructProperty = CastChecked( StructPropertyHandle->GetProperty() ); FPropertyEditorModule& PropertyEditorModule = FModuleManager::GetModuleChecked("PropertyEditor"); IDetailsViewPrivate& DetailsView = ParentCategory.Pin()->GetDetailsView(); TSharedRef DetailsViewPtr = StaticCastSharedRef( DetailsView.AsShared() ); FPropertyTypeLayoutCallback LayoutCallback = PropertyEditorModule.GetPropertyTypeCustomization(StructProperty, *StructPropertyHandle, DetailsViewPtr ); if (LayoutCallback.IsValid()) { TSharedRef CustomStructInterface = LayoutCallback.GetCustomizationInstance(); return SNew( SStandaloneCustomStructValue, CustomStructInterface, StructPropertyHandle, ParentCategory.Pin().ToSharedRef() ); } else { // Uncustomized structs have nothing for their value content return SNullWidget::NullWidget; } }