5#include "CoreMinimal.h"
7#include "Widgets/SCompoundWidget.h"
8#include "Widgets/Layout/SConstraintCanvas.h"
9#include "Styling/SlateBrush.h"
12class SConstraintCanvas;
18 TSharedPtr<SComponentPreviewer>
Widget;
19 SConstraintCanvas::FSlot*
Slot;
41class TOUCHINTERFACE_API STouchInterfaceLayoutPreviewer :
public SCompoundWidget
44 SLATE_BEGIN_ARGS(STouchInterfaceLayoutPreviewer)
47 SLATE_ARGUMENT(UTouchInterfaceLayout*, EditedLayout)
48 SLATE_ARGUMENT(UTouchInterfaceLayout*, DesignedLayout)
49 SLATE_ARGUMENT(
float, StartOpacity)
50 SLATE_ARGUMENT(
bool, DrawHitBox)
51 SLATE_ARGUMENT(FIntPoint, ScreenSize)
52 SLATE_ARGUMENT(
float, DPIScale)
54 SLATE_ARGUMENT(
bool, bDesignMode)
55 SLATE_ARGUMENT(
float, ResizeSensibility)
57 SLATE_EVENT(FOnComponentEditedSignature, OnComponentSelected)
58 SLATE_EVENT(FOnComponentEditedSignature, OnComponentLocationEdited)
59 SLATE_EVENT(FOnComponentEditedSignature, OnComponentSizeEdited)
63 STouchInterfaceLayoutPreviewer();
66 void Construct(const FArguments& InArgs);
69 void GenerateLayout();
73 virtual FVector2D ComputeDesiredSize(
float LayoutScaleMultiplier) const override;
75 virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle,
bool bParentEnabled) const override;
78 virtual FReply OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
79 virtual FReply OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
80 virtual FReply OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
82 virtual
void OnMouseLeave(const FPointerEvent& MouseEvent) override;
84 virtual FReply OnTouchStarted(const FGeometry& MyGeometry, const FPointerEvent& InTouchEvent) override;
85 virtual FReply OnDragDetected(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
86 virtual FReply OnTouchMoved(const FGeometry& MyGeometry, const FPointerEvent& InTouchEvent) override;
87 virtual FReply OnTouchEnded(const FGeometry& MyGeometry, const FPointerEvent& InTouchEvent) override;
90 void EnablePreview(
bool bReset = false);
91 void DisablePreview();
93 bool IsPreview()
const {
return bPreview; }
97 void Update(FName ComponentName, FVector2D Location, FVector2D Size)
const;
100 void RebuildLayout();
102 void SetEditedLayoutAsset(
const UTouchInterfaceLayout* NewLayout);
105 void SetScreenSize(
const FIntPoint InScreenSize);
106 void SetOpacity(
const float InOpacity) { Opacity = InOpacity; }
107 void SetDPIScale(
const float InDPIScale);
108 void SetDrawHitBox(
const bool bEnable) { bDrawHitBox = bEnable; }
109 void SetPressedStateVisibility(
const bool bVisible) { bShowPressedState = bVisible; }
111 void SetCanDrawPositioningBrush(
const bool bEnable) { bCanDrawPositioningBrush = bEnable; }
112 void SetCanDrawDesignLocationBrush(
const bool bEnable) { bCanDrawDesignLocationBrush = bEnable; }
119 virtual FMargin GenerateOffset(
const TObjectPtr<ULayoutComponent> Component);
121 float GetScaleFactor(
const FGeometry& AllottedGeometry)
const;
124 uint8 bUseTouchForPositioning:1;
125 uint8 bUseTouchForResizing:1;
127 float ResizeSensibility;
129 uint8 bDrawPositioningBrush:1;
130 FSlateBrush PositioningBrush;
132 uint8 bDrawOriginalCenterBrush:1;
133 FSlateBrush OriginalCenterBrush;
136 FOnComponentEditedSignature OnComponentSelected;
137 FOnComponentEditedSignature OnComponentLocationEdited;
138 FOnComponentEditedSignature OnComponentResized;
140 FVector2D ScreenSize;
144 float InactiveOpacity;
145 float LastDistanceBetweenFingers;
150 FVector2D TouchLocation_Finger0;
151 FVector2D TouchLocation_Finger1;
153 FName SelectedComponentName;
157 uint8 bDragVirtualControl:1;
158 uint8 bResizeVirtualControl:1;
159 uint8 bCanDrawPositioningBrush:1;
160 uint8 bCanDrawDesignLocationBrush:1;
162 TSharedPtr<SConstraintCanvas> MainCanvas;
164 const UTouchInterfaceLayout* EditedLayout;
167 TMap<FName, FLayoutPreviewerWidget> Components;
169 TArray<TSharedPtr<SComponentPreviewer>> ComponentPreviewers;
177 uint8 bShowPressedState:1;
DECLARE_DELEGATE_TwoParams(FOnTouchEvent, int32, FVector2D)
Definition SComponentPreviewer.h:17
Definition ComponentDecorator.h:36
Definition TouchInterfaceLayout.h:20