UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
WorkspaceItem.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3
4#pragma once
5
6#include "CoreMinimal.h"
8#include "Misc/Attribute.h"
9
10struct FTabSpawnerEntry;
11
12class FWorkspaceItem : public TSharedFromThis<FWorkspaceItem>
13{
14protected:
16 {
18 {
19 if ( A->GetChildItems().Num() > 0 )
20 {
21 if ( B->GetChildItems().Num() == 0 )
22 {
23 return true;
24 }
25 }
26 else if ( B->GetChildItems().Num() > 0 )
27 {
28 return false;
29 }
30 return ( A->GetDisplayName().CompareTo( B->GetDisplayName() ) == -1 );
31 }
32 };
33
34public:
39
44
49
54
61
68
75
82
83 const FName GetFName() const
84 {
85 return NameAttribute.Get();
86 }
87
88 const FText& GetDisplayName() const
89 {
91 }
92
93 const FText& GetTooltipText() const
94 {
96 }
97
98 const FSlateIcon& GetIcon() const
99 {
100 return Icon;
101 }
102
104 {
105 return ChildItems;
106 }
107
109 {
110 ItemToAdd->ParentItem = SharedThis(this);
112
113 // If desired of this menu, sort the children
114 if ( bSortChildren )
115 {
116 SortChildren();
117 }
118
119 // If this is our first child, our parent item may need sorting, resort it now
120 if ( ChildItems.Num() == 1 && ParentItem.IsValid() && ParentItem.Pin()->bSortChildren )
121 {
122 ParentItem.Pin()->SortChildren();
123 }
124 }
125
130
132 {
134 }
135
137 {
139 }
140
145
146
148 {
149 return ParentItem.Pin();
150 }
151
153 {
154 // Spawner Entries are leaves. If this is a spawner entry and it allowed in this menu, then
155 // any group containing this node is populated.
157 bool bIsGroupPopulated = ThisAsSpawnerEntry.IsValid() && AllowedSpawners.Contains(ThisAsSpawnerEntry.ToSharedRef());
158
159 // Look through all the children of this node and see if any of them are populated
160 for ( int32 ChildIndex=0; !bIsGroupPopulated && ChildIndex < ChildItems.Num(); ++ChildIndex )
161 {
163 if ( ChildItem->HasChildrenIn(AllowedSpawners) )
164 {
165 bIsGroupPopulated = true;
166 }
167 }
168
169 return bIsGroupPopulated;
170 }
171
174 {
175 }
177
178protected:
186
187 FWorkspaceItem( const FName& InName, const FText& InDisplayName, const FSlateIcon& InIcon, const bool bInSortChildren )
188 : Icon(InIcon)
189 , NameAttribute(InName)
192 {
193 }
194
203
212
217 UE_DEPRECATED(5.0, "Use DisplayNameAttribute instead.")
222
224
226
227 // Allows MakeShared with protected constructor.
228 template <typename ObjectType, ESPMode Mode>
230};
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
ESPMode
Definition SharedPointerFwd.h:12
Definition NameTypes.h:617
Definition UnrealType.h:3087
Definition Text.h:385
Definition WorkspaceItem.h:13
const FText & GetDisplayName() const
Definition WorkspaceItem.h:88
const FSlateIcon & GetIcon() const
Definition WorkspaceItem.h:98
static TSharedRef< FWorkspaceItem > NewGroup(const FText &DisplayName, const FSlateIcon &Icon=FSlateIcon(), const bool bSortChildren=false)
Definition WorkspaceItem.h:35
TAttribute< FName > NameAttribute
Definition WorkspaceItem.h:214
TArray< TSharedRef< FWorkspaceItem > > ChildItems
Definition WorkspaceItem.h:223
TSharedRef< FWorkspaceItem > AddGroup(const FName &InName, const FText &InDisplayName, const FText &InTooltipText, const FSlateIcon &InIcon=FSlateIcon(), const bool InSortChildren=false)
Definition WorkspaceItem.h:76
TSharedRef< FWorkspaceItem > AddGroup(const FText &InDisplayName, const FSlateIcon &InIcon=FSlateIcon(), const bool InSortChildren=false)
Definition WorkspaceItem.h:55
void ClearItems()
Definition WorkspaceItem.h:131
static TSharedRef< FWorkspaceItem > NewGroup(const FName &Name, const FText &DisplayName, const FSlateIcon &Icon=FSlateIcon(), const bool bSortChildren=false)
Definition WorkspaceItem.h:40
FWorkspaceItem(const FName &InName, const FText &InDisplayName, const FText &InTooltipText, const FSlateIcon &InIcon, const bool bInSortChildren)
Definition WorkspaceItem.h:204
bool bSortChildren
Definition WorkspaceItem.h:221
const TArray< TSharedRef< FWorkspaceItem > > & GetChildItems() const
Definition WorkspaceItem.h:103
FText DisplayName
Definition WorkspaceItem.h:218
const FText & GetTooltipText() const
Definition WorkspaceItem.h:93
TWeakPtr< FWorkspaceItem > ParentItem
Definition WorkspaceItem.h:225
TAttribute< FText > TooltipTextAttribute
Definition WorkspaceItem.h:216
void RemoveItem(const TSharedRef< FWorkspaceItem > &ItemToRemove)
Definition WorkspaceItem.h:126
TSharedPtr< FWorkspaceItem > GetParent() const
Definition WorkspaceItem.h:147
virtual TSharedPtr< FTabSpawnerEntry > AsSpawnerEntry()
Definition WorkspaceItem.h:141
void SortChildren()
Definition WorkspaceItem.h:136
FWorkspaceItem(const FText &InDisplayName, const FSlateIcon &InIcon, const bool bInSortChildren)
Definition WorkspaceItem.h:179
TAttribute< FText > DisplayNameAttribute
Definition WorkspaceItem.h:215
const FName GetFName() const
Definition WorkspaceItem.h:83
TSharedRef< FWorkspaceItem > AddGroup(const FText &InDisplayName, const FText &InTooltipText, const FSlateIcon &InIcon=FSlateIcon(), const bool InSortChildren=false)
Definition WorkspaceItem.h:69
static TSharedRef< FWorkspaceItem > NewGroup(const FName &Name, const FText &DisplayName, const FText &TooltipText, const FSlateIcon &Icon=FSlateIcon(), const bool bSortChildren=false)
Definition WorkspaceItem.h:50
static TSharedRef< FWorkspaceItem > NewGroup(const FText &DisplayName, const FText &TooltipText, const FSlateIcon &Icon=FSlateIcon(), const bool bSortChildren=false)
Definition WorkspaceItem.h:45
friend class SharedPointerInternals::TIntrusiveReferenceController
Definition WorkspaceItem.h:229
void AddItem(const TSharedRef< FWorkspaceItem > &ItemToAdd)
Definition WorkspaceItem.h:108
TSharedRef< FWorkspaceItem > AddGroup(const FName &InName, const FText &InDisplayName, const FSlateIcon &InIcon=FSlateIcon(), const bool InSortChildren=false)
Definition WorkspaceItem.h:62
FWorkspaceItem(const FText &InDisplayName, const FText &InTooltipText, const FSlateIcon &InIcon, const bool bInSortChildren)
Definition WorkspaceItem.h:195
FWorkspaceItem(const FName &InName, const FText &InDisplayName, const FSlateIcon &InIcon, const bool bInSortChildren)
Definition WorkspaceItem.h:187
FSlateIcon Icon
Definition WorkspaceItem.h:213
bool HasChildrenIn(const TArray< TWeakPtr< FTabSpawnerEntry > > &AllowedSpawners)
Definition WorkspaceItem.h:152
FText TooltipText
Definition WorkspaceItem.h:220
virtual PRAGMA_DISABLE_DEPRECATION_WARNINGS ~FWorkspaceItem()
Definition WorkspaceItem.h:173
Definition Array.h:670
SizeType Remove(const ElementType &Item)
Definition Array.h:3091
UE_REWRITE SizeType Num() const
Definition Array.h:1144
void Reset(SizeType NewSize=0)
Definition Array.h:2246
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
UE_NODEBUG void Sort()
Definition Array.h:3418
Definition Attribute.h:17
const ObjectType & Get() const
Definition Attribute.h:241
Definition SharedPointer.h:1640
static UE_FORCEINLINE_HINT TSharedRef< OtherType, Mode > SharedThis(OtherType *ThisPtr)
Definition SharedPointer.h:1780
Definition SharedPointer.h:692
UE_FORCEINLINE_HINT const bool IsValid() const
Definition SharedPointer.h:1085
Definition SharedPointer.h:153
Definition SharedPointer.h:1295
UE_FORCEINLINE_HINT TSharedPtr< ObjectType, Mode > Pin() const &
Definition SharedPointer.h:1512
UE_FORCEINLINE_HINT bool IsValid() const
Definition SharedPointer.h:1535
Definition SharedPointerInternals.h:32
Definition SlateIcon.h:13
Definition TabManager.h:235
Definition WorkspaceItem.h:16
bool operator()(const TSharedRef< FWorkspaceItem > A, const TSharedRef< FWorkspaceItem > B) const
Definition WorkspaceItem.h:17