Files
UnrealEngineUWP/Engine/Source/Editor/CurveEditor/Private/SCurveViewerPanel.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

92 lines
3.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "SCurveViewerPanel.h"
#include "Rendering/DrawElements.h"
#include "CurveDrawInfo.h"
#include "Styling/AppStyle.h"
#include "Misc/Attribute.h"
#include "CurveEditorScreenSpace.h"
#include "Views/SInteractiveCurveEditorView.h"
#define LOCTEXT_NAMESPACE "SCurveViewerPanel"
namespace CurveViewerConstants
{
static bool bAntiAliasCurves = true;
}
void SCurveViewerPanel::Construct(const FArguments& InArgs, TSharedRef<FCurveEditor> InCurveEditor)
{
WeakCurveEditor = InCurveEditor;
CurveThickness = InArgs._CurveThickness;
InCurveEditor->SetView(SharedThis(this));
for (const TPair<FCurveModelID, TUniquePtr<FCurveModel>>& CurvePair : InCurveEditor->GetCurves())
{
CurveInfoByID.Add(CurvePair.Key);
}
SetClipping(EWidgetClipping::ClipToBounds);
}
void SCurveViewerPanel::Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime)
{
CachedDrawParams.Reset();
GetCurveDrawParams(CachedDrawParams);
}
int32 SCurveViewerPanel::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const
{
const ESlateDrawEffect DrawEffects = ShouldBeEnabled(bParentEnabled) ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect;
DrawCurves(AllottedGeometry, OutDrawElements, LayerId, InWidgetStyle, DrawEffects);
return LayerId + CurveViewConstants::ELayerOffset::Last;
}
void SCurveViewerPanel::DrawCurves(const FGeometry& AllottedGeometry, FSlateWindowElementList& OutDrawElements, int32 BaseLayerId, const FWidgetStyle& InWidgetStyle, ESlateDrawEffect DrawEffects) const
{
const FPaintGeometry PaintGeometry = AllottedGeometry.ToPaintGeometry();
for (const FCurveDrawParams& Params : CachedDrawParams)
{
FSlateDrawElement::MakeLines(
OutDrawElements,
BaseLayerId + CurveViewConstants::ELayerOffset::Curves,
PaintGeometry,
Params.InterpolatingPoints,
DrawEffects,
Params.Color,
CurveViewerConstants::bAntiAliasCurves,
CurveThickness.Get()
);
if (Params.bKeyDrawEnabled)
{
for (int32 PointIndex = 0; PointIndex < Params.Points.Num(); PointIndex++)
{
const FCurvePointInfo& Point = Params.Points[PointIndex];
const FKeyDrawInfo& PointDrawInfo = Params.GetKeyDrawInfo(Point.Type, PointIndex);
const int32 KeyLayerId = BaseLayerId + Point.LayerBias + CurveViewConstants::ELayerOffset::Keys;
FLinearColor PointTint = PointDrawInfo.Tint.IsSet() ? PointDrawInfo.Tint.GetValue() : Params.Color;
// Brighten and saturate the points a bit so they pop
FLinearColor HSV = PointTint.LinearRGBToHSV();
HSV.G = FMath::Clamp(HSV.G * 1.1f, 0.f, 255.f);
HSV.B = FMath::Clamp(HSV.B * 2.f, 0.f, 255.f);
PointTint = HSV.HSVToLinearRGB();
FPaintGeometry PointGeometry = AllottedGeometry.ToPaintGeometry(
Point.ScreenPosition - (PointDrawInfo.ScreenSize * 0.5f),
PointDrawInfo.ScreenSize
);
FSlateDrawElement::MakeBox(OutDrawElements, KeyLayerId, PointGeometry, PointDrawInfo.Brush, DrawEffects, PointTint );
}
}
}
}
#undef LOCTEXT_NAMESPACE