UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SlateBrush.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
8#include "Layout/Margin.h"
10#include "Types/SlateBox2.h"
11#include "Types/SlateVector2.h"
12#include "SlateBrush.generated.h"
13
17UENUM(BlueprintType)
19{
20 enum Type : int
21 {
23 NoDrawType UMETA(DisplayName="None"),
24
27
30
33
36 };
37}
38
39
43UENUM(BlueprintType)
45{
46 enum Type : int
47 {
50
53
56
58 Both
59 };
60}
61
62
66UENUM()
68{
69 enum Type : int
70 {
73
76
79
81 Both
82 };
83}
84
85
89UENUM()
91{
92 enum Type : int
93 {
96
99
102
105 };
106}
107
108
112UENUM()
114{
115 enum Type : int
116 {
119
122 };
123}
124
125
129USTRUCT(BlueprintType)
131{
133
135 : CornerRadii(FVector4(0.0, 0.0, 0.0, 0.0))
137 , Width(0.0)
138 , RoundingType(ESlateBrushRoundingType::HalfHeightRadius)
139 , bUseBrushTransparency(false)
140 {}
141
145 , Width(0.0)
146 , RoundingType(ESlateBrushRoundingType::FixedRadius)
147 , bUseBrushTransparency(false)
148 {}
149
151 : CornerRadii(InRadius)
153 , Width(0.0)
154 , RoundingType(ESlateBrushRoundingType::FixedRadius)
155 , bUseBrushTransparency(false)
156 {}
157
159 : CornerRadii(FVector4(0.0, 0.0, 0.0, 0.0))
160 , Color(InColor)
161 , Width(InWidth)
162 , RoundingType(ESlateBrushRoundingType::HalfHeightRadius)
163 , bUseBrushTransparency(false)
164 {}
165
168 , Color(InColor)
169 , Width(InWidth)
170 , RoundingType(ESlateBrushRoundingType::FixedRadius)
171 , bUseBrushTransparency(false)
172 {}
173
175 : CornerRadii(InRadius)
176 , Color(InColor)
177 , Width(InWidth)
178 , RoundingType(ESlateBrushRoundingType::FixedRadius)
179 , bUseBrushTransparency(false)
180 {}
181
190 {
191 return CornerRadii == Other.CornerRadii
192 && Color == Other.Color
193 && Width == Other.Width
194 && RoundingType == Other.RoundingType
195 && bUseBrushTransparency == Other.bUseBrushTransparency;
196 }
197
199 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Brush)
200 FVector4 CornerRadii;
201
203 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Brush, meta=(DisplayName="Outline", sRGB="true"))
205
207 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Brush)
208 float Width;
209
211 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Brush)
213
215 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Brush)
216 bool bUseBrushTransparency;
217
218};
219
221{
222 inline constexpr float DefaultImageSize = 32.0f;
223}
224
225// Hacky base class to avoid 8 bytes of padding after the vtable
227{
228 virtual ~FSlateBrushFixLayout() = default;
229};
230
234USTRUCT(BlueprintType) //, meta = (HasNativeMake = ""))
236#if CPP
238#endif
239{
241
243
244public:
246 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Brush, meta=( DisplayName="Tint", sRGB="true" ))
247 FSlateColor TintColor;
248
250 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Brush)
252
254 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Brush)
256
259 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Brush)
261
263 UPROPERTY(EditAnywhere, AdvancedDisplay, Category = Brush)
265
267 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Brush)
269
271 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Brush, meta=( UVSpace="true" ))
272 FMargin Margin;
273
274#if WITH_EDITORONLY_DATA
276 UPROPERTY(NotReplicated)
278#endif
279
280public:
281
286
287 virtual ~FSlateBrush(){}
288
289public:
290
293
294 const FMargin& GetMargin() const { return Margin; }
295
296 ESlateBrushTileType::Type GetTiling() const { return Tiling; }
297
298 ESlateBrushMirrorType::Type GetMirroring() const { return Mirroring; }
299
300 ESlateBrushImageType::Type GetImageType() const { return ImageType; }
301
302 ESlateBrushDrawType::Type GetDrawType() const { return DrawAs; }
303
309 const FName GetResourceName() const
310 {
311 return ( ( ResourceName != NAME_None ) || ( ResourceObject == nullptr ) )
312 ? ResourceName
313 : ResourceObject->GetFName();
314 }
315
324 {
325 return ResourceObject;
326 }
327
331 SLATECORE_API void SetResourceObject(class UObject* InResourceObject);
332
339 FLinearColor GetTint( const FWidgetStyle& InWidgetStyle ) const
340 {
341 return TintColor.GetColor(InWidgetStyle);
342 }
343
349 {
350 TintColor.Unlink();
351 }
352
358 bool HasUObject( ) const
359 {
360 return (ResourceObject != nullptr) || (bHasUObject_DEPRECATED);
361 }
362
369 {
370 return bIsDynamicallyLoaded;
371 }
372
379 {
380 return UVRegion;
381 }
382
389 {
390 UVRegion = FBox2f(InUVRegion);
391 }
392
394 {
395 UVRegion = InUVRegion;
396 }
397
405 bool operator==( const FSlateBrush& Other ) const
406 {
407 return ImageSize == Other.ImageSize
408 && DrawAs == Other.DrawAs
409 && Margin == Other.Margin
410 && TintColor == Other.TintColor
411 && Tiling == Other.Tiling
412 && Mirroring == Other.Mirroring
413 && ResourceObject == Other.ResourceObject
414 && ResourceName == Other.ResourceName
415 && bIsDynamicallyLoaded == Other.bIsDynamicallyLoaded
416 && UVRegion == Other.UVRegion
417 && (DrawAs != ESlateBrushDrawType::RoundedBox || OutlineSettings == Other.OutlineSettings); // Compare outline settings for equality only if we have a rounded box brush.
418 }
419
427 bool operator!=( const FSlateBrush& Other ) const
428 {
429 return !(*this == Other);
430 }
431
433 void AddReferencedObjects(FReferenceCollector& Collector, UObject* ReferencingObject = nullptr)
434 {
435 Collector.AddReferencedObject(ResourceObject, ReferencingObject);
436 }
437
443 static SLATECORE_API const FString UTextureIdentifier( );
444
446 {
447 UpdateRenderingResource(LocalSize, DrawScale);
448
449 return ResourceHandle;
450 }
451
452 SLATECORE_API const FSlateResourceHandle& GetRenderingResource() const;
453
454 bool IsSet() const { return bIsSet; }
455
456#if WITH_EDITOR
458 {
459 ResourceHandle = FSlateResourceHandle();
460 };
461#endif
462
463private:
464 SLATECORE_API void UpdateRenderingResource(FVector2f LocalSize, float DrawScale) const;
465 SLATECORE_API bool CanRenderResourceObject(UObject* InResourceObject) const;
466
467private:
468
473 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Brush, meta=( AllowPrivateAccess="true", DisplayThumbnail="true", DisplayName="Image", AllowedClasses="/Script/Engine.Texture,/Script/Engine.MaterialInterface,/Script/Engine.SlateTextureAtlasInterface", DisallowedClasses = "/Script/MediaAssets.MediaTexture"))
474 TObjectPtr<UObject> ResourceObject;
475
476public:
478 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Brush)
480
486 UPROPERTY()
487 FBox2f UVRegion;
488
490 UPROPERTY()
491 uint8 bIsDynamicallyLoaded:1;
492
494 UPROPERTY()
495 uint8 bHasUObject_DEPRECATED:1;
496
498 uint8 bIsSet : 1;
499
500public:
501
504
507 UPROPERTY(EditAnywhere, AdvancedDisplay, Category = Brush)
508 FName ResourceName;
509
522
524
526
527};
528
531{
532public:
533 virtual ~ISlateBrushSource() = default;
534 virtual const FSlateBrush* GetSlateBrush() const = 0;
535};
#define FORCENOINLINE
Definition AndroidPlatform.h:142
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
return true
Definition ExternalRpcRegistry.cpp:601
UE::Math::TBox2< float > FBox2f
Definition MathFwd.h:82
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define UMETA(...)
Definition ObjectMacros.h:747
#define UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition NameTypes.h:617
Definition UObjectGlobals.h:2492
Definition SlateResourceHandle.h:16
Definition ShaderResourceManager.h:44
Definition WidgetStyle.h:15
Definition SlateBrush.h:531
virtual ~ISlateBrushSource()=default
virtual const FSlateBrush * GetSlateBrush() const =0
Definition EnumAsByte.h:22
Definition SharedPointer.h:153
Definition Object.h:95
Definition SlateBrush.h:19
Type
Definition SlateBrush.h:21
@ RoundedBox
Definition SlateBrush.h:35
Definition SlateBrush.h:91
Type
Definition SlateBrush.h:93
@ FullColor
Definition SlateBrush.h:98
@ NoImage
Definition SlateBrush.h:95
Definition SlateBrush.h:68
Type
Definition SlateBrush.h:70
@ NoMirror
Definition SlateBrush.h:72
Definition SlateBrush.h:114
Type
Definition SlateBrush.h:116
@ FixedRadius
Definition SlateBrush.h:118
@ HalfHeightRadius
Definition SlateBrush.h:121
Definition SlateBrush.h:45
Type
Definition SlateBrush.h:47
@ NoTile
Definition SlateBrush.h:49
Definition SlateBrush.h:221
constexpr float DefaultImageSize
Definition SlateBrush.h:222
Definition SScissorRectBox.cpp:10
FDeprecateSlateVector2D FDeprecateVector2DResult
Definition SlateVector2.h:469
Definition AdvancedWidgetsModule.cpp:13
@ false
Definition radaudio_common.h:23
Definition Color.h:48
Definition Margin.h:17
Definition SlateBrush.h:227
virtual ~FSlateBrushFixLayout()=default
Definition SlateBrush.h:131
FSlateBrushOutlineSettings(FVector4 InRadius, const FSlateColor &InColor, float InWidth)
Definition SlateBrush.h:174
FSlateBrushOutlineSettings(float InUniformRadius)
Definition SlateBrush.h:142
bool operator==(const FSlateBrushOutlineSettings &Other) const
Definition SlateBrush.h:189
FSlateBrushOutlineSettings(const FSlateColor &InColor, float InWidth)
Definition SlateBrush.h:158
FSlateBrushOutlineSettings(float InUniformRadius, const FSlateColor &InColor, float InWidth)
Definition SlateBrush.h:166
FSlateBrushOutlineSettings(FVector4 InRadius)
Definition SlateBrush.h:150
Definition SlateBrush.h:239
bool operator==(const FSlateBrush &Other) const
Definition SlateBrush.h:405
void SetUVRegion(const FBox2f &InUVRegion)
Definition SlateBrush.h:393
virtual ~FSlateBrush()
Definition SlateBrush.h:287
const FSlateResourceHandle & GetRenderingResource(UE::Slate::FDeprecateVector2DParameter LocalSize, float DrawScale) const
Definition SlateBrush.h:445
void AddReferencedObjects(FReferenceCollector &Collector, UObject *ReferencingObject=nullptr)
Definition SlateBrush.h:433
ESlateBrushDrawType::Type GetDrawType() const
Definition SlateBrush.h:302
void SetUVRegion(const FBox2d &InUVRegion)
Definition SlateBrush.h:388
FLinearColor GetTint(const FWidgetStyle &InWidgetStyle) const
Definition SlateBrush.h:339
ESlateBrushTileType::Type GetTiling() const
Definition SlateBrush.h:296
ESlateBrushMirrorType::Type GetMirroring() const
Definition SlateBrush.h:298
void UnlinkColors()
Definition SlateBrush.h:348
bool IsDynamicallyLoaded() const
Definition SlateBrush.h:368
ESlateBrushImageType::Type GetImageType() const
Definition SlateBrush.h:300
bool IsSet() const
Definition SlateBrush.h:454
void SetImageSize(UE::Slate::FDeprecateVector2DParameter InImageSize)
Definition SlateBrush.h:292
const FMargin & GetMargin() const
Definition SlateBrush.h:294
bool HasUObject() const
Definition SlateBrush.h:358
const FName GetResourceName() const
Definition SlateBrush.h:309
class UObject * GetResourceObject() const
Definition SlateBrush.h:323
UE::Slate::FDeprecateVector2DResult GetImageSize() const
Definition SlateBrush.h:291
bool operator!=(const FSlateBrush &Other) const
Definition SlateBrush.h:427
UE::Slate::FDeprecateBox2D GetUVRegion() const
Definition SlateBrush.h:378
Definition SlateColor.h:42
const FLinearColor & GetColor(const FWidgetStyle &InWidgetStyle) const
Definition SlateColor.h:104
void Unlink()
Definition SlateColor.h:160
Definition ObjectPtr.h:488
Definition SlateBox2.h:19
Definition SlateVector2.h:485