LEAP Documentation 40220
Documentation for the LEAP project
SWorldAdvancedWidgetScreenLayer.h
Go to the documentation of this file.
1// Copyright Blue Isle Studios Inc 2018. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "ProjectX.h"
7#include "Layout/Visibility.h"
8#include "Widgets/DeclarativeSyntaxSupport.h"
9#include "Engine/LocalPlayer.h"
10#include "Widgets/SCompoundWidget.h"
11#include "Widgets/Layout/SConstraintCanvas.h"
12
13class USceneComponent;
14
15class SWorldAdvancedWidgetScreenLayer : public SCompoundWidget
16{
17 SLATE_BEGIN_ARGS(SWorldAdvancedWidgetScreenLayer)
18 {
19 _Visibility = EVisibility::SelfHitTestInvisible;
20 }
21 SLATE_END_ARGS()
22
23public:
24 void Construct(const FArguments& InArgs, const FLocalPlayerContext& InPlayerContext);
25
26 virtual void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override;
27
28 void SetWidgetDrawSize(FVector2D DrawSize);
29
30 void SetWidgetPivot(FVector2D Pivot);
31
32 void AddComponent(USceneComponent* Component, TSharedPtr<SWidget> Widget);
33
34 void RemoveComponent(USceneComponent* Component);
35
36private:
37 FLocalPlayerContext PlayerContext;
38
39 FVector2D DrawSize;
40 FVector2D Pivot;
41
42 class FComponentEntry
43 {
44 public:
45 FComponentEntry()
46 : Slot(nullptr)
47 {
48 }
49
50 ~FComponentEntry()
51 {
52 Widget.Reset();
53 ContainerWidget.Reset();
54 }
55
56 public:
57
58 bool bRemoving = false;
59
60 TWeakObjectPtr<USceneComponent> Component;
61 TWeakObjectPtr<class UAdvancedWidgetComponent> WidgetComponent;
62
63 TSharedPtr<SWidget> ContainerWidget;
64 TSharedPtr<SWidget> Widget;
65 SConstraintCanvas::FSlot* Slot;
66 };
67
68 TMap<FObjectKey, FComponentEntry> ComponentMap;
69 TSharedPtr<SConstraintCanvas> Canvas;
70
71 void RemoveEntryFromCanvas(SWorldAdvancedWidgetScreenLayer::FComponentEntry& Entry);
72
73protected:
74 virtual void TickEntry(UGameViewportClient* ViewportClient, const FGeometry& ViewportGeometry, const FGeometry& AllottedGeometry, FComponentEntry& Entry, bool bProjected, FVector& ViewportPosition);
75 virtual void TickClampedEntry(UGameViewportClient* ViewportClient, const FGeometry& ViewportGeometry, const FGeometry& AllottedGeometry, FComponentEntry& Entry, bool bProjected, FVector& ViewportPosition);
76};
Definition: SWorldAdvancedWidgetScreenLayer.h:16
void SetWidgetDrawSize(FVector2D DrawSize)
Definition: SWorldAdvancedWidgetScreenLayer.cpp:28
void RemoveComponent(USceneComponent *Component)
Definition: SWorldAdvancedWidgetScreenLayer.cpp:63
virtual void TickEntry(UGameViewportClient *ViewportClient, const FGeometry &ViewportGeometry, const FGeometry &AllottedGeometry, FComponentEntry &Entry, bool bProjected, FVector &ViewportPosition)
Definition: SWorldAdvancedWidgetScreenLayer.cpp:136
void SetWidgetPivot(FVector2D Pivot)
Definition: SWorldAdvancedWidgetScreenLayer.cpp:33
void Construct(const FArguments &InArgs, const FLocalPlayerContext &InPlayerContext)
Definition: SWorldAdvancedWidgetScreenLayer.cpp:14
virtual void Tick(const FGeometry &AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override
Definition: SWorldAdvancedWidgetScreenLayer.cpp:78
virtual void TickClampedEntry(UGameViewportClient *ViewportClient, const FGeometry &ViewportGeometry, const FGeometry &AllottedGeometry, FComponentEntry &Entry, bool bProjected, FVector &ViewportPosition)
Definition: SWorldAdvancedWidgetScreenLayer.cpp:171
void AddComponent(USceneComponent *Component, TSharedPtr< SWidget > Widget)
Definition: SWorldAdvancedWidgetScreenLayer.cpp:38