Files
UnrealEngineUWP/Engine/Source/Editor/CurveEditor/Private/CurveEditorSettings.cpp
Max Chen 9c03481d38 Curve Editor: Curve points now default to the same color as the curve. Selected points defaults to white and is controllable by a preference.
The default color for curves is now a darker gray instead of White since the selection color is White.
The blue channel for Z and B channels is now brighter because it was too dark on the dark background.

#jira UE-149063
#rb andrew.rodham, matt.hoffman
#preflight 6288345c95170b5599ffc30e

[CL 20335878 by Max Chen in ue5-main branch]
2022-05-23 15:39:25 -04:00

294 lines
7.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "CurveEditorSettings.h"
UCurveEditorSettings::UCurveEditorSettings()
{
bAutoFrameCurveEditor = true;
FrameInputPadding = 50;
FrameOutputPadding = 50;
bShowBufferedCurves = true;
bShowCurveEditorCurveToolTips = true;
TangentVisibility = ECurveEditorTangentVisibility::SelectedKeys;
ZoomPosition = ECurveEditorZoomPosition::CurrentTime;
bSnapTimeToSelection = false;
SelectionColor = FLinearColor::White;
ParentSpaceCustomColor = FLinearColor(.93, .31, .19); //pastel orange
WorldSpaceCustomColor = FLinearColor(.198, .610, .558); //pastel teal
}
bool UCurveEditorSettings::GetAutoFrameCurveEditor() const
{
return bAutoFrameCurveEditor;
}
void UCurveEditorSettings::SetAutoFrameCurveEditor(bool InbAutoFrameCurveEditor)
{
if (bAutoFrameCurveEditor != InbAutoFrameCurveEditor)
{
bAutoFrameCurveEditor = InbAutoFrameCurveEditor;
SaveConfig();
}
}
int32 UCurveEditorSettings::GetFrameInputPadding() const
{
return FrameInputPadding;
}
void UCurveEditorSettings::SetFrameInputPadding(int32 InFrameInputPadding)
{
if (FrameInputPadding != InFrameInputPadding)
{
FrameInputPadding = InFrameInputPadding;
SaveConfig();
}
}
int32 UCurveEditorSettings::GetFrameOutputPadding() const
{
return FrameOutputPadding;
}
void UCurveEditorSettings::SetFrameOutputPadding(int32 InFrameOutputPadding)
{
if (FrameOutputPadding != InFrameOutputPadding)
{
FrameOutputPadding = InFrameOutputPadding;
SaveConfig();
}
}
bool UCurveEditorSettings::GetShowBufferedCurves() const
{
return bShowBufferedCurves;
}
void UCurveEditorSettings::SetShowBufferedCurves(bool InbShowBufferedCurves)
{
if (bShowBufferedCurves != InbShowBufferedCurves)
{
bShowBufferedCurves = InbShowBufferedCurves;
SaveConfig();
}
}
bool UCurveEditorSettings::GetShowCurveEditorCurveToolTips() const
{
return bShowCurveEditorCurveToolTips;
}
void UCurveEditorSettings::SetShowCurveEditorCurveToolTips(bool InbShowCurveEditorCurveToolTips)
{
if (bShowCurveEditorCurveToolTips != InbShowCurveEditorCurveToolTips)
{
bShowCurveEditorCurveToolTips = InbShowCurveEditorCurveToolTips;
SaveConfig();
}
}
ECurveEditorTangentVisibility UCurveEditorSettings::GetTangentVisibility() const
{
return TangentVisibility;
}
void UCurveEditorSettings::SetTangentVisibility(ECurveEditorTangentVisibility InTangentVisibility)
{
if (TangentVisibility != InTangentVisibility)
{
TangentVisibility = InTangentVisibility;
SaveConfig();
}
}
ECurveEditorZoomPosition UCurveEditorSettings::GetZoomPosition() const
{
return ZoomPosition;
}
void UCurveEditorSettings::SetZoomPosition(ECurveEditorZoomPosition InZoomPosition)
{
if (ZoomPosition != InZoomPosition)
{
ZoomPosition = InZoomPosition;
SaveConfig();
}
}
bool UCurveEditorSettings::GetSnapTimeToSelection() const
{
return bSnapTimeToSelection;
}
void UCurveEditorSettings::SetSnapTimeToSelection(bool bInSnapTimeToSelection)
{
if (bSnapTimeToSelection != bInSnapTimeToSelection)
{
bSnapTimeToSelection = bInSnapTimeToSelection;
SaveConfig();
}
}
FLinearColor UCurveEditorSettings::GetSelectionColor() const
{
return SelectionColor;
}
void UCurveEditorSettings::SetSelectionColor(const FLinearColor& InColor)
{
if (SelectionColor != InColor)
{
SelectionColor = InColor;
SaveConfig();
}
}
TOptional<FLinearColor> UCurveEditorSettings::GetCustomColor(UClass* InClass, const FString& InPropertyName) const
{
TOptional<FLinearColor> Color;
for (const FCustomColorForChannel& CustomColor : CustomColors)
{
UClass* Class = CustomColor.Object.LoadSynchronous();
if (Class == InClass && CustomColor.PropertyName == InPropertyName)
{
Color = CustomColor.Color;
break;
}
}
return Color;
}
void UCurveEditorSettings::SetCustomColor(UClass* InClass, const FString& InPropertyName, FLinearColor InColor)
{
TOptional<FLinearColor> Color;
for (FCustomColorForChannel& CustomColor : CustomColors)
{
UClass* Class = CustomColor.Object.LoadSynchronous();
if (Class == InClass && CustomColor.PropertyName == InPropertyName)
{
CustomColor.Color = InColor;
SaveConfig();
return;
}
}
FCustomColorForChannel NewColor;
NewColor.Object = InClass;
NewColor.PropertyName = InPropertyName;
NewColor.Color = InColor;
CustomColors.Add(NewColor);
SaveConfig();
}
void UCurveEditorSettings::DeleteCustomColor(UClass* InClass, const FString& InPropertyName)
{
TOptional<FLinearColor> Color;
for (int32 Index = 0;Index < CustomColors.Num(); ++Index)
{
FCustomColorForChannel& CustomColor = CustomColors[Index];
UClass* Class = CustomColor.Object.LoadSynchronous();
if (Class == InClass && CustomColor.PropertyName == InPropertyName)
{
CustomColors.RemoveAt(Index);
SaveConfig();
return;
}
}
}
TOptional<FLinearColor> UCurveEditorSettings::GetSpaceSwitchColor(const FString& InControlName) const
{
TOptional<FLinearColor> Color;
if (InControlName == FString(TEXT("Parent")))
{
Color = ParentSpaceCustomColor;
}
else if(InControlName == FString(TEXT("World")))
{
Color = WorldSpaceCustomColor;
}
else
{
for (const FCustomColorForSpaceSwitch& CustomColor : ControlSpaceCustomColors)
{
if (CustomColor.ControlName == InControlName)
{
Color = CustomColor.Color;
break;
}
}
}
return Color;
}
void UCurveEditorSettings::SetSpaceSwitchColor(const FString& InControlName, FLinearColor InColor)
{
if (InControlName == FString(TEXT("Parent")))
{
ParentSpaceCustomColor = InColor;
SaveConfig();
}
else if (InControlName == FString(TEXT("World")))
{
WorldSpaceCustomColor = InColor;
SaveConfig();
}
else
{
TOptional<FLinearColor> Color;
for (FCustomColorForSpaceSwitch& CustomColor : ControlSpaceCustomColors)
{
if (CustomColor.ControlName == InControlName)
{
CustomColor.Color = InColor;
SaveConfig();
return;
}
}
FCustomColorForSpaceSwitch NewColor;
NewColor.ControlName = InControlName;
NewColor.Color = InColor;
ControlSpaceCustomColors.Add(NewColor);
SaveConfig();
}
}
void UCurveEditorSettings::DeleteSpaceSwitchColor(const FString& InControlName)
{
TOptional<FLinearColor> Color;
for (int32 Index = 0; Index < ControlSpaceCustomColors.Num(); ++Index)
{
FCustomColorForSpaceSwitch& CustomColor = ControlSpaceCustomColors[Index];
if (CustomColor.ControlName == InControlName)
{
ControlSpaceCustomColors.RemoveAt(Index);
SaveConfig();
return;
}
}
}
FLinearColor UCurveEditorSettings::GetNextRandomColor()
{
static TArray<FLinearColor> IndexedColor;
static int32 NextIndex = 0;
if (IndexedColor.Num() == 0)
{
IndexedColor.Add(FLinearColor(.904, .323, .539)); //pastel red
IndexedColor.Add(FLinearColor(552, .737, .328)); //pastel green
IndexedColor.Add(FLinearColor(.947, .418, .219)); //pastel orange
IndexedColor.Add(FLinearColor(.156, .624, .921)); //pastel blue
IndexedColor.Add(FLinearColor(.921, .314, .337));//pastel red 2
IndexedColor.Add(FLinearColor(.361, .651, .332)); //pastel green 2
IndexedColor.Add(FLinearColor(.982, .565, .254)); //pastel orange 2
IndexedColor.Add(FLinearColor(.246, .223, .514)); //pastel purple
IndexedColor.Add(FLinearColor(.208, .386, .687)); //pastel blue2
IndexedColor.Add(FLinearColor(.223, .59, .337)); //pastel green 3
IndexedColor.Add(FLinearColor(.230, .291, .591)); //pastel blue 3
}
FLinearColor Color = IndexedColor[NextIndex];
++NextIndex;
int32 NewIndex = (NextIndex % IndexedColor.Num());
NextIndex = NewIndex;
return Color;
}