2019-12-26 15:33:43 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2019-05-29 15:56:46 -04:00
|
|
|
|
|
|
|
|
#include "CommonMovieSceneTools.h"
|
2022-08-24 22:45:13 -04:00
|
|
|
|
|
|
|
|
#include "Containers/UnrealString.h"
|
|
|
|
|
#include "Fonts/FontMeasure.h"
|
|
|
|
|
#include "Fonts/SlateFontInfo.h"
|
2021-11-18 14:37:34 -05:00
|
|
|
#include "FrameNumberNumericInterface.h"
|
2019-05-29 15:56:46 -04:00
|
|
|
#include "Framework/Application/SlateApplication.h"
|
2022-08-24 22:45:13 -04:00
|
|
|
#include "Layout/Geometry.h"
|
|
|
|
|
#include "Math/Color.h"
|
|
|
|
|
#include "Math/Vector2D.h"
|
|
|
|
|
#include "Misc/FrameNumber.h"
|
|
|
|
|
#include "Rendering/DrawElements.h"
|
|
|
|
|
#include "Rendering/RenderingCommon.h"
|
|
|
|
|
#include "Rendering/SlateRenderer.h"
|
2019-05-29 15:56:46 -04:00
|
|
|
#include "SequencerSectionPainter.h"
|
2022-08-24 22:45:13 -04:00
|
|
|
#include "Styling/AppStyle.h"
|
|
|
|
|
#include "Styling/CoreStyle.h"
|
|
|
|
|
#include "Styling/SlateColor.h"
|
|
|
|
|
#include "Styling/WidgetStyle.h"
|
|
|
|
|
#include "Templates/SharedPointer.h"
|
|
|
|
|
#include "TimeToPixel.h"
|
2019-05-29 15:56:46 -04:00
|
|
|
|
2021-11-18 14:37:34 -05:00
|
|
|
void DrawFrameTimeHint(FSequencerSectionPainter& InPainter, const FFrameTime& CurrentTime, const FFrameTime& FrameTime, const FFrameNumberInterface* FrameNumberInterface)
|
2019-05-29 15:56:46 -04:00
|
|
|
{
|
2021-11-18 14:37:34 -05:00
|
|
|
FString FrameTimeString;
|
|
|
|
|
if (FrameNumberInterface)
|
|
|
|
|
{
|
|
|
|
|
FrameTimeString = FrameNumberInterface->ToString(FrameTime.AsDecimal());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FrameTimeString = FString::FromInt(FrameTime.GetFrame().Value);
|
|
|
|
|
}
|
2019-05-29 15:56:46 -04:00
|
|
|
|
|
|
|
|
const FSlateFontInfo SmallLayoutFont = FCoreStyle::GetDefaultFontStyle("Bold", 10);
|
|
|
|
|
const TSharedRef< FSlateFontMeasure > FontMeasureService = FSlateApplication::Get().GetRenderer()->GetFontMeasureService();
|
2021-11-18 14:37:34 -05:00
|
|
|
FVector2D TextSize = FontMeasureService->Measure(FrameTimeString, SmallLayoutFont);
|
2019-05-29 15:56:46 -04:00
|
|
|
|
|
|
|
|
const float PixelX = InPainter.GetTimeConverter().FrameToPixel(CurrentTime);
|
|
|
|
|
|
|
|
|
|
// Flip the text position if getting near the end of the view range
|
|
|
|
|
static const float TextOffsetPx = 10.f;
|
|
|
|
|
bool bDrawLeft = (InPainter.SectionGeometry.Size.X - PixelX) < (TextSize.X + 22.f) - TextOffsetPx;
|
|
|
|
|
float TextPosition = bDrawLeft ? PixelX - TextSize.X - TextOffsetPx : PixelX + TextOffsetPx;
|
|
|
|
|
//handle mirrored labels
|
|
|
|
|
const float MajorTickHeight = 9.0f;
|
|
|
|
|
FVector2D TextOffset(TextPosition, InPainter.SectionGeometry.Size.Y - (MajorTickHeight + TextSize.Y));
|
|
|
|
|
|
2022-05-09 13:12:28 -04:00
|
|
|
const FLinearColor DrawColor = FAppStyle::GetSlateColor("SelectionColor").GetColor(FWidgetStyle()).CopyWithNewOpacity(InPainter.GhostAlpha);
|
2019-05-29 15:56:46 -04:00
|
|
|
const FVector2D BoxPadding = FVector2D(4.0f, 2.0f);
|
|
|
|
|
// draw time string
|
|
|
|
|
|
|
|
|
|
FSlateDrawElement::MakeBox(
|
|
|
|
|
InPainter.DrawElements,
|
|
|
|
|
InPainter.LayerId + 5,
|
2023-01-10 14:46:43 -05:00
|
|
|
InPainter.SectionGeometry.ToPaintGeometry(TextSize + 2.0f * BoxPadding, FSlateLayoutTransform(TextOffset - BoxPadding)),
|
2022-05-09 13:12:28 -04:00
|
|
|
FAppStyle::GetBrush("WhiteBrush"),
|
2019-05-29 15:56:46 -04:00
|
|
|
ESlateDrawEffect::None,
|
2020-10-09 22:42:26 -04:00
|
|
|
FLinearColor::Black.CopyWithNewOpacity(0.5f * InPainter.GhostAlpha)
|
2019-05-29 15:56:46 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
ESlateDrawEffect DrawEffects = InPainter.bParentEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect;
|
|
|
|
|
|
|
|
|
|
FSlateDrawElement::MakeText(
|
|
|
|
|
InPainter.DrawElements,
|
|
|
|
|
InPainter.LayerId + 6,
|
2023-01-10 14:46:43 -05:00
|
|
|
InPainter.SectionGeometry.ToPaintGeometry(TextSize, FSlateLayoutTransform(TextOffset)),
|
2021-11-18 14:37:34 -05:00
|
|
|
FrameTimeString,
|
2019-05-29 15:56:46 -04:00
|
|
|
SmallLayoutFont,
|
|
|
|
|
DrawEffects,
|
|
|
|
|
DrawColor
|
|
|
|
|
);
|
2021-11-18 14:37:34 -05:00
|
|
|
}
|