Touch Interface Designer 2025.2
Create touch interface with a visual editor and manage all mobile inputs like gestures
Loading...
Searching...
No Matches
TouchInterfaceLayout.h
Go to the documentation of this file.
1// Copyright 2024 Lost in Game Studio. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "UObject/Object.h"
8#include "TouchInterfaceLayout.generated.h"
9
10class UComponentLogic;
13class STouchInterface;
15class UMaterialInterface;
16
19class TOUCHINTERFACE_API UTouchInterfaceLayout : public UObject
20{
21 GENERATED_BODY()
22
23 UTouchInterfaceLayout();
24 ~UTouchInterfaceLayout();
25
26 virtual void BeginDestroy() override;
27
28public:
29 TSharedPtr<STouchInterface> GetLayoutWidget() const;
30 void SetLayoutWidget(TSharedRef<STouchInterface> InLayoutWidget);
31
32#if WITH_EDITOR
33 virtual void OnBeginEdit();
34 virtual void OnDesignerSizeChanged(const FIntPoint NewSize);
35 virtual void OnEndEdit();
36
37 virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override;
38#endif
39
40 virtual void ApplyLayout(TSharedRef<STouchInterface> TouchInterface);
41
42
43 //LAYOUT
44
45 // Display layout
46 UFUNCTION(Category="Layout|Visibility", BlueprintCallable)
47 virtual void ShowLayout();
48
49 // Hide layout (Inputs remain active)
50 UFUNCTION(Category="Layout|Visibility", BlueprintCallable)
51 virtual void HideLayout();
52
53 // Return true if layout widget is visible
54 UFUNCTION(Category="Layout|Visibility", BlueprintCallable)
55 virtual bool IsVisible();
56
57
58 UFUNCTION(Category="Layout|Opacity", BlueprintCallable, BlueprintPure)
59 float GetActiveOpacity() const { return ActiveOpacity; }
60
61 //TODO: Notify widget that opacity has changed
62 UFUNCTION(Category="Layout|Opacity", BlueprintCallable)
63 void SetActiveOpacity(const float Opacity) { ActiveOpacity = Opacity; }
64
65 UFUNCTION(Category="Layout|Opacity", BlueprintCallable, BlueprintPure)
66 float GetInactiveOpacity() const { return InactiveOpacity; }
67
68 UFUNCTION(Category="Layout|Opacity", BlueprintCallable)
69 void SetInactiveOpacity(const float Opacity) { InactiveOpacity = Opacity; }
70
71
72 UFUNCTION(Category="Layout|Scale", BlueprintCallable, BlueprintPure)
73 virtual float GetLayoutScale() const { return LayoutScale; }
74
75 //Set the global scale of layout
76 UFUNCTION(Category="Layout|Scale", BlueprintCallable)
77 virtual void SetLayoutScale(const float NewScale);
78
79 //Reset layout to default layout
80 UFUNCTION(Category="Layout|Scale", BlueprintCallable)
81 void ResetToDefault();
82
83 UFUNCTION(Category="Layout|Utility", BlueprintCallable)
84 void Rebuild();
85
86
87 //COMPONENTS
88
89 //TODO: Create component decorator automatically except if class is filled. Output component decorator.
90
91 //TODO: Group support decorator and input
95 UFUNCTION(Category="Component", BlueprintCallable)
96 virtual ULayoutGroupComponent* AddGroup(const FName DesiredName, const FVector2D Position);
97
98 //TODO: Create component decorator automatically except if class is filled. Output component decorator.
99
105 UFUNCTION(Category="Component", BlueprintCallable)
106 virtual ULayoutComponent* AddTouchInput(const FName DesiredName, const FVector2D Position, FVector2D Size, const TSubclassOf<UComponentLogic> LogicClass, UComponentLogic*& OutLogic);
107
108 //TODO: Create component decorator automatically except if class is filled. Output component decorator.
109
116 UFUNCTION(Category="Component", BlueprintCallable)
117 virtual ULayoutComponent* AddTouchInputInGroup(const FName DesiredName, const FVector2D Offset, FVector2D Size, TSubclassOf<UComponentLogic> LogicClass, const FName GroupName, UComponentLogic*& OutLogic);
118
119 //TODO: Create Touch Input Function, then make function to add instance in layout or group. More simpler!
120
121 //Remove component from layout (Warning: Include Children)
122 UFUNCTION(Category="Component", BlueprintCallable)
123 virtual void RemoveComponent(class ULayoutComponent* Component);
124
125 //Remove component from layout (Warning: Include Children)
126 UFUNCTION(Category="Component", BlueprintCallable)
127 virtual void RemoveComponentByName(const FName ComponentName);
128
129 // Displays component in layout
130 UFUNCTION(Category="Component|Visibility", BlueprintCallable)
131 virtual void ShowComponent(const FName Name);
132
133 // Hide component in layout
134 UFUNCTION(Category="Component|Visibility", BlueprintCallable)
135 virtual void HideComponent(const FName Name);
136
137 UFUNCTION(Category="Component|Visibility", BlueprintCallable)
138 virtual void ShowComponentByNames(const TArray<FName> Names);
139
140 // Hide all components in layout
141 UFUNCTION(Category="Component|Visibility", BlueprintCallable)
142 virtual void HideComponentByNames(const TArray<FName> Names);
143
144 // Displays all components in layout
145 UFUNCTION(Category="Component|Visibility", BlueprintCallable)
146 virtual void ShowAllComponents();
147
148 // Hide all components in layout
149 UFUNCTION(Category="Component|Visibility", BlueprintCallable)
150 virtual void HideAllComponents();
151
152 // Displays all components except the named one
153 UFUNCTION(Category="Component|Visibility", BlueprintCallable)
154 virtual void ShowAllExcept(const FName Name);
155
156 // Hide all components except the named one
157 UFUNCTION(Category="Component|Visibility", BlueprintCallable)
158 virtual void HideAllExcept(const FName Name);
159
160 // Displays all components except the named ones
161 UFUNCTION(Category="Component|Visibility", BlueprintCallable)
162 virtual void ShowAllExceptNamedOnes(const TArray<FName> Names);
163
164 // Hide all components except the named ones
165 UFUNCTION(Category="Component|Visibility", BlueprintCallable)
166 virtual void HideAllExceptNamedOnes(const TArray<FName> Names);
167
168
172 UFUNCTION(Category="Touch Interface|Utility", BlueprintCallable)
173 virtual bool ContainComponent(const ULayoutComponent* Component, const bool bRecursively = false);
174
178 UFUNCTION(Category="Touch Interface|Utility", BlueprintCallable)
179 virtual bool ContainComponentByName(const FName ComponentName, const bool bRecursively = false);
180
186 UFUNCTION(Category="Component|Utility", BlueprintCallable)
187 virtual bool GetComponentByNames(TArray<ULayoutComponent*>& Components, const TArray<FName> Names, const bool bRecursively = false);
188
192 UFUNCTION(Category="Component|Utility", BlueprintCallable)
193 virtual bool GetAllComponents(TArray<ULayoutComponent*>& Components, const bool bRecursively = false);
194
198 UFUNCTION(Category="Component|Utility", BlueprintCallable)
199 virtual ULayoutComponent* GetComponentByName(const FName Name, const bool bRecursively = false) const;
200
205 UFUNCTION(Category="Component|Utility", BlueprintCallable)
206 virtual bool GetComponentsByLogicClass(TSubclassOf<UComponentLogic> LogicClass, TArray<ULayoutComponent*>& Components, const bool bRecursively = false);
207
211 //UFUNCTION(Category="Component|Utility", BlueprintCallable)
212 //virtual bool GetComponentsPressed(TArray<UTouchInputComponent*>& Components, const bool bRecursively = false);
213
214 // Returns index of component
215 UFUNCTION(Category="Component|Utility", BlueprintCallable, BlueprintPure)
216 int32 GetIndexOfComponent(ULayoutComponent* Component);
217
221 UFUNCTION(Category="Component|Utility", BlueprintCallable)
222 virtual bool GetAllComponentName(TArray<FName>& Names, const bool bRecursively = false);
223
224 //TODO: Function to modify retainer settings
225
226 // Touch Interface Layout tree
227 UPROPERTY()
228 TArray<TObjectPtr<ULayoutComponent>> Children;
229
231 uint8 bFade:1;
232
235 UPROPERTY(Category="Opacity", EditAnywhere, BlueprintReadOnly, meta=(ClampMin=0.0f, ClampMax=1.0f, UIMin=0.0f, UIMax=1.0f))
236 float ActiveOpacity;
237
238 // Opacity (0.0 - 1.0) of all components while touch interface is inactive (no interaction)
239 UPROPERTY(Category="Opacity", EditAnywhere, BlueprintReadOnly, meta=(EditCondition="bFade==true", EditConditionHides), meta=(ClampMin=0.0f, ClampMax=1.0f, UIMin=0.0f, UIMax=1.0f))
240 float InactiveOpacity;
241
242 // Speed at which inactive opacity is reached
243 UPROPERTY(Category="Opacity", EditAnywhere, BlueprintReadOnly, meta=(EditCondition="bFade==true", EditConditionHides), meta=(ClampMin=0.1f, UIMin=0.1f))
244 float InactiveLerpRate;
245
246
247 // How long after user interaction will all components fade out to Inactive Opacity
248 UPROPERTY(Category="Reset/Recenter", EditAnywhere, BlueprintReadOnly, meta=(ClampMin=0.0f, UIMin=0.0f))
249 float TimeUntilDeactivated;
250
253 UPROPERTY(Category="Reset/Recenter", EditAnywhere, BlueprintReadOnly, meta=(ClampMin=0.0f, UIMin=0.0f))
254 float TimeUntilReset;
255
256
259 UPROPERTY(Category="Delay", EditAnywhere, BlueprintReadOnly, meta=(ClampMin=0.0f, UIMin=0.0f))
260 float ActivationDelay;
261
264 UPROPERTY(Category="Delay", EditAnywhere, BlueprintReadOnly, meta=(ClampMin=0.016f, UIMin=0.016f))
265 float StartupDelay;
266
269 UPROPERTY(Category="Optimization", EditAnywhere)
271
272 // Should this widget redraw the contents it has every time it receives an invalidation request
273 UPROPERTY(Category="Optimization", EditAnywhere, meta=(EditCondition="bRetainRender==true"))
274 uint8 bRenderOnInvalidation:1;
275
276 // Should this widget redraw the contents it has every time the phase occurs
277 UPROPERTY(Category="Optimization", EditAnywhere, meta=(EditCondition="bRetainRender==true"))
278 uint8 bRenderOnPhase:1;
279
284 UPROPERTY(Category="Optimization", EditAnywhere, meta=(EditCondition="bRetainRender==true && bRenderOnPhase==true"))
285 int32 Phase;
286
289 UPROPERTY(Category="Optimization", EditAnywhere, meta=(EditCondition="bRetainRender==true && bRenderOnPhase==true"))
290 int32 PhaseCount;
291
297 UPROPERTY(Category="Effect", EditAnywhere, meta=(EditCondition="bRetainRender==true && bRenderOnPhase==true"))
298 TObjectPtr<UMaterialInterface> EffectMaterial;
299
300 //The texture sampler parameter of the EffectMaterial, that we'll set to the render target.
301 UPROPERTY(Category="Effect", EditAnywhere, meta=(EditCondition="bRetainRender==true && bRenderOnPhase==true"))
302 FName TextureParameter;
303
304
307 UPROPERTY(Category="Advanced", EditAnywhere)
309
310 // Whether or not shape drawing is detected on all screen surface.
311 UPROPERTY(Category="Advanced", EditAnywhere)
313
314 //Drawer class used to draw the user's drawing and shape.
315 UPROPERTY(Category="Advanced", EditAnywhere)
317
318 //Enable or disable opacity modification in the layout modifier widget.
319 UPROPERTY(Category="Layout Modifier", EditAnywhere)
321
322 //Enable or disable modification of retainer parameters in the layout modifier widget.
323 UPROPERTY(Category="Layout Modifier", EditAnywhere)
325
326
327private:
328 TSharedPtr<STouchInterface> LayoutWidget;
329
330 UPROPERTY(Transient)
331 TObjectPtr<UTouchInterfaceLayout> TouchInterfaceLayout;
332
333 float LayoutScale;
334};
BlueprintType
Definition ComponentDecorator_Animation.h:40
Blueprintable
Definition ComponentDecorator_Animation.h:40
Definition STouchInterface.h:43
Definition TouchInterface.Build.cs:6
Definition LayoutComponent.h:94
Definition LayoutGroupComponent.h:14
EditAnywhere uint8 bAllScreenGesture
Definition TouchInterfaceLayout.h:308
virtual BlueprintPure float GetLayoutScale() const
Definition TouchInterfaceLayout.h:73
EditAnywhere uint8 bAllowRetainerWidgetModification
Definition TouchInterfaceLayout.h:324
EditAnywhere TSubclassOf< UVirtualShapeDrawer > ShapeDrawerClass
Definition TouchInterfaceLayout.h:316
EditAnywhere
Definition TouchInterfaceLayout.h:230
void SetLayoutWidget(TSharedRef< STouchInterface > InLayoutWidget)
Definition TouchInterfaceLayout.cpp:61
TSharedPtr< STouchInterface > GetLayoutWidget() const
Definition TouchInterfaceLayout.cpp:56
TArray< TObjectPtr< ULayoutComponent > > Children
Definition TouchInterfaceLayout.h:228
EditAnywhere uint8 bAllScreenShapeDrawing
Definition TouchInterfaceLayout.h:312
virtual void ApplyLayout(TSharedRef< STouchInterface > TouchInterface)
Definition TouchInterfaceLayout.cpp:113
BlueprintReadOnly
Definition TouchInterfaceLayout.h:235
BlueprintCallable
Definition TouchInterfaceLayout.h:58
EditAnywhere uint8 bRetainRender
Definition TouchInterfaceLayout.h:270
BlueprintCallable void SetInactiveOpacity(const float Opacity)
Definition TouchInterfaceLayout.h:69
virtual BlueprintCallable bool IsVisible()
Definition TouchInterfaceLayout.cpp:128
BlueprintCallable void SetActiveOpacity(const float Opacity)
Definition TouchInterfaceLayout.h:63
BlueprintPure float GetInactiveOpacity() const
Definition TouchInterfaceLayout.h:66
virtual BlueprintCallable void ShowLayout()
Definition TouchInterfaceLayout.cpp:118
BlueprintReadOnly uint8 bFade
Definition TouchInterfaceLayout.h:231
EditAnywhere uint8 bAllowOpacityModification
Definition TouchInterfaceLayout.h:320
virtual BlueprintCallable void HideLayout()
Definition TouchInterfaceLayout.cpp:123
Category
Definition TouchInterfaceLayout.h:46
BlueprintPure float GetActiveOpacity() const
Definition TouchInterfaceLayout.h:59
meta
Definition TouchInterfaceLayout.h:235
Definition TouchInterfaceListener.h:16
Definition VirtualShapeDrawer.h:22