// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "Async/TaskTrace.h" // TraceServices #include "TraceServices/Model/TasksProfiler.h" // TraceInsights #include "Insights/Table/Widgets/SSessionTableTreeView.h" #include "Insights/TaskGraphProfiler/ViewModels/TaskTable.h" class FMenuBuilder; namespace UE::Insights::TaskGraphProfiler { //////////////////////////////////////////////////////////////////////////////////////////////////// class STaskTableTreeView : public SSessionTableTreeView { private: struct FColumnConfig { const FName& ColumnId; bool bIsVisible; float Width; }; enum class ETimestampOptions : uint32 { Absolute, RelativeToPrevious, RelativeToCreated, }; public: /** Default constructor. */ STaskTableTreeView(); /** Virtual destructor. */ virtual ~STaskTableTreeView(); SLATE_BEGIN_ARGS(STaskTableTreeView) {} SLATE_END_ARGS() /** * Construct this widget * @param InArgs - The declaration data for this widget */ void Construct(const FArguments& InArgs, TSharedPtr InTablePtr); void ConstructHeaderArea(TSharedRef InWidgetContent) override; virtual TSharedPtr ConstructFooter() override; TSharedPtr GetTaskTable() { return StaticCastSharedPtr(GetTable()); } const TSharedPtr GetTaskTable() const { return StaticCastSharedPtr(GetTable()); } //void UpdateSourceTable(TSharedPtr SourceTable); virtual void Reset(); /** * Ticks this widget. Override in derived classes, but always call the parent implementation. * * @param AllottedGeometry The space allotted for this widget * @param InCurrentTime Current absolute real time * @param InDeltaTime Real time passed since last tick */ virtual void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override; /** * Rebuilds the tree (if necessary). * @param bResync - If true, it forces a resync even if the list did not changed since last sync. */ virtual void RebuildTree(bool bResync); //////////////////////////////////////////////////////////////////////////////////////////////////// // IAsyncOperationStatusProvider implementation virtual bool IsRunning() const override; virtual double GetAllOperationsDuration() override; virtual FText GetCurrentOperationName() const override; //////////////////////////////////////////////////////////////////////////////////////////////////// virtual void TreeView_OnMouseButtonDoubleClick(FTableTreeNodePtr TreeNode) override; void SelectTaskEntry(TaskTrace::FId InId); protected: virtual void InternalCreateGroupings() override; virtual void ExtendMenu(FMenuBuilder& MenuBuilder) override; virtual void SearchForItem(TSharedPtr CancellationToken) override; private: void AddCommmands(); const TArray>* GetAvailableTimestampOptions(); TSharedRef TimestampOptions_OnGenerateWidget(TSharedPtr InOption); void TimestampOptions_OnSelectionChanged(TSharedPtr InOption, ESelectInfo::Type SelectInfo); void TimestampOptions_OnSelectionChanged(ETimestampOptions InOption); FText TimestampOptions_GetSelectionText() const; FText TimestampOptions_GetText(ETimestampOptions InOption) const; bool TimestampOptions_IsEnabled() const; const TArray>* GetAvailableTasksSelectionOptions(); TSharedRef TasksSelectionOptions_OnGenerateWidget(TSharedPtr InOption); void TasksSelectionOptions_OnSelectionChanged(TSharedPtr InOption, ESelectInfo::Type SelectInfo); void TasksSelectionOptions_OnSelectionChanged(TraceServices::ETaskEnumerationOption InOption); FText TasksSelectionOptions_GetSelectionText() const; FText TasksSelectionOptions_GetText(TraceServices::ETaskEnumerationOption InOption) const; bool TasksSelectionOptions_IsEnabled() const; bool ContextMenu_GoToTask_CanExecute() const; void ContextMenu_GoToTask_Execute(); bool ContextMenu_OpenInIDE_CanExecute() const; void ContextMenu_OpenInIDE_Execute(); bool GetSourceFileAndLineForSelectedTask(FString& OutFile, uint32& OutLine) const; private: double QueryStartTime = 0.0f; double QueryEndTime = 0.0f; ETimestampOptions SelectedTimestampOption = ETimestampOptions::RelativeToPrevious; TArray> AvailableTimestampOptions; TraceServices::ETaskEnumerationOption SelectedTasksSelectionOption = TraceServices::ETaskEnumerationOption::Alive; TArray> AvailableTasksSelectionOptions; TaskTrace::FId TaskIdToSelect; }; //////////////////////////////////////////////////////////////////////////////////////////////////// } // namespace UE::Insights::TaskGraphProfiler