2014-12-07 19:09:38 -05:00
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
2014-03-14 14:13:41 -04:00
2014-04-23 20:18:55 -04:00
# include "EnvironmentQueryEditorPrivatePCH.h"
2014-03-14 14:13:41 -04:00
# include "EnvDirectionCustomization.h"
2014-05-29 17:06:50 -04:00
# include "EnvironmentQuery/EnvQueryTypes.h"
2014-03-14 14:13:41 -04:00
# define LOCTEXT_NAMESPACE "FEnvQueryCustomization"
2014-06-04 10:16:14 -04:00
TSharedRef < IPropertyTypeCustomization > FEnvDirectionCustomization : : MakeInstance ( )
2014-03-14 14:13:41 -04:00
{
return MakeShareable ( new FEnvDirectionCustomization ) ;
}
2014-06-04 11:16:24 -04:00
void FEnvDirectionCustomization : : CustomizeHeader ( TSharedRef < class IPropertyHandle > StructPropertyHandle , class FDetailWidgetRow & HeaderRow , IPropertyTypeCustomizationUtils & StructCustomizationUtils )
2014-03-14 14:13:41 -04:00
{
// create struct header
HeaderRow . NameContent ( )
[
StructPropertyHandle - > CreatePropertyNameWidget ( )
]
. ValueContent ( )
. VAlign ( VAlign_Center )
[
SNew ( STextBlock )
. Text ( this , & FEnvDirectionCustomization : : GetShortDescription )
. Font ( IDetailLayoutBuilder : : GetDetailFont ( ) )
] ;
ModeProp = StructPropertyHandle - > GetChildHandle ( GET_MEMBER_NAME_CHECKED ( FEnvDirection , DirMode ) ) ;
if ( ModeProp . IsValid ( ) )
{
FSimpleDelegate OnModeChangedDelegate = FSimpleDelegate : : CreateSP ( this , & FEnvDirectionCustomization : : OnModeChanged ) ;
ModeProp - > SetOnPropertyValueChanged ( OnModeChangedDelegate ) ;
}
OnModeChanged ( ) ;
}
2014-06-04 11:16:24 -04:00
void FEnvDirectionCustomization : : CustomizeChildren ( TSharedRef < class IPropertyHandle > StructPropertyHandle , class IDetailChildrenBuilder & StructBuilder , IPropertyTypeCustomizationUtils & StructCustomizationUtils )
2014-03-14 14:13:41 -04:00
{
StructBuilder . AddChildProperty ( ModeProp . ToSharedRef ( ) ) ;
TSharedPtr < IPropertyHandle > PropFrom = StructPropertyHandle - > GetChildHandle ( GET_MEMBER_NAME_CHECKED ( FEnvDirection , LineFrom ) ) ;
StructBuilder . AddChildProperty ( PropFrom . ToSharedRef ( ) )
. Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FEnvDirectionCustomization : : GetTwoPointsVisibility ) ) ) ;
TSharedPtr < IPropertyHandle > PropTo = StructPropertyHandle - > GetChildHandle ( GET_MEMBER_NAME_CHECKED ( FEnvDirection , LineTo ) ) ;
StructBuilder . AddChildProperty ( PropTo . ToSharedRef ( ) )
. Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FEnvDirectionCustomization : : GetTwoPointsVisibility ) ) ) ;
TSharedPtr < IPropertyHandle > PropRot = StructPropertyHandle - > GetChildHandle ( GET_MEMBER_NAME_CHECKED ( FEnvDirection , Rotation ) ) ;
StructBuilder . AddChildProperty ( PropRot . ToSharedRef ( ) )
. Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FEnvDirectionCustomization : : GetRotationVisibility ) ) ) ;
}
2015-01-07 09:52:40 -05:00
FText FEnvDirectionCustomization : : GetShortDescription ( ) const
2014-03-14 14:13:41 -04:00
{
2015-01-07 09:52:40 -05:00
return bIsRotation ? LOCTEXT ( " DirectionShortDescRotatation " , " context's rotation... " ) : LOCTEXT ( " DirectionShortDescBetweenTwoPoints " , " between two contexts... " ) ;
2014-03-14 14:13:41 -04:00
}
EVisibility FEnvDirectionCustomization : : GetTwoPointsVisibility ( ) const
{
return bIsRotation ? EVisibility : : Collapsed : EVisibility : : Visible ;
}
EVisibility FEnvDirectionCustomization : : GetRotationVisibility ( ) const
{
return bIsRotation ? EVisibility : : Visible : EVisibility : : Collapsed ;
}
void FEnvDirectionCustomization : : OnModeChanged ( )
{
uint8 EnumValue = 0 ;
ModeProp - > GetValue ( EnumValue ) ;
bIsRotation = ( EnumValue = = EEnvDirection : : Rotation ) ;
}
# undef LOCTEXT_NAMESPACE