本文整理汇总了C++中TAttribute类的典型用法代码示例。如果您正苦于以下问题:C++ TAttribute类的具体用法?C++ TAttribute怎么用?C++ TAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDescription
TSharedRef<SToolTip> FUICommandInfo::MakeTooltip( const TAttribute<FText>& InText, const TAttribute< EVisibility >& InToolTipVisibility ) const
{
return
SNew(SToolTip)
.Visibility(InToolTipVisibility.IsBound() ? InToolTipVisibility : EVisibility::Visible)
.Content()
[
SNew(SVerticalBox)
+SVerticalBox::Slot()
.Padding(0.0f, 0.0f, 0.0f, 4.0f)
[
SNew(STextBlock)
.Text(InText.IsBound() ? InText : GetDescription())
.Font(FCoreStyle::Get().GetFontStyle( "ToolTip.Font" ))
.ColorAndOpacity( FSlateColor::UseForeground() )
]
+SVerticalBox::Slot()
[
SNew(STextBlock)
.Text(GetInputText())
.Font(FCoreStyle::Get().GetFontStyle( "ToolTip.Font" ))
.ColorAndOpacity( FSlateColor::UseSubduedForeground() )
]
];
}
示例2: GenerateChildrenForPropertyNode
void FDetailPropertyRow::GenerateChildrenForPropertyNode( TSharedPtr<FPropertyNode>& RootPropertyNode, FDetailNodeList& OutChildren )
{
// Children should be disabled if we are disabled
TAttribute<bool> ParentEnabledState = CustomIsEnabledAttrib;
if( IsParentEnabled.IsBound() || HasEditCondition() )
{
// Bind a delegate to the edit condition so our children will be disabled if the edit condition fails
ParentEnabledState.Bind( this, &FDetailPropertyRow::GetEnabledState );
}
if( PropertyTypeLayoutBuilder.IsValid() && bShowCustomPropertyChildren )
{
const TArray< FDetailLayoutCustomization >& ChildRows = PropertyTypeLayoutBuilder->GetChildCustomizations();
for( int32 ChildIndex = 0; ChildIndex < ChildRows.Num(); ++ChildIndex )
{
TSharedRef<FDetailItemNode> ChildNodeItem = MakeShareable( new FDetailItemNode( ChildRows[ChildIndex], ParentCategory.Pin().ToSharedRef(), ParentEnabledState ) );
ChildNodeItem->Initialize();
OutChildren.Add( ChildNodeItem );
}
}
else if (bShowCustomPropertyChildren || !CustomPropertyWidget.IsValid() )
{
TSharedRef<FDetailCategoryImpl> ParentCategoryRef = ParentCategory.Pin().ToSharedRef();
IDetailLayoutBuilder& LayoutBuilder = ParentCategoryRef->GetParentLayout();
UProperty* ParentProperty = RootPropertyNode->GetProperty();
const bool bStructProperty = ParentProperty && ParentProperty->IsA<UStructProperty>();
for( int32 ChildIndex = 0; ChildIndex < RootPropertyNode->GetNumChildNodes(); ++ChildIndex )
{
TSharedPtr<FPropertyNode> ChildNode = RootPropertyNode->GetChildNode(ChildIndex);
if( ChildNode.IsValid() && ChildNode->HasNodeFlags( EPropertyNodeFlags::IsCustomized ) == 0 )
{
if( ChildNode->AsObjectNode() )
{
// Skip over object nodes and generate their children. Object nodes are not visible
GenerateChildrenForPropertyNode( ChildNode, OutChildren );
}
// Only struct children can have custom visibility that is different from their parent.
else if ( !bStructProperty || LayoutBuilder.IsPropertyVisible( FPropertyAndParent(*ChildNode->GetProperty(), ParentProperty ) ) )
{
FDetailLayoutCustomization Customization;
Customization.PropertyRow = MakeShareable( new FDetailPropertyRow( ChildNode, ParentCategoryRef ) );
TSharedRef<FDetailItemNode> ChildNodeItem = MakeShareable( new FDetailItemNode( Customization, ParentCategoryRef, ParentEnabledState ) );
ChildNodeItem->Initialize();
OutChildren.Add( ChildNodeItem );
}
}
}
}
}
示例3: GenerateSectionLayout
void FFloatPropertySection::GenerateSectionLayout(class ISectionLayoutBuilder& LayoutBuilder) const
{
UMovieSceneFloatSection* FloatSection = Cast<UMovieSceneFloatSection>(&SectionObject);
TAttribute<TOptional<float>> ExternalValue;
if (CanGetPropertyValue())
{
ExternalValue.Bind(TAttribute<TOptional<float>>::FGetter::CreateLambda([&]
{
return GetPropertyValue<float>();
}));
}
TSharedRef<FFloatCurveKeyArea> KeyArea = MakeShareable(
new FFloatCurveKeyArea(&FloatSection->GetFloatCurve(), ExternalValue, FloatSection));
LayoutBuilder.SetSectionAsKeyArea(KeyArea);
}
示例4: AppendKeyBindingToToolTip
/** Appends the key binding to the end of the provided ToolTip */
static FText AppendKeyBindingToToolTip( const TAttribute<FText> ToolTip, TWeakPtr< const FUICommandInfo> Command )
{
TSharedPtr<const FUICommandInfo> CommandPtr = Command.Pin();
if( CommandPtr.IsValid() && CommandPtr->GetActiveChord()->IsValidChord() )
{
FFormatNamedArguments Args;
Args.Add( TEXT("ToolTipDescription"), ToolTip.Get() );
Args.Add( TEXT("Keybinding"), CommandPtr->GetInputText() );
return FText::Format( NSLOCTEXT("ToolBar", "ToolTip + Keybinding", "{ToolTipDescription} ({Keybinding})"), Args );
}
else
{
return ToolTip.Get();
}
}
示例5: SetHyperlink
/** Sets the text and delegate for the hyperlink */
virtual void SetHyperlink( const FSimpleDelegate& InHyperlink, const TAttribute< FText >& InHyperlinkText = TAttribute< FText >() ) override
{
Hyperlink = InHyperlink;
// Only replace the text if specified
if ( InHyperlinkText.IsBound() )
{
HyperlinkText = InHyperlinkText;
}
}
示例6: SNew
TSharedRef< class SToolTip > FDocumentation::CreateToolTip(const TAttribute<FText>& Text, const TSharedPtr<SWidget>& OverrideContent, const FString& Link, const FString& ExcerptName) const
{
TSharedPtr< SDocumentationToolTip > DocToolTip;
if ( !Text.IsBound() && Text.Get().IsEmpty() )
{
return SNew( SToolTip );
}
if ( OverrideContent.IsValid() )
{
SAssignNew( DocToolTip, SDocumentationToolTip )
.DocumentationLink( Link )
.ExcerptName( ExcerptName )
[
OverrideContent.ToSharedRef()
];
}
else
{
SAssignNew( DocToolTip, SDocumentationToolTip )
.Text( Text )
.DocumentationLink( Link )
.ExcerptName( ExcerptName );
}
return SNew( SToolTip )
.IsInteractive( DocToolTip.ToSharedRef(), &SDocumentationToolTip::IsInteractive )
// Emulate text-only tool-tip styling that SToolTip uses when no custom content is supplied. We want documentation tool-tips to
// be styled just like text-only tool-tips
.BorderImage( FCoreStyle::Get().GetBrush("ToolTip.BrightBackground") )
.TextMargin(FMargin(11.0f))
[
DocToolTip.ToSharedRef()
];
}
示例7: BeginSection
void FMenuBuilder::BeginSection( FName InExtensionHook, const TAttribute< FText >& InHeadingText )
{
check(CurrentSectionExtensionHook == NAME_None && !bSectionNeedsToBeApplied);
ApplyHook(InExtensionHook, EExtensionHook::Before);
// Do not actually apply the section header, because if this section is ended immediately
// then nothing ever gets created, preventing empty sections from ever appearing
bSectionNeedsToBeApplied = true;
CurrentSectionExtensionHook = InExtensionHook;
CurrentSectionHeadingText = InHeadingText.Get();
// Do apply the section beginning if we are in developer "show me all the hooks" mode
if (FMultiBoxSettings::DisplayMultiboxHooks.Get())
{
ApplySectionBeginning();
}
ApplyHook(InExtensionHook, EExtensionHook::First);
}
示例8: Construct
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;
}
示例9: GetHiddenPropertyVisibility
void FFoliageTypePaintingCustomization::GetHiddenPropertyVisibility(const TSharedPtr<IPropertyHandle>& PropertyHandle, bool bHideInReapplyTool, TAttribute<EVisibility>& OutVisibility) const
{
TAttribute<EVisibility>::FGetter VisibilityGetter;
FFoliageTypeCustomizationHelpers::BindHiddenPropertyVisibilityGetter(PropertyHandle, VisibilityGetter);
if (bHideInReapplyTool)
{
// In addition to hiding it it behind the given property, only show this in the reapply tool
OutVisibility = TAttribute<EVisibility>::Create(TAttribute<EVisibility>::FGetter::CreateLambda([=]
{
if (!FoliageEditMode->UISettings.GetReapplyToolSelected() && VisibilityGetter.IsBound())
{
const EVisibility ReturnVal = VisibilityGetter.Execute();
return ReturnVal;
}
return EVisibility::Collapsed;
}));
}
else
{
OutVisibility.Bind(VisibilityGetter);
}
}
示例10: __releaseAttr
static Sxmlattribute __releaseAttr (TAttribute attr) { Sxmlattribute xml(attr); attr->removeReference(); return xml; }
示例11:
EXP void factoryFreeAttribute (TFactory f, TAttribute attr) { attr->removeReference(); }
示例12: LOCTEXT
void FMainMenu::FillEditMenu( FMenuBuilder& MenuBuilder, const TSharedRef< FExtender > Extender, const TSharedPtr<FTabManager> TabManager )
{
MenuBuilder.BeginSection("EditHistory", LOCTEXT("HistoryHeading", "History"));
{
struct Local
{
/** @return Returns a dynamic text string for Undo that contains the name of the action */
static FText GetUndoLabelText()
{
return FText::Format(LOCTEXT("DynamicUndoLabel", "Undo {0}"), GUnrealEd->Trans->GetUndoContext().Title);
}
/** @return Returns a dynamic text string for Redo that contains the name of the action */
static FText GetRedoLabelText()
{
return FText::Format(LOCTEXT("DynamicRedoLabel", "Redo {0}"), GUnrealEd->Trans->GetRedoContext().Title);
}
};
// Undo
TAttribute<FText> DynamicUndoLabel;
DynamicUndoLabel.BindStatic(&Local::GetUndoLabelText);
MenuBuilder.AddMenuEntry( FGenericCommands::Get().Undo, "Undo", DynamicUndoLabel); // TAttribute< FString >::Create( &Local::GetUndoLabelText ) );
// Redo
TAttribute< FText > DynamicRedoLabel;
DynamicRedoLabel.BindStatic( &Local::GetRedoLabelText );
MenuBuilder.AddMenuEntry(FGenericCommands::Get().Redo, "Redo", DynamicRedoLabel); // TAttribute< FString >::Create( &Local::GetRedoLabelText ) );
// Show undo history
MenuBuilder.AddMenuEntry(
LOCTEXT("UndoHistoryTabTitle", "Undo History"),
LOCTEXT("UndoHistoryTooltipText", "View the entire undo history."),
FSlateIcon(FEditorStyle::GetStyleSetName(), "UndoHistory.TabIcon"),
FUIAction(FExecuteAction::CreateStatic(&FUndoHistoryModule::ExecuteOpenUndoHistory))
);
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection("EditLocalTabSpawners", LOCTEXT("ConfigurationHeading", "Configuration"));
{
if (GetDefault<UEditorExperimentalSettings>()->bToolbarCustomization)
{
FUIAction ToggleMultiBoxEditMode(
FExecuteAction::CreateStatic(&FMultiBoxSettings::ToggleToolbarEditing),
FCanExecuteAction(),
FIsActionChecked::CreateStatic(&FMultiBoxSettings::IsInToolbarEditMode)
);
MenuBuilder.AddMenuEntry(
LOCTEXT("EditToolbarsLabel", "Edit Toolbars"),
LOCTEXT("EditToolbarsToolTip", "Allows customization of each toolbar"),
FSlateIcon(),
ToggleMultiBoxEditMode,
NAME_None,
EUserInterfaceActionType::ToggleButton
);
// Automatically populate tab spawners from TabManager
if (TabManager.IsValid())
{
const IWorkspaceMenuStructure& MenuStructure = WorkspaceMenu::GetMenuStructure();
TabManager->PopulateTabSpawnerMenu(MenuBuilder, MenuStructure.GetEditOptions());
}
}
if (GetDefault<UEditorStyleSettings>()->bExpandConfigurationMenus)
{
MenuBuilder.AddSubMenu(
LOCTEXT("EditorPreferencesSubMenuLabel", "Editor Preferences"),
LOCTEXT("EditorPreferencesSubMenuToolTip", "Configure the behavior and features of this Editor"),
FNewMenuDelegate::CreateStatic(&FSettingsMenu::MakeMenu, FName("Editor")),
false,
FSlateIcon(FEditorStyle::GetStyleSetName(), "EditorPreferences.TabIcon")
);
MenuBuilder.AddSubMenu(
LOCTEXT("ProjectSettingsSubMenuLabel", "Project Settings"),
LOCTEXT("ProjectSettingsSubMenuToolTip", "Change the settings of the currently loaded project"),
FNewMenuDelegate::CreateStatic(&FSettingsMenu::MakeMenu, FName("Project")),
false,
FSlateIcon(FEditorStyle::GetStyleSetName(), "ProjectSettings.TabIcon")
);
}
else
{
#if !PLATFORM_MAC // Handled by app's menu in menu bar
MenuBuilder.AddMenuEntry(
LOCTEXT("EditorPreferencesMenuLabel", "Editor Preferences..."),
LOCTEXT("EditorPreferencesMenuToolTip", "Configure the behavior and features of the Unreal Editor."),
FSlateIcon(FEditorStyle::GetStyleSetName(), "EditorPreferences.TabIcon"),
FUIAction(FExecuteAction::CreateStatic(&FSettingsMenu::OpenSettings, FName("Editor"), FName("General"), FName("Appearance")))
);
#endif
MenuBuilder.AddMenuEntry(
LOCTEXT("ProjectSettingsMenuLabel", "Project Settings..."),
LOCTEXT("ProjectSettingsMenuToolTip", "Change the settings of the currently loaded project."),
FSlateIcon(FEditorStyle::GetStyleSetName(), "ProjectSettings.TabIcon"),
FUIAction(FExecuteAction::CreateStatic(&FSettingsMenu::OpenSettings, FName("Project"), FName("Project"), FName("General")))
//.........这里部分代码省略.........
示例13: PassThroughAttribute
static FText PassThroughAttribute( TAttribute< FString > InString )
{
return FText::FromString( InString.Get( TEXT("") ) );
}
示例14: ReapplyConditionKey
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>());
}
}
}
}
}
示例15: MakeValueWidget
void FDetailPropertyRow::MakeValueWidget( FDetailWidgetRow& Row, const TSharedPtr<FDetailWidgetRow> InCustomRow, bool bAddWidgetDecoration ) const
{
EVerticalAlignment VerticalAlignment = VAlign_Center;
EHorizontalAlignment HorizontalAlignment = HAlign_Left;
TOptional<float> MinWidth;
TOptional<float> MaxWidth;
if( InCustomRow.IsValid() )
{
VerticalAlignment = InCustomRow->ValueWidget.VerticalAlignment;
HorizontalAlignment = InCustomRow->ValueWidget.HorizontalAlignment;
}
TAttribute<bool> IsEnabledAttrib = CustomIsEnabledAttrib;
if( HasEditCondition() )
{
IsEnabledAttrib.Bind( this, &FDetailPropertyRow::GetEnabledState );
}
TSharedRef<SHorizontalBox> ValueWidget =
SNew( SHorizontalBox )
.IsEnabled( IsEnabledAttrib );
if( InCustomRow.IsValid() )
{
MinWidth = InCustomRow->ValueWidget.MinWidth;
MaxWidth = InCustomRow->ValueWidget.MaxWidth;
ValueWidget->AddSlot()
[
InCustomRow->ValueWidget.Widget
];
}
else
{
TSharedPtr<SPropertyValueWidget> PropertyValue;
ValueWidget->AddSlot()
.Padding( 0.0f, 0.0f, 4.0f, 0.0f )
[
SAssignNew( PropertyValue, SPropertyValueWidget, PropertyEditor, GetPropertyUtilities() )
.ShowPropertyButtons( false ) // We handle this ourselves
];
MinWidth = PropertyValue->GetMinDesiredWidth();
MaxWidth = PropertyValue->GetMaxDesiredWidth();
}
if(bAddWidgetDecoration)
{
if( bShowPropertyButtons )
{
TArray< TSharedRef<SWidget> > RequiredButtons;
PropertyEditorHelpers::MakeRequiredPropertyButtons( PropertyEditor.ToSharedRef(), /*OUT*/RequiredButtons );
for( int32 ButtonIndex = 0; ButtonIndex < RequiredButtons.Num(); ++ButtonIndex )
{
ValueWidget->AddSlot()
.AutoWidth()
.HAlign(HAlign_Left)
.VAlign(VAlign_Center)
.Padding(2.0f, 1.0f)
[
RequiredButtons[ButtonIndex]
];
}
}
if (PropertyHandle->HasMetaData(TEXT("ConfigHierarchyEditable")))
{
ValueWidget->AddSlot()
.AutoWidth()
.VAlign(VAlign_Center)
.HAlign(HAlign_Left)
.Padding(0.0f, 0.0f, 4.0f, 0.0f)
[
PropertyCustomizationHelpers::MakeEditConfigHierarchyButton(FSimpleDelegate::CreateSP(PropertyEditor.ToSharedRef(), &FPropertyEditor::EditConfigHierarchy))
];
}
if (!PropertyHandle->HasMetaData(TEXT("NoResetToDefault")))
{
ValueWidget->AddSlot()
.Padding( 2.0f, 0.0f )
.AutoWidth()
.VAlign(VAlign_Center)
.HAlign(HAlign_Left)
[
SNew( SResetToDefaultPropertyEditor, PropertyEditor.ToSharedRef() )
.IsEnabled( IsEnabledAttrib )
.CustomResetToDefault(CustomResetToDefault)
];
}
}
Row.ValueContent()
.HAlign( HorizontalAlignment )
.VAlign( VerticalAlignment )
.MinDesiredWidth( MinWidth )
//.........这里部分代码省略.........