Files
UnrealEngineUWP/Engine/Source/Developer/ToolWidgets/Private/SSegmentedTimelineView.cpp
Andrew Rodham 4ff7bab147 Slate: Initial phase of FVector2D deprecation
- Expanded FDeprecateSlateVector2D to provide structs for parameters, return types and member variables that use FVector2f, while still allowing conversion to/from FVector2d with optional per-module deprecation mechanisms.
  - Many of the high-traffic SlateCore types like FSlateBrush, FGeometry and FSlateLayoutTransform have been converted to use these deprecation mechanisms.
  - Some legacy FGeometry::ToPaintGeometry and MakeChild overloads have been explicitly deprecated since they cause ambiguous overloads with FSlateLayoutTransform if it were to support implicit construction.
  - Deprecated ULocalPlayer::GetPixelBoundingBox and GetPixelPoint to prefer FVector2f for OptionalAllotedSize parameter since this parameter is expected to come from FGeometry
  - Exposed FVector2f members to blueprints

#jira none
#rb Andy.Davidson, Dave.Jones, Vincent.Gauthier, Patrick.Boutot
#preflight 63bc6fd068068a8bd6027c9f

[CL 23631073 by Andrew Rodham in ue5-main branch]
2023-01-10 14:46:43 -05:00

62 lines
2.5 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "SSegmentedTimelineView.h"
#include "Rendering/DrawElements.h"
#include "SSimpleTimeSlider.h"
#define LOCTEXT_NAMESPACE "SSegmentedTimelineView"
void SSegmentedTimelineView::Construct(const SSegmentedTimelineView::FArguments& InArgs)
{
ViewRange = InArgs._ViewRange;
FillColor = InArgs._FillColor;
DesiredSize = InArgs._DesiredSize;
SegmentData = InArgs._SegmentData;
}
int32 SSegmentedTimelineView::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const
{
int32 NewLayer = PaintBlock(AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled);
return FMath::Max(NewLayer, SCompoundWidget::OnPaint(Args, AllottedGeometry, MyCullingRect, OutDrawElements, NewLayer, InWidgetStyle, ShouldBeEnabled(bParentEnabled)));
}
FVector2D SSegmentedTimelineView::ComputeDesiredSize(float) const
{
return DesiredSize.Get();
}
int32 SSegmentedTimelineView::PaintBlock(const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const
{
// convert time range to from rewind debugger times to profiler times
TRange<double> DebugTimeRange = ViewRange.Get();
FLinearColor Color = FillColor.Get();
SSimpleTimeSlider::FScrubRangeToScreen RangeToScreen(DebugTimeRange, AllottedGeometry.GetLocalSize());
FVector2D Size = AllottedGeometry.GetLocalSize();
if (TSharedPtr<FSegmentData> SegmentDataPtr = SegmentData.Get())
{
for (const TRange<double>& SegmentRange : SegmentDataPtr->Segments)
{
double LowerBound = SegmentRange.HasLowerBound() ? SegmentRange.GetLowerBoundValue() : 0;
double UpperBound = SegmentRange.HasUpperBound() ? SegmentRange.GetUpperBoundValue() : Size.X;
float BoxMin = FMath::Max(0, RangeToScreen.InputToLocalX(LowerBound));
float BoxMax = FMath::Min(Size.X, RangeToScreen.InputToLocalX(UpperBound));
FPaintGeometry BoxGeometry = AllottedGeometry.ToPaintGeometry(FVector2f(BoxMax - BoxMin, Size.Y - 2), FSlateLayoutTransform(FVector2f(BoxMin, 1.f)));
const FSlateBrush* Brush = FAppStyle::GetBrush("Sequencer.SectionArea.Background");
FSlateDrawElement::MakeBox(OutDrawElements, LayerId, BoxGeometry, Brush, ESlateDrawEffect::None, Color);
}
++LayerId;
}
return LayerId;
}
#undef LOCTEXT_NAMESPACE