UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
WidgetLayoutLibrary.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/Geometry.h"
9#include "WidgetLayoutLibrary.generated.h"
10
14class UGridSlot;
16class UOverlaySlot;
19class UScrollBoxSlot;
20class USafeZoneSlot;
21class UScaleBoxSlot;
22class USizeBoxSlot;
23class UStackBoxSlot;
24class UWrapBoxSlot;
26class UWidget;
27
28UCLASS(MinimalAPI)
30{
32
33public:
34
44 UFUNCTION(BlueprintPure, BlueprintCosmetic, Category="Viewport")
45 static UMG_API bool ProjectWorldLocationToWidgetPosition(const APlayerController* PlayerController, FVector WorldLocation, FVector2D& ScreenPosition, bool bPlayerViewportRelative);
46
53 static UMG_API bool ProjectWorldLocationToWidgetPositionWithDistance(const APlayerController* PlayerController, FVector WorldLocation, FVector& ScreenPosition, bool bPlayerViewportRelative);
54
58 UFUNCTION(BlueprintPure, BlueprintCosmetic, Category="Viewport", meta=( WorldContext="WorldContextObject" ))
59 static UMG_API float GetViewportScale(const UObject* WorldContextObject);
60
64 static UMG_API float GetViewportScale(const UGameViewportClient* ViewportClient);
65
69 UFUNCTION(BlueprintPure, BlueprintCosmetic, Category="Viewport", meta=( WorldContext="WorldContextObject", Keywords = "screen size"))
70 static UMG_API FVector2D GetViewportSize(const UObject* WorldContextObject);
71
77 UFUNCTION(BlueprintCallable, Category="Viewport", meta=( WorldContext="WorldContextObject" ))
78 static UMG_API FGeometry GetViewportWidgetGeometry(const UObject* WorldContextObject);
79
85 UFUNCTION(BlueprintCallable, Category="Viewport")
86 static UMG_API FGeometry GetPlayerScreenWidgetGeometry(APlayerController* PlayerController);
87
91 UFUNCTION(BlueprintCallable, Category="Viewport")
92 static UMG_API FVector2D GetMousePositionOnPlatform();
93
97 UFUNCTION(BlueprintCallable, Category="Viewport", meta=( WorldContext="WorldContextObject" ))
98 static UMG_API FVector2D GetMousePositionOnViewport(const UObject* WorldContextObject);
99
106 //UE_DEPRECATED(4.17, "Use GetMousePositionOnViewport() instead. Optionally and for more options, you can use GetViewportWidgetGeometry and GetPlayerScreenWidgetGeometry are newly introduced to give you the geometry of the viewport and the player screen for widgets to help convert between spaces.")
107 UFUNCTION(BlueprintPure, BlueprintCosmetic, Category="Viewport")
108 static UMG_API bool GetMousePositionScaledByDPI(const APlayerController* Player, float& LocationX, float& LocationY);
109 static UMG_API bool GetMousePositionScaledByDPI(const APlayerController* Player, double& LocationX, double& LocationY); // LWC_TODO: Temp stand in for native calls with FVector2D components.
110
115 UFUNCTION(BlueprintPure, Category = "Slot")
116 static UMG_API class UBorderSlot* SlotAsBorderSlot(UWidget* Widget);
117
122 UFUNCTION(BlueprintPure, Category="Slot")
123 static UMG_API UCanvasPanelSlot* SlotAsCanvasSlot(UWidget* Widget);
124
129 UFUNCTION(BlueprintPure, Category="Slot")
130 static UMG_API UGridSlot* SlotAsGridSlot(UWidget* Widget);
131
136 UFUNCTION(BlueprintPure, Category="Slot")
137 static UMG_API UHorizontalBoxSlot* SlotAsHorizontalBoxSlot(UWidget* Widget);
138
143 UFUNCTION(BlueprintPure, Category="Slot")
144 static UMG_API UOverlaySlot* SlotAsOverlaySlot(UWidget* Widget);
145
150 UFUNCTION(BlueprintPure, Category="Slot")
151 static UMG_API UUniformGridSlot* SlotAsUniformGridSlot(UWidget* Widget);
152
157 UFUNCTION(BlueprintPure, Category = "Slot")
158 static UMG_API UVerticalBoxSlot* SlotAsVerticalBoxSlot(UWidget* Widget);
159
160
165 UFUNCTION(BlueprintPure, Category = "Slot")
166 static UMG_API UScrollBoxSlot* SlotAsScrollBoxSlot(UWidget* Widget);
167
172 UFUNCTION(BlueprintPure, Category = "Slot")
173 static UMG_API USafeZoneSlot* SlotAsSafeBoxSlot(UWidget* Widget);
174
179 UFUNCTION(BlueprintPure, Category = "Slot")
180 static UMG_API UScaleBoxSlot* SlotAsScaleBoxSlot(UWidget* Widget);
181
186 UFUNCTION(BlueprintPure, Category = "Slot")
187 static UMG_API USizeBoxSlot* SlotAsSizeBoxSlot(UWidget* Widget);
188
193 UFUNCTION(BlueprintPure, Category = "Slot")
194 static UMG_API UStackBoxSlot* SlotAsStackBoxSlot(UWidget* Widget);
195
200 UFUNCTION(BlueprintPure, Category = "Slot")
201 static UMG_API UWrapBoxSlot* SlotAsWrapBoxSlot(UWidget* Widget);
202
207 UFUNCTION(BlueprintPure, Category = "Slot")
208 static UMG_API UWidgetSwitcherSlot* SlotAsWidgetSwitcherSlot(UWidget* Widget);
209
213 UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category="Viewport", meta=( WorldContext="WorldContextObject" ))
214 static UMG_API void RemoveAllWidgets(const UObject* WorldContextObject);
215};
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define GENERATED_UCLASS_BODY(...)
Definition ObjectMacros.h:768
#define UCLASS(...)
Definition ObjectMacros.h:776
Definition PlayerController.h:261
Definition BlueprintFunctionLibrary.h:16
Definition BorderSlot.h:21
Definition CanvasPanelSlot.h:67
Definition GameViewportClient.h:71
Definition GridSlot.h:20
Definition HorizontalBoxSlot.h:17
Definition Object.h:95
Definition OverlaySlot.h:18
Definition SafeZoneSlot.h:16
Definition ScaleBoxSlot.h:18
Definition ScrollBoxSlot.h:18
Definition SizeBoxSlot.h:18
Definition StackBoxSlot.h:18
Definition UniformGridSlot.h:19
Definition VerticalBoxSlot.h:18
Definition WidgetLayoutLibrary.h:30
Definition WidgetSwitcherSlot.h:19
Definition Widget.h:217
Definition WrapBoxSlot.h:17
Definition Geometry.h:40