You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#jira UETOOL-3823 #rb brooke.hubert #preflight 6109d1e9b4288d0001acb7ef [CL 17055606 by michael balzer in ue5-main branch]
117 lines
2.4 KiB
C++
117 lines
2.4 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "BaseGizmos/GizmoInterfaces.h"
|
|
#include "ParameterSourcesFloat.generated.h"
|
|
|
|
/**
|
|
* FGizmoVec2ParameterChange represents a change in the value of an IGizmoFloatParameterSource.
|
|
* IGizmoFloatParameterSource implementations use this to track changes and emit delta information.
|
|
*/
|
|
USTRUCT()
|
|
struct INTERACTIVETOOLSFRAMEWORK_API FGizmoFloatParameterChange
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
UPROPERTY()
|
|
float InitialValue = 0;
|
|
|
|
UPROPERTY()
|
|
float CurrentValue = 0;
|
|
|
|
|
|
float GetChangeDelta() const
|
|
{
|
|
return CurrentValue - InitialValue;
|
|
}
|
|
|
|
explicit FGizmoFloatParameterChange(float StartValue = 0)
|
|
{
|
|
InitialValue = CurrentValue = StartValue;
|
|
}
|
|
};
|
|
|
|
|
|
/**
|
|
* UGizmoBaseFloatParameterSource is a base implementation of IGizmoFloatParameterSource,
|
|
* which is not functional but adds an OnParameterChanged delegate for further subclasses.
|
|
*/
|
|
UCLASS()
|
|
class INTERACTIVETOOLSFRAMEWORK_API UGizmoBaseFloatParameterSource : public UObject, public IGizmoFloatParameterSource
|
|
{
|
|
GENERATED_BODY()
|
|
public:
|
|
virtual float GetParameter() const
|
|
{
|
|
check(false); // this is an abstract base class
|
|
return 0.0f;
|
|
}
|
|
|
|
virtual void SetParameter(float NewValue)
|
|
{
|
|
check(false); // this is an abstract base class
|
|
}
|
|
|
|
|
|
virtual void BeginModify()
|
|
{
|
|
}
|
|
|
|
virtual void EndModify()
|
|
{
|
|
}
|
|
|
|
|
|
public:
|
|
DECLARE_MULTICAST_DELEGATE_TwoParams(FOnGizmoFloatParameterSourceChanged, IGizmoFloatParameterSource*, FGizmoFloatParameterChange);
|
|
FOnGizmoFloatParameterSourceChanged OnParameterChanged;
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
* UGizmoLocalFloatParameterSource is an implementation of IGizmoFloatParameterSource
|
|
* (by way of UGizmoBaseFloatParameterSource) which locally stores the relevant Parameter
|
|
* and emits update events via the OnParameterChanged delegate.
|
|
*/
|
|
UCLASS()
|
|
class INTERACTIVETOOLSFRAMEWORK_API UGizmoLocalFloatParameterSource : public UGizmoBaseFloatParameterSource
|
|
{
|
|
GENERATED_BODY()
|
|
public:
|
|
virtual float GetParameter() const override
|
|
{
|
|
return Value;
|
|
}
|
|
|
|
virtual void SetParameter(float NewValue) override
|
|
{
|
|
Value = NewValue;
|
|
LastChange.CurrentValue = NewValue;
|
|
OnParameterChanged.Broadcast(this, LastChange);
|
|
}
|
|
|
|
virtual void BeginModify()
|
|
{
|
|
LastChange = FGizmoFloatParameterChange(Value);
|
|
}
|
|
|
|
virtual void EndModify()
|
|
{
|
|
}
|
|
|
|
|
|
public:
|
|
|
|
UPROPERTY()
|
|
float Value = 0.0f;
|
|
|
|
UPROPERTY()
|
|
FGizmoFloatParameterChange LastChange;
|
|
};
|
|
|
|
|
|
|