UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AudioDebugDraw.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CanvasTypes.h"
6#include "Engine/Font.h"
7#include "Engine/Engine.h"
8
9namespace Audio
10{
12 {
13 public:
15
16 void Draw(FCanvas* Canvas, int32 X, int32 Y) const
17 {
18 DrawHeaders(Canvas,X,Y, HeaderColor);
19 Y+=Font->GetMaxCharHeight();
20 DrawRows(Canvas,X,Y, RowColor);
21 }
22
24 void AddRow(const TArray<FItem>& Items)
25 {
26 for(int32 i = 0; i < Items.Num(); ++i)
27 {
28 if (Cols.IsValidIndex(i))
29 {
30 Cols[i].Items.Add(Items[i].Text);
31 Cols[i].Colors.Add(Items[i].Color);
32 }
33 }
34 }
35 void AddCol(FString Text, int32 WidthInChars=0)
36 {
38 Text=Text.LeftPad(WidthInChars);
39 int32 X,Y;
40 StringSize(Font, X, Y, *Text);
41 Cols.Add({Text, X});
42 }
43 private:
44 struct FCol
45 {
46 FString Header;
47 int32 Width = 32;
48 TArray<FString> Items;
50 };
51 TArray<FCol> Cols;
52 FColor HeaderColor = FColor::White;
53 FColor RowColor = FColor::Green;
54 const UFont* Font = UEngine::GetTinyFont();
55
56 void RightJustify(FCanvas* Canvas, const int32 X, const int32 Y, const int32 InterColumnOffset, TCHAR const* Text, FLinearColor const& Color) const
57 {
58 int32 SizeX, SizeY;
59 StringSize(Font, SizeX, SizeY, Text);
60 Canvas->DrawShadowedString(X + InterColumnOffset - SizeX, Y, Text, Font, Color);
61 }
62 void DrawHeaders(FCanvas* Canvas, int32 X, int32 Y,const FLinearColor& Color) const
63 {
64 for (const FCol& i : Cols)
65 {
66 RightJustify(Canvas,X,Y,i.Width,*i.Header, Color);
67 X += i.Width;
68 }
69 }
70 void DrawRows(FCanvas* Canvas, const int32 InX, const int32 InY,const FLinearColor& Color) const
71 {
72 int32 Line=0;
73 const int32 MaxY = Canvas->GetParentCanvasSize().Y;
74 for (int32 Y=InY; Y < MaxY; Y+=Font->GetMaxCharHeight(), ++Line)
75 {
76 // Draw row.
77 int32 X=InX;
78 for (const FCol& i : Cols)
79 {
80 const FLinearColor C = i.Colors.IsValidIndex(Line) ? i.Colors[Line] : Color;
81 if (i.Items.IsValidIndex(Line))
82 {
83 RightJustify(Canvas,X,Y,i.Width,*i.Items[Line], C);
84 }
85 X += i.Width;
86 }
87 }
88 }
89 };
90}
ENGINE_API void StringSize(const UFont *Font, int32 &XL, int32 &YL, FStringView Text)
Definition Canvas.cpp:1181
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define X(Name, Desc)
Definition FormatStringSan.h:47
Definition AudioDebugDraw.h:12
void Draw(FCanvas *Canvas, int32 X, int32 Y) const
Definition AudioDebugDraw.h:16
void AddRow(const TArray< FItem > &Items)
Definition AudioDebugDraw.h:24
void AddCol(FString Text, int32 WidthInChars=0)
Definition AudioDebugDraw.h:35
Definition CanvasTypes.h:211
ENGINE_API int32 DrawShadowedString(double StartX, double StartY, FStringView Text, const UFont *Font, const FLinearColor &Color, const FLinearColor &ShadowColor=FLinearColor::Black)
Definition Canvas.cpp:1130
FIntPoint GetParentCanvasSize() const
Definition CanvasTypes.h:603
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
UE_NODEBUG UE_FORCEINLINE_HINT bool IsValidIndex(SizeType Index) const
Definition Array.h:1122
static ENGINE_API class UFont * GetTinyFont()
Definition UnrealEngine.cpp:3843
Definition Font.h:111
ENGINE_API float GetMaxCharHeight() const
Definition Font.cpp:286
NO_LOGGING.
Definition AudioMixerPlatformAndroid.cpp:53
Definition AudioDebugDraw.h:23
FLinearColor Color
Definition AudioDebugDraw.h:23
FString Text
Definition AudioDebugDraw.h:23
Definition Color.h:486
static CORE_API const FColor White
Definition Color.h:749
static CORE_API const FColor Green
Definition Color.h:753
Definition Color.h:48
IntType Y
Definition IntPoint.h:37