You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#preflight 6272a74d2f6d177be3c6fdda #rb Matt.Kuhlenschmidt #ROBOMERGE-OWNER: Lauren.Barnes #ROBOMERGE-AUTHOR: lauren.barnes #ROBOMERGE-SOURCE: CL 20057269 via CL 20070159 via CL 20072035 via CL 20072203 #ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v943-19904690) #ROBOMERGE-CONFLICT from-shelf [CL 20105363 by Lauren Barnes in ue5-main branch]
148 lines
5.2 KiB
C++
148 lines
5.2 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "SCurveEditorEventChannelView.h"
|
|
#include "Rendering/DrawElements.h"
|
|
#include "Fonts/FontMeasure.h"
|
|
#include "Styling/CoreStyle.h"
|
|
#include "CurveEditor.h"
|
|
#include "Styling/AppStyle.h"
|
|
#include "CurveModel.h"
|
|
#include "ICurveEditorBounds.h"
|
|
#include "CurveEditorScreenSpace.h"
|
|
#include "CurveDataAbstraction.h"
|
|
#include "CurveDrawInfo.h"
|
|
|
|
float SCurveEditorEventChannelView::TrackHeight = 24.f;
|
|
|
|
void SCurveEditorEventChannelView::Construct(const FArguments& InArgs, TWeakPtr<FCurveEditor> InCurveEditor)
|
|
{
|
|
bFixedOutputBounds = true;
|
|
OutputMin = -0.5;
|
|
OutputMax = 0.5;
|
|
WeakCurveEditor = InCurveEditor;
|
|
SortBias = 25;
|
|
|
|
SInteractiveCurveEditorView::Construct(InArgs, InCurveEditor);
|
|
}
|
|
|
|
FVector2D SCurveEditorEventChannelView::ComputeDesiredSize(float LayoutScaleMultiplier) const
|
|
{
|
|
return FVector2D(100.f, TrackHeight * (CurveInfoByID.Num()));
|
|
}
|
|
|
|
void SCurveEditorEventChannelView::GetGridLinesY(TSharedRef<const FCurveEditor> CurveEditor, TArray<float>& MajorGridLines, TArray<float>& MinorGridLines, TArray<FText>* MajorGridLabels) const
|
|
{}
|
|
|
|
void SCurveEditorEventChannelView::Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime)
|
|
{
|
|
TSharedPtr<FCurveEditor> CurveEditor = WeakCurveEditor.Pin();
|
|
if (!CurveEditor)
|
|
{
|
|
return;
|
|
}
|
|
|
|
double Count = 0.0;
|
|
for (auto It = CurveInfoByID.CreateIterator(); It; ++It)
|
|
{
|
|
FCurveModel* Curve = CurveEditor->FindCurve(It.Key());
|
|
if (ensureAlways(Curve))
|
|
{
|
|
It->Value.ViewToCurveTransform = FTransform2D(FVector2D(0.f, Count));
|
|
}
|
|
|
|
Count += 1.0;
|
|
}
|
|
|
|
OutputMin = OutputMax - FMath::Max(Count, 1e-10);
|
|
SInteractiveCurveEditorView::Tick(AllottedGeometry, InCurrentTime, InDeltaTime);
|
|
}
|
|
|
|
void SCurveEditorEventChannelView::PaintView(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 BaseLayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const
|
|
{
|
|
TSharedPtr<FCurveEditor> CurveEditor = WeakCurveEditor.Pin();
|
|
if (CurveEditor)
|
|
{
|
|
const ESlateDrawEffect DrawEffects = ShouldBeEnabled(bParentEnabled) ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect;
|
|
|
|
DrawBackground(AllottedGeometry, OutDrawElements, BaseLayerId, DrawEffects);
|
|
DrawLabels(AllottedGeometry, OutDrawElements, BaseLayerId, DrawEffects);
|
|
DrawGridLines(CurveEditor.ToSharedRef(), AllottedGeometry, OutDrawElements, BaseLayerId, DrawEffects);
|
|
DrawCurves(CurveEditor.ToSharedRef(), AllottedGeometry, MyCullingRect, OutDrawElements, BaseLayerId, InWidgetStyle, DrawEffects);
|
|
}
|
|
}
|
|
|
|
void SCurveEditorEventChannelView::DrawLabels(const FGeometry& AllottedGeometry, FSlateWindowElementList& OutDrawElements, int32 BaseLayerId, ESlateDrawEffect DrawEffects) const
|
|
{
|
|
TSharedPtr<FCurveEditor> CurveEditor = WeakCurveEditor.Pin();
|
|
if (!CurveEditor)
|
|
{
|
|
return;
|
|
}
|
|
|
|
const FSlateBrush* WhiteBrush = FAppStyle::GetBrush("WhiteBrush");
|
|
|
|
// Draw some text telling the user how to get retime anchors.
|
|
const FSlateFontInfo FontInfo = FCoreStyle::Get().GetFontStyle("ToolTip.LargerFont");
|
|
|
|
// We have to measure the string so we can draw it centered on the window.
|
|
const TSharedRef<FSlateFontMeasure> FontMeasure = FSlateApplication::Get().GetRenderer()->GetFontMeasureService();
|
|
|
|
const FVector2D LocalSize = AllottedGeometry.GetLocalSize();
|
|
|
|
const FCurveEditorScreenSpaceV ViewSpace = GetViewSpace();
|
|
|
|
for (auto It = CurveInfoByID.CreateConstIterator(); It; ++It)
|
|
{
|
|
FCurveModel* Curve = CurveEditor->FindCurve(It.Key());
|
|
if (!ensureAlways(Curve))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
const int32 CurveIndex = static_cast<int32>(It->Value.ViewToCurveTransform.GetTranslation().Y);
|
|
|
|
const FCurveEditorScreenSpaceV CurveSpace = ViewSpace.ToCurveSpace(It->Value.ViewToCurveTransform);
|
|
const float LaneTop = CurveSpace.ValueToScreen(0.0) - TrackHeight*.5f;
|
|
|
|
// Draw the curve color as the background. Event curves set their track color as the curve color.
|
|
FLinearColor CurveColor = Curve->GetColor();
|
|
|
|
// Alpha blend the zebra tint
|
|
if (CurveIndex%2)
|
|
{
|
|
static FLinearColor ZebraTint = FLinearColor::White.CopyWithNewOpacity(0.01f);
|
|
if (CurveColor == FLinearColor::White)
|
|
{
|
|
CurveColor = ZebraTint;
|
|
}
|
|
else
|
|
{
|
|
CurveColor = CurveColor * (1.f - ZebraTint.A) + ZebraTint * ZebraTint.A;
|
|
}
|
|
}
|
|
|
|
if (CurveColor != FLinearColor::White)
|
|
{
|
|
const FPaintGeometry BoxGeometry = AllottedGeometry.ToPaintGeometry(
|
|
FVector2D(AllottedGeometry.GetLocalSize().X, TrackHeight),
|
|
FSlateLayoutTransform(FVector2D(0.f, LaneTop))
|
|
);
|
|
|
|
FSlateDrawElement::MakeBox(OutDrawElements, BaseLayerId + CurveViewConstants::ELayerOffset::Background, BoxGeometry, WhiteBrush, DrawEffects, CurveColor);
|
|
}
|
|
|
|
// Draw the curve label
|
|
{
|
|
const FText Label = Curve->GetLongDisplayName();
|
|
|
|
const FVector2D TextSize = FontMeasure->Measure(Label, FontInfo);
|
|
const FVector2D Position(LocalSize.X - TextSize.X - CurveViewConstants::CurveLabelOffsetX, LaneTop + (TrackHeight - TextSize.Y)*.5f);
|
|
|
|
const FPaintGeometry LabelGeometry = AllottedGeometry.ToPaintGeometry(
|
|
FSlateLayoutTransform(Position)
|
|
);
|
|
|
|
FSlateDrawElement::MakeText(OutDrawElements, BaseLayerId + CurveViewConstants::ELayerOffset::Labels, LabelGeometry, Label, FontInfo, DrawEffects, FLinearColor::White);
|
|
}
|
|
}
|
|
} |