Files
UnrealEngineUWP/Engine/Source/Editor/MovieSceneTools/Private/CommonMovieSceneTools.cpp
Lauren Barnes 6248f8d412 Replacing legacy EditorStyle calls with AppStyle
#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]
2022-05-09 13:12:28 -04:00

61 lines
2.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "CommonMovieSceneTools.h"
#include "FrameNumberNumericInterface.h"
#include "Framework/Application/SlateApplication.h"
#include "Styling/AppStyle.h"
#include "Fonts/FontMeasure.h"
#include "SequencerSectionPainter.h"
void DrawFrameTimeHint(FSequencerSectionPainter& InPainter, const FFrameTime& CurrentTime, const FFrameTime& FrameTime, const FFrameNumberInterface* FrameNumberInterface)
{
FString FrameTimeString;
if (FrameNumberInterface)
{
FrameTimeString = FrameNumberInterface->ToString(FrameTime.AsDecimal());
}
else
{
FrameTimeString = FString::FromInt(FrameTime.GetFrame().Value);
}
const FSlateFontInfo SmallLayoutFont = FCoreStyle::GetDefaultFontStyle("Bold", 10);
const TSharedRef< FSlateFontMeasure > FontMeasureService = FSlateApplication::Get().GetRenderer()->GetFontMeasureService();
FVector2D TextSize = FontMeasureService->Measure(FrameTimeString, SmallLayoutFont);
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));
const FLinearColor DrawColor = FAppStyle::GetSlateColor("SelectionColor").GetColor(FWidgetStyle()).CopyWithNewOpacity(InPainter.GhostAlpha);
const FVector2D BoxPadding = FVector2D(4.0f, 2.0f);
// draw time string
FSlateDrawElement::MakeBox(
InPainter.DrawElements,
InPainter.LayerId + 5,
InPainter.SectionGeometry.ToPaintGeometry(TextOffset - BoxPadding, TextSize + 2.0f * BoxPadding),
FAppStyle::GetBrush("WhiteBrush"),
ESlateDrawEffect::None,
FLinearColor::Black.CopyWithNewOpacity(0.5f * InPainter.GhostAlpha)
);
ESlateDrawEffect DrawEffects = InPainter.bParentEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect;
FSlateDrawElement::MakeText(
InPainter.DrawElements,
InPainter.LayerId + 6,
InPainter.SectionGeometry.ToPaintGeometry(TextOffset, TextSize),
FrameTimeString,
SmallLayoutFont,
DrawEffects,
DrawColor
);
}