Touch Interface Designer 2025.2
Create touch interface with a visual editor and manage all mobile inputs like gestures
Loading...
Searching...
No Matches
LayoutModifier.h
Go to the documentation of this file.
1// Copyright 2025 Lost in Game Studio. All Rights Reserved
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Components/Widget.h"
7#include "LayoutModifier.generated.h"
8
9class STouchInterfaceLayoutPreviewer;
10struct FLayoutSaveData;
12class SLayoutModifier;
14
15DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnComponentEditedEvent, FName, Name, FVector2D, Location);
16
18UCLASS()
19class TOUCHINTERFACE_API ULayoutModifier : public UWidget
20{
21 GENERATED_BODY()
22
23public:
25
26 //Begin UWidget
27 virtual void SynchronizeProperties() override;
28
29protected:
30 virtual TSharedRef<SWidget> RebuildWidget() override;
31
32public:
33#if WITH_EDITOR
34 virtual const FText GetPaletteCategory() override;
35 virtual void OnBeginEditByDesigner() override;
36 virtual void OnEndEditByDesigner() override;
37 virtual void OnDesignerChanged(const FDesignerChangedEventArgs& EventArgs) override;
38#endif
39 //End UWidget
40
41 //Begin UVisual
42 virtual void ReleaseSlateResources(bool bReleaseChildren) override;
43 //End UVisual
44
47 UFUNCTION(Category="Layout Modifier", BlueprintCallable)
48 void SetPreviewEnabled(const bool bEnabled);
49
50 // Returns true if a preview of the layout is displayed by the layout modifier.
51 UFUNCTION(Category="Layout Modifier", BlueprintCallable)
52 bool IsPreviewEnabled() const;
53
54 // Activates or deactivates the function for changing the position of a component with the finger.
55 UFUNCTION(Category="Layout Modifier", BlueprintCallable)
56 void SetPositioningWithTouchEnabled(const bool bEnablePositioning) const;
57
58 // Activates or deactivates the function for resizing a component with the finger.
59 UFUNCTION(Category="Layout Modifier", BlueprintCallable)
60 void SetResizingWithTouchEnabled(const bool bEnableResizing) const;
61
62 //TODO: With slider or input
63 //Make a function to list all virtual input and make button to navigate (or bind on virtual input selected)
64 //Allow dev to adjust order by type, name or define order with name
65
69 UFUNCTION(Category="Layout Modifier|Save", BlueprintCallable)
70 bool Edit(UTouchInterfaceLayout* Layout);
71
79 UFUNCTION(Category="Layout Modifier|Save", BlueprintCallable)
80 bool EditSave(UTouchInterfaceLayout* LayoutReference, const int32 UserIndex, const int32 ConfigIndex, UTouchInterfaceLayout*& OutEditedLayout);
81
84 UFUNCTION(Category="Layout Modifier|Save", BlueprintCallable)
85 bool SaveLayout(const int32 UserIndex, const int32 ConfigIndex) const;
86
87 //Load touch interface modifications from save file
88 //UFUNCTION(Category="Layout Modifier|Save", BlueprintCallable)
89 //bool LoadSavedLayout(const int32 UserIndex, const int32 ConfigIndex);
90
91 //Get configuration in save file that contain touch interface modification
92 UFUNCTION(Category="Layout Modifier|Load", BlueprintCallable)
93 bool GetSavedLayoutData(const int32 UserIndex, const int32 ConfigIndex, FLayoutSaveData& Configuration);
94
95
96 // Reset configuration to origin (layout reference)
97 UFUNCTION(Category="Layout Modifier|Utility", BlueprintCallable)
98 void ResetToDefault(UTouchInterfaceLayout* LayoutReference, const int32 UserIndex, const int32 ConfigIndex, const bool bSaveToDisk);
99
100 // Generate component name array
101 UFUNCTION(Category="Layout Modifier|Utility", BlueprintCallable, BlueprintPure)
102 TArray<FName> GetListOfComponent(const int32 UserIndex, const int32 ConfigIndex) const;
103
106 UFUNCTION(Category="Layout Modifier|Utility", BlueprintCallable, BlueprintPure)
107 FName GetSelectedComponentName() const;
108
109 // Clear selection
110 UFUNCTION(Category="Layout Modifier|Utility", BlueprintCallable)
111 void ClearSelection();
112
113
114 //Get touch interface opacity value (edited by layout modifier)
115 UFUNCTION(Category="Layout Modifier|Property", BlueprintCallable, BlueprintPure)
116 void GetTouchInterfaceOpacity(float& InactiveOpacity, float& ActiveOpacity);
117
118 //Return original touch interface opacity (opacity value filled in touch interface layout editor)
119 //UFUNCTION(Category="Layout Modifier|Property", BlueprintCallable, BlueprintPure)
120 //void GetTouchInterfaceDesignOpacity(float& InactiveOpacity, float& ActiveOpacity);
121
122 //Set touch interface opacity value
123 UFUNCTION(Category="Layout Modifier|Property", BlueprintCallable)
124 void SetTouchInterfaceOpacity(const float InactiveOpacity, const float ActiveOpacity);
125
129 UFUNCTION(Category="Layout Modifier|Property", BlueprintCallable, BlueprintPure)
130 FVector2D GetComponentLocation(const FName InputName);
131
132 //Return original location of component (location value filled in touch interface layout editor)
133 UFUNCTION(Category="Layout Modifier|Property", BlueprintCallable, BlueprintPure)
134 FVector2D GetComponentDesignLocation(const FName ComponentName);
135
136 //Set component location
137 UFUNCTION(Category="Layout Modifier|Property", BlueprintCallable)
138 void SetComponentLocation(const FName InputName, const FVector2D NewOffset);
139
140 //Return max offset from origin
141 UFUNCTION(Category="Layout Modifier|Property", BlueprintCallable)
142 FVector4f GetComponentMaxOffset(const FName ComponentName);
143
146 UFUNCTION(Category="Layout Modifier|Property", BlueprintCallable, BlueprintPure)
147 FVector2D GetComponentSize(const FName InputName);
148
149 //Return original size of component (Size value filled in touch interface layout editor)
150 UFUNCTION(Category="Layout Modifier|Property", BlueprintCallable, BlueprintPure)
151 FVector2D GetComponentDesignSize(const FName ComponentName);
152
153 //Set component size
154 UFUNCTION(Category="Layout Modifier|Property", BlueprintCallable)
155 void SetComponentSize(const FName InputName, FVector2D NewSize);
156
157 //Return max size scale
158 UFUNCTION(Category="Layout Modifier|Property", BlueprintCallable)
159 FVector2D GetComponentMaxSize(const FName ComponentName);
160
161 //Return layout asset that correspond to modifications in save file at config index
162 UFUNCTION(Category="Layout Modifier|Property", BlueprintCallable)
163 UTouchInterfaceLayout* GetLayoutAssetFromSave(int32 UserIndex, int32 ConfigIndex);
164
165
170 UFUNCTION(Category="Layout Modifier|Preview", BlueprintCallable)
171 void SetPositioningPreviewEnabled(const bool bEnable) const;
172
177 UFUNCTION(Category="Layout Modifier|Preview", BlueprintCallable)
178 void SetDesignLocationPreviewEnabled(const bool bEnable) const;
179
180private:
181 UFUNCTION()
182 void HandleOnComponentSelected(FName Name, FVector2D Location);
183
184 UFUNCTION()
185 void HandleOnComponentLocationEdited(FName Name, FVector2D Delta);
186
187 UFUNCTION()
188 void HandleOnComponentSizeEdited(FName Name, FVector2D Delta);
189
190public:
196
200 UPROPERTY(Category="Settings", BlueprintReadWrite, EditAnywhere)
202
203 UPROPERTY(Category="Settings", BlueprintReadOnly, EditAnywhere, meta=(ClampMin=0.1f, ClampMax=1.0f))
204 float ResizeSensibility;
205
206 UPROPERTY(Category="Settings|Visual", BlueprintReadOnly, EditAnywhere)
208
209 // Brush used to draw max offset from origin for positioning
210 UPROPERTY(Category="Settings|Visual", BlueprintReadOnly, EditAnywhere, meta=(EditCondition="bDrawPositioningBrush"))
211 FSlateBrush PositioningBrush;
212
213 UPROPERTY(Category="Settings|Visual", BlueprintReadOnly, EditAnywhere)
215
216 UPROPERTY(Category="Settings|Visual", BlueprintReadOnly, EditAnywhere, meta=(EditCondition="bDrawDesignCenter"))
217 FSlateBrush DesignLocationBrush;
218
219
220 UPROPERTY(Category="Configurator|Event", BlueprintAssignable)
221 FOnComponentEditedEvent OnComponentSelected;
222
223 UPROPERTY(Category="Configurator|Event", BlueprintAssignable)
224 FOnComponentEditedEvent OnComponentLocationEdited;
225
226 UPROPERTY(Category="Configurator|Event", BlueprintAssignable)
227 FOnComponentEditedEvent OnComponentSizeEdited;
228
229protected:
230 TSharedPtr<STouchInterfaceLayoutPreviewer> LayoutModifierWidget;
231
232private:
233 FVector2D GeometrySize;
234 float CurrentDPIScale;
235
236 float CurrentActiveOpacity;
237 float CurrentInactiveOpacity;
238
239 FName SelectedComponentName;
240
241 UPROPERTY()
242 ULayoutComponent* ComponentSelected;
243
244 UPROPERTY()
245 TObjectPtr<UTouchInterfaceLayout> EditedLayout;
246};
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnComponentEditedEvent, FName, Name, FVector2D, Location)
Definition LayoutComponent.h:94
virtual BlueprintPure FVector2D GetComponentLocation() const
Definition LayoutComponent.cpp:645
virtual BlueprintCallable void SetComponentSize(const FVector2D NewSize)
Definition LayoutComponent.cpp:984
virtual BlueprintPure FVector4f GetComponentMaxOffset() const
Definition LayoutComponent.h:211
virtual BlueprintCallable void SetComponentLocation(const FVector2D NewLocation)
Definition LayoutComponent.cpp:898
BlueprintPure FVector2D GetComponentSize() const
Definition LayoutComponent.cpp:710
BlueprintCallable FVector2D GetComponentMaxSize(const FName ComponentName)
Definition LayoutModifier.cpp:519
BlueprintPure void GetTouchInterfaceOpacity(float &InactiveOpacity, float &ActiveOpacity)
Definition LayoutModifier.cpp:362
BlueprintCallable void SetPositioningPreviewEnabled(const bool bEnable) const
Definition LayoutModifier.cpp:564
BlueprintPure FVector2D GetComponentDesignLocation(const FName ComponentName)
Definition LayoutModifier.cpp:402
Category
Definition LayoutModifier.h:47
EditAnywhere uint8 bUseTouchForSizing
Definition LayoutModifier.h:201
BlueprintCallable void ResetToDefault(UTouchInterfaceLayout *LayoutReference, const int32 UserIndex, const int32 ConfigIndex, const bool bSaveToDisk)
Definition LayoutModifier.cpp:287
EditAnywhere uint8 bDrawDesignCenter
Definition LayoutModifier.h:214
BlueprintCallable void SetPositioningWithTouchEnabled(const bool bEnablePositioning) const
Definition LayoutModifier.cpp:119
BlueprintPure TArray< FName > GetListOfComponent(const int32 UserIndex, const int32 ConfigIndex) const
Definition LayoutModifier.cpp:334
BlueprintCallable void SetTouchInterfaceOpacity(const float InactiveOpacity, const float ActiveOpacity)
Definition LayoutModifier.cpp:371
ULayoutModifier()
Definition LayoutModifier.cpp:12
EditAnywhere uint8 bDrawPositioningBrush
Definition LayoutModifier.h:207
BlueprintCallable void SetResizingWithTouchEnabled(const bool bEnableResizing) const
Definition LayoutModifier.cpp:127
virtual void SynchronizeProperties() override
Definition LayoutModifier.cpp:28
BlueprintCallable void ClearSelection()
Definition LayoutModifier.cpp:354
BlueprintCallable
Definition LayoutModifier.h:101
BlueprintAssignable FOnComponentEditedEvent OnComponentLocationEdited
Definition LayoutModifier.h:224
BlueprintCallable void SetPreviewEnabled(const bool bEnabled)
Definition LayoutModifier.cpp:94
TSharedPtr< STouchInterfaceLayoutPreviewer > LayoutModifierWidget
Definition LayoutModifier.h:230
virtual TSharedRef< SWidget > RebuildWidget() override
Definition LayoutModifier.cpp:44
BlueprintCallable bool Edit(UTouchInterfaceLayout *Layout)
Definition LayoutModifier.cpp:135
BlueprintReadWrite
Definition LayoutModifier.h:194
EditAnywhere
Definition LayoutModifier.h:203
virtual void ReleaseSlateResources(bool bReleaseChildren) override
Definition LayoutModifier.cpp:88
BlueprintAssignable FOnComponentEditedEvent OnComponentSelected
Definition LayoutModifier.h:221
meta
Definition LayoutModifier.h:203
BlueprintAssignable FOnComponentEditedEvent OnComponentSizeEdited
Definition LayoutModifier.h:227
BlueprintCallable bool GetSavedLayoutData(const int32 UserIndex, const int32 ConfigIndex, FLayoutSaveData &Configuration)
Definition LayoutModifier.cpp:264
EditAnywhere uint8 bUseTouchForPositioning
Definition LayoutModifier.h:195
BlueprintCallable bool IsPreviewEnabled() const
Definition LayoutModifier.cpp:109
BlueprintPure FVector2D GetComponentDesignSize(const FName ComponentName)
Definition LayoutModifier.cpp:482
BlueprintPure FName GetSelectedComponentName() const
Definition LayoutModifier.cpp:349
BlueprintCallable bool EditSave(UTouchInterfaceLayout *LayoutReference, const int32 UserIndex, const int32 ConfigIndex, UTouchInterfaceLayout *&OutEditedLayout)
Definition LayoutModifier.cpp:148
BlueprintCallable void SetDesignLocationPreviewEnabled(const bool bEnable) const
Definition LayoutModifier.cpp:572
BlueprintCallable bool SaveLayout(const int32 UserIndex, const int32 ConfigIndex) const
Definition LayoutModifier.cpp:211
BlueprintReadOnly
Definition LayoutModifier.h:203
BlueprintCallable UTouchInterfaceLayout * GetLayoutAssetFromSave(int32 UserIndex, int32 ConfigIndex)
Definition LayoutModifier.cpp:536
Definition TouchInterfaceLayout.h:20
Definition TouchInterfaceSave.h:102