UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TwoAxisPropertyEditBehavior.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "InputBehavior.h"
7
8#include "TwoAxisPropertyEditBehavior.generated.h"
9
10class FCanvas;
11
13
18UCLASS(MinimalAPI)
20{
22
23public:
24
26
27 // Used to define the initial adjustment frame or to update the current reference point alternating between editing the 2 properties.
30 bool IsEditing() const { return bInDrag; }
31
32private:
33
34 void OnDragStart(FVector2D InScreenPosition);
35 void OnDragUpdate(FVector2D InScreenPosition);
36 void OnDragEnd();
37 void ResetDragState();
38
39 // UInputBehavior implementation
40 // Routes input to the device specific handler functions.
41 virtual EInputDevices GetSupportedDevices() override { return EInputDevices::Mouse | EInputDevices::Keyboard; }
42 virtual FInputCaptureRequest WantsCapture(const FInputDeviceState& InputState) override;
43 virtual FInputCaptureUpdate BeginCapture(const FInputDeviceState& InputState, EInputCaptureSide eSide) override;
44 virtual FInputCaptureUpdate UpdateCapture(const FInputDeviceState& InputState, const FInputCaptureData& CaptureData) override;
45 virtual void ForceEndCapture(const FInputCaptureData& CaptureData) override;
46
47 // Mouse input handling - In these functions we assume input is from mouse device.
48 // This code is responsible for invoking OnDrag* functions at the proper times.
49 FInputCaptureRequest WantsMouseCapture(const FInputDeviceState& InputState);
51 FInputCaptureUpdate UpdateMouseCapture(const FInputDeviceState& InputState, const FInputCaptureData& CaptureData);
52 bool IsMousePressed(const FInputDeviceState& InputState) const;
53
54 // Keyboard input handling - In these functions we assume input is from keyboard device.
55 // This code is responsible for keeping bKeyPressed in the proper state.
56 FInputCaptureRequest WantsKeyboardCapture(const FInputDeviceState& InputState);
58 FInputCaptureUpdate UpdateKeyboardCapture(const FInputDeviceState& InputState, const FInputCaptureData& CaptureData);
59 bool IsKeyboardPressed(const FInputDeviceState& InputState) const;
60
61private:
62
63 // These 2 bools reflect which input we are currently capturing.
64 bool bInDrag = false;
65 bool bKeyPressed = false;
66
67 // Data that is only valid while in a drag (while bInDrag is true13).
68 struct FDragState
69 {
70 float StartValue = 0.f; // Cached initial values of the property being actively edited.
71 FVector2D StartOrigin; // The screen space coordinate of the brush when the drag started.
72 FVector2D CurrentOrigin; // The screen space coordinate of the origin of the current adjustment. Reset when changing between horizontal and vertical adjustment.
73 bool bAdjustingHorizontally = true;
74 } State; // Only valid if bInDrag is true
75
77};
78
79
80
85UCLASS(MinimalAPI)
87{
89
90public:
91
92 /* Lambda implementation of IPropertyInterface */
94 {
98
101 FMutateDeltaSignature MutateDeltaFunc = [](float Delta){ return Delta; };
102
104 float EditRate = 0.002f;
105 bool bEnabled = false;
106
107 bool IsValid() const
108 {
109 /* Enabled properties must have all mandatory fields set, disabled properties are always valid. */
110 if (bEnabled) { return !Name.IsEmpty() && GetValueFunc && SetValueFunc; }
111 return true;
112 }
113
114 private:
115
116 virtual FText GetName() override { return Name; }
117 virtual float GetValue() override { return GetValueFunc(); }
118 virtual void SetValue(float NewValue) override { SetValueFunc(NewValue); }
119 virtual float GetEditRate() override { return EditRate; }
120 virtual float MutateDelta(float Delta) override { return MutateDeltaFunc(Delta); }
121 virtual bool IsEnabled() override { return bEnabled; }
122 };
123
124public:
125
131
134 TUniqueFunction<FKey()> GetCaptureKeyFunc = [](){ return EKeys::B; };
136
137private:
138
139 // ITwoAxisPropertyEditBehaviorTarget implementation
140
141 virtual IPropertyInterface* GetHorizontalProperty() override { return &HorizontalProperty; }
142 virtual IPropertyInterface* GetVerticalProperty() override { return &VerticalProperty; }
143 virtual FKey GetCaptureKey() override { return GetCaptureKeyFunc(); }
144 virtual void PostDragUpdated() override { OnDragUpdated.Broadcast(); }
145};
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
EInputCaptureSide
Definition InputBehavior.h:20
EInputDevices
Definition InputState.h:30
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UCLASS(...)
Definition ObjectMacros.h:776
USkinnedMeshComponent float
Definition SkinnedMeshComponent.h:60
Definition CanvasTypes.h:211
Definition Text.h:385
Definition ToolContextInterfaces.h:427
Definition BehaviorTargetInterfaces.h:261
Definition FunctionFwd.h:19
Definition InputBehavior.h:249
Definition TwoAxisPropertyEditBehavior.h:87
FPropertyInterface HorizontalProperty
Definition TwoAxisPropertyEditBehavior.h:132
FSimpleMulticastDelegate OnDragUpdated
Definition TwoAxisPropertyEditBehavior.h:135
void Initialize()
Definition TwoAxisPropertyEditBehavior.h:127
FPropertyInterface VerticalProperty
Definition TwoAxisPropertyEditBehavior.h:133
Definition TwoAxisPropertyEditBehavior.h:20
INTERACTIVETOOLSFRAMEWORK_API void Initialize(ITwoAxisPropertyEditBehaviorTarget *InTarget)
Definition TwoAxisPropertyEditBehavior.cpp:16
bool IsEditing() const
Definition TwoAxisPropertyEditBehavior.h:30
IAnalyticsPropertyStore::EStatusCode SetValue(TGetter &&GetterFn, TSetter &&SetterFn, const T &ProposedValue, TCompare &&ConditionFn)
Definition AnalyticsPropertyStore.cpp:34
bool IsEnabled()
Definition IAudioLinkFactory.cpp:13
State
Definition PacketHandler.h:88
static INPUTCORE_API const FKey B
Definition InputCoreTypes.h:339
Definition InputBehavior.h:35
Definition InputBehavior.h:67
Definition InputBehavior.h:132
Definition InputState.h:264
Definition InputCoreTypes.h:50
Definition BehaviorTargetInterfaces.h:266
Definition TwoAxisPropertyEditBehavior.h:94
FGetValueSignature GetValueFunc
Definition TwoAxisPropertyEditBehavior.h:99
FSetValueSignature SetValueFunc
Definition TwoAxisPropertyEditBehavior.h:100
TUniqueFunction< void(float)> FSetValueSignature
Definition TwoAxisPropertyEditBehavior.h:96
TUniqueFunction< float(void)> FGetValueSignature
Definition TwoAxisPropertyEditBehavior.h:95
FText Name
Definition TwoAxisPropertyEditBehavior.h:103
TUniqueFunction< float(float)> FMutateDeltaSignature
Definition TwoAxisPropertyEditBehavior.h:97
bool IsValid() const
Definition TwoAxisPropertyEditBehavior.h:107