242 lines
11 KiB
C++
242 lines
11 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "SStatsViewTooltip.h"
|
|
|
|
#include "EditorStyleSet.h"
|
|
#include "SlateOptMacros.h"
|
|
#include "TraceServices/Model/AnalysisSession.h"
|
|
#include "Widgets/Layout/SGridPanel.h"
|
|
#include "Widgets/Layout/SSeparator.h"
|
|
#include "Widgets/SBoxPanel.h"
|
|
#include "Widgets/SToolTip.h"
|
|
#include "Widgets/Text/STextBlock.h"
|
|
|
|
// Insights
|
|
#include "Insights/Common/TimeUtils.h"
|
|
#include "Insights/Table/ViewModels/Table.h"
|
|
#include "Insights/Table/ViewModels/TableColumn.h"
|
|
#include "Insights/ViewModels/StatsNode.h"
|
|
#include "Insights/ViewModels/StatsNodeHelper.h"
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#define LOCTEXT_NAMESPACE "SStatsView"
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
|
|
|
|
TSharedPtr<SToolTip> SStatsViewTooltip::GetTableTooltip(const Insights::FTable& Table)
|
|
{
|
|
TSharedPtr<SToolTip> ColumnTooltip =
|
|
SNew(SToolTip)
|
|
[SNew(SVerticalBox)
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(Table.GetDisplayName())
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.TooltipBold"))]
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(Table.GetDescription())
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.Tooltip"))]];
|
|
|
|
return ColumnTooltip;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
TSharedPtr<SToolTip> SStatsViewTooltip::GetColumnTooltip(const Insights::FTableColumn& Column)
|
|
{
|
|
TSharedPtr<SToolTip> ColumnTooltip =
|
|
SNew(SToolTip)
|
|
[SNew(SVerticalBox)
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(Column.GetTitleName())
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.TooltipBold"))]
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(Column.GetDescription())
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.Tooltip"))]];
|
|
|
|
return ColumnTooltip;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
TSharedPtr<SToolTip> SStatsViewTooltip::GetRowTooltip(const TSharedPtr<FStatsNode> StatsNodePtr)
|
|
{
|
|
const FText InstanceCountText = FText::AsNumber(StatsNodePtr->GetAggregatedStats().Count);
|
|
|
|
FText SumText = StatsNodePtr->GetTextForAggregatedStatsSum();
|
|
FText MinText = StatsNodePtr->GetTextForAggregatedStatsMin();
|
|
FText MaxText = StatsNodePtr->GetTextForAggregatedStatsMax();
|
|
FText AvgText = StatsNodePtr->GetTextForAggregatedStatsAverage();
|
|
FText MedText = StatsNodePtr->GetTextForAggregatedStatsMedian();
|
|
// FText LowText = StatsNodePtr->GetTextForAggregatedStatsLowerQuartile();
|
|
// FText UppText = StatsNodePtr->GetTextForAggregatedStatsUpperQuartile();
|
|
|
|
TSharedPtr<SGridPanel> GridPanel;
|
|
TSharedPtr<SHorizontalBox> HBox;
|
|
|
|
TSharedPtr<SToolTip> TableCellTooltip =
|
|
SNew(SToolTip)
|
|
[SAssignNew(HBox, SHorizontalBox)
|
|
|
|
+ SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
[SNew(SVerticalBox)
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SNew(SSeparator)
|
|
.Orientation(Orient_Horizontal)]
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SNew(SGridPanel)
|
|
|
|
// Id: [Id]
|
|
+ SGridPanel::Slot(0, 0)
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(LOCTEXT("TT_Id", "Id:"))
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.TooltipBold"))] +
|
|
SGridPanel::Slot(1, 0)
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(FText::AsNumber(StatsNodePtr->GetCounterId()))
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.Tooltip"))]
|
|
|
|
// Name: [Name]
|
|
+ SGridPanel::Slot(0, 1)
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(LOCTEXT("TT_Name", "Name:"))
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.TooltipBold"))] +
|
|
SGridPanel::Slot(1, 1)
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.WrapTextAt(512.0f)
|
|
.WrappingPolicy(ETextWrappingPolicy::AllowPerCharacterWrapping)
|
|
.Text(FText::FromName(StatsNodePtr->GetName()))
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.Tooltip"))]
|
|
|
|
// Counter Type: [Type]
|
|
+ SGridPanel::Slot(0, 3)
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(LOCTEXT("TT_Type", "Node Type:"))
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.TooltipBold"))] +
|
|
SGridPanel::Slot(1, 3)
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(StatsNodeTypeHelper::ToText(StatsNodePtr->GetType()))
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.Tooltip"))]
|
|
|
|
// Data Type: [DataType]
|
|
+ SGridPanel::Slot(0, 4)
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(LOCTEXT("TT_DataType", "Data Type:"))
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.TooltipBold"))] +
|
|
SGridPanel::Slot(1, 4)
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(StatsNodeDataTypeHelper::ToText(StatsNodePtr->GetDataType()))
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.Tooltip"))]]
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SNew(SSeparator)
|
|
.Orientation(Orient_Horizontal)]
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SNew(SGridPanel)
|
|
|
|
+ SGridPanel::Slot(0, 0)
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(LOCTEXT("TT_NumInstances", "Num Instances:"))
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.TooltipBold"))] +
|
|
SGridPanel::Slot(1, 0)
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(InstanceCountText)
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.Tooltip"))]]
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SNew(SSeparator)
|
|
.Orientation(Orient_Horizontal)]
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SAssignNew(GridPanel, SGridPanel)
|
|
|
|
// Aggregated stats are added here.
|
|
]
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SNew(SSeparator)
|
|
.Orientation(Orient_Horizontal)]]];
|
|
|
|
int32 Row = 1;
|
|
AddAggregatedStatsRow(GridPanel, Row, LOCTEXT("TT_Sum", "Sum:"), SumText);
|
|
AddAggregatedStatsRow(GridPanel, Row, LOCTEXT("TT_Max", "Max:"), MaxText);
|
|
// AddAggregatedStatsRow(GridPanel, Row, LOCTEXT("TT_UpperQ", "Upper Quartile:"), UppText);
|
|
AddAggregatedStatsRow(GridPanel, Row, LOCTEXT("TT_Average", "Average:"), AvgText);
|
|
AddAggregatedStatsRow(GridPanel, Row, LOCTEXT("TT_Median", "Median:"), MedText);
|
|
// AddAggregatedStatsRow(GridPanel, Row, LOCTEXT("TT_LowerQ", "Lower Quartile:"), LowText);
|
|
AddAggregatedStatsRow(GridPanel, Row, LOCTEXT("TT_Min", "Min:"), MinText);
|
|
|
|
return TableCellTooltip;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
void SStatsViewTooltip::AddAggregatedStatsRow(TSharedPtr<SGridPanel> Grid, int32& Row, const FText& Name, const FText& Value)
|
|
{
|
|
Grid->AddSlot(0, Row)
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(Name)
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.TooltipBold"))];
|
|
|
|
Grid->AddSlot(1, Row)
|
|
.Padding(2.0f)
|
|
.HAlign(HAlign_Right)
|
|
[SNew(STextBlock)
|
|
.Text(Value)
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.Tooltip"))];
|
|
|
|
Row++;
|
|
}
|
|
|
|
END_SLATE_FUNCTION_BUILD_OPTIMIZATION
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#undef LOCTEXT_NAMESPACE
|