void SWidget::Construct( const TAttribute<FText> & InToolTipText , const TSharedPtr<IToolTip> & InToolTip , const TAttribute< TOptional<EMouseCursor::Type> > & InCursor , const TAttribute<bool> & InEnabledState , const TAttribute<EVisibility> & InVisibility, const TAttribute<TOptional<FSlateRenderTransform>>& InTransform, const TAttribute<FVector2D>& InTransformPivot, const FName& InTag, const bool InForceVolatile, const TArray<TSharedRef<ISlateMetaData>>& InMetaData ) { if ( InToolTip.IsValid() ) { // If someone specified a fancy widget tooltip, use it. ToolTip = InToolTip; } else if ( InToolTipText.IsSet() ) { // If someone specified a text binding, make a tooltip out of it ToolTip = FSlateApplicationBase::Get().MakeToolTip(InToolTipText); } else if( !ToolTip.IsValid() || (ToolTip.IsValid() && ToolTip->IsEmpty()) ) { // We don't have a tooltip. ToolTip.Reset(); } Cursor = InCursor; EnabledState = InEnabledState; Visibility = InVisibility; RenderTransform = InTransform; RenderTransformPivot = InTransformPivot; Tag = InTag; bForceVolatile = InForceVolatile; MetaData = InMetaData; }
void FFoliageTypePaintingCustomization::ShowFoliagePropertiesForCategory(IDetailLayoutBuilder& DetailLayoutBuilder, const FName CategoryName, TMap<const FName, IDetailPropertyRow*>& OutDetailRowsByPropertyName) { // Properties that have a ReapplyCondition should be disabled behind the specified property when in reapply mode static const FName ReapplyConditionKey("ReapplyCondition"); // Properties with a HideBehind property specified should only be shown if that property is true, non-zero, or not empty static const FName HideBehindKey("HideBehind"); IDetailCategoryBuilder& CategoryBuilder = DetailLayoutBuilder.EditCategory(CategoryName); TArray<TSharedRef<IPropertyHandle>> CategoryProperties; CategoryBuilder.GetDefaultProperties(CategoryProperties, true, true); // Determine whether each property should be shown and how for (auto& PropertyHandle : CategoryProperties) { bool bShowingProperty = false; if (UProperty* Property = PropertyHandle->GetProperty()) { // Check to see if this property can be reapplied TSharedPtr<IPropertyHandle> ReapplyConditionPropertyHandle = DetailLayoutBuilder.GetProperty(*Property->GetMetaData(ReapplyConditionKey)); if (ReapplyConditionPropertyHandle.IsValid() && ReapplyConditionPropertyHandle->IsValidHandle()) { // Create a custom entry that allows explicit enabling/disabling of the property when reapplying TSharedPtr<IPropertyHandle> PropertyHandlePtr = PropertyHandle; OutDetailRowsByPropertyName.FindOrAdd(PropertyHandle->GetProperty()->GetFName()) = &AddFoliageProperty(CategoryBuilder, PropertyHandlePtr, ReapplyConditionPropertyHandle, TAttribute<EVisibility>(), TAttribute<bool>()); } else { TSharedPtr<IPropertyHandle> InvalidProperty; TSharedPtr<IPropertyHandle> PropertyHandlePtr = PropertyHandle; // Check to see if this property is hidden behind another TSharedPtr<IPropertyHandle> HiddenBehindPropertyHandle = DetailLayoutBuilder.GetProperty(*Property->GetMetaData(HideBehindKey)); if (HiddenBehindPropertyHandle.IsValid() && HiddenBehindPropertyHandle->IsValidHandle()) { TAttribute<bool> IsEnabledAttribute; ReapplyConditionPropertyHandle = DetailLayoutBuilder.GetProperty(*HiddenBehindPropertyHandle->GetProperty()->GetMetaData(ReapplyConditionKey)); if (ReapplyConditionPropertyHandle.IsValid() && ReapplyConditionPropertyHandle->IsValidHandle()) { // If the property this is hidden behind has a reapply condition, disable this when the condition is false IsEnabledAttribute = TAttribute<bool>::Create(TAttribute<bool>::FGetter::CreateSP(this, &FFoliageTypePaintingCustomization::IsReapplyPropertyEnabled, ReapplyConditionPropertyHandle)); } TAttribute<EVisibility> VisibilityAttribute; GetHiddenPropertyVisibility(HiddenBehindPropertyHandle, !IsEnabledAttribute.IsSet(), VisibilityAttribute); OutDetailRowsByPropertyName.FindOrAdd(PropertyHandle->GetProperty()->GetFName()) = &AddFoliageProperty(CategoryBuilder, PropertyHandlePtr, InvalidProperty, VisibilityAttribute, IsEnabledAttribute); } else { // This property cannot be reapplied and isn't hidden behind anything, so show it whenever the reapply tool isn't active OutDetailRowsByPropertyName.FindOrAdd(PropertyHandle->GetProperty()->GetFName()) = &AddFoliageProperty(CategoryBuilder, PropertyHandlePtr, InvalidProperty, TAttribute<EVisibility>::Create(TAttribute<EVisibility>::FGetter::CreateSP(this, &FFoliageTypePaintingCustomization::GetNonReapplyPropertyVisibility)), TAttribute<bool>()); } } } } }