Files
UnrealEngineUWP/Engine/Source/Developer/TaskGraph/Public/SBarVisualizer.h

290 lines
8.5 KiB
C
Raw Normal View History

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
#include "CoreMinimal.h"
#include "Layout/Visibility.h"
#include "Layout/Geometry.h"
#include "Input/Reply.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "Widgets/SCompoundWidget.h"
#include "VisualizerEvents.h"
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
#include "Widgets/Views/STableViewBase.h"
#include "Widgets/Views/STableRow.h"
class SGraphBar;
class SScrollBar;
class STextBlock;
class STimeline;
/**
* Bars Visualizer. Contains a list of bars for each profiler category
*/
class TASKGRAPH_API SBarVisualizer : public SCompoundWidget
{
public:
/** Delegate used when bar graph selection changes */
DECLARE_DELEGATE_OneParam( FOnBarGraphSelectionChanged, TSharedPtr< FVisualizerEvent > );
/** Delegate used when bar graph expansion changes */
DECLARE_DELEGATE_OneParam( FOnBarGraphExpansionChanged, TSharedPtr< FVisualizerEvent > );
/** Delegate used when a single event on the bar graph is selected */
DECLARE_DELEGATE_TwoParams( FOnBarEventSelectionChanged, int32, TSharedPtr< FVisualizerEvent > );
/** Delegate used when the user right-clicks on a bar graph */
DECLARE_DELEGATE_TwoParams( FOnBarGraphContextMenu, TSharedPtr< FVisualizerEvent >, const FPointerEvent& );
SLATE_BEGIN_ARGS( SBarVisualizer )
: _ProfileData()
, _OnBarGraphSelectionChanged()
, _OnBarGraphExpansionChanged()
, _OnBarEventSelectionChanged()
, _OnBarGraphContextMenu()
{}
/** Profiler results */
SLATE_ATTRIBUTE( TSharedPtr< FVisualizerEvent >, ProfileData )
/** Callback triggered when bar graph selection changes */
SLATE_EVENT( FOnBarGraphSelectionChanged, OnBarGraphSelectionChanged )
/** Callback triggered when bar graph expansion changes */
SLATE_EVENT( FOnBarGraphExpansionChanged, OnBarGraphExpansionChanged )
/** Callback triggered when single event on the bar graph is selected */
SLATE_EVENT( FOnBarEventSelectionChanged, OnBarEventSelectionChanged )
/** Callback triggered when the user right-clicks on a bar graph */
SLATE_EVENT( FOnBarGraphContextMenu, OnBarGraphContextMenu )
SLATE_END_ARGS()
/**
* Construct the widget
*
* @param InArgs A declaration from which to construct the widget
*/
void Construct( const FArguments& InArgs );
/**
* Handles selection change in the events tree
*
* @param Selection selected event
*/
void HandleEventSelectionChanged( TSharedPtr< FVisualizerEvent > Selection );
protected:
/**
* Gets the maximum scroll offset fraction value for the horizontal scrollbar
*
* @return Maximum scroll offset fraction
*/
float GetMaxScrollOffsetFraction() const
{
return 1.0f - 1.0f / GetZoom();
}
/**
* Gets the maximum graph offset value for the graph bars
*
* @return Maximum graph offset
*/
float GetMaxGraphOffset() const
{
return GetZoom() - 1.0f;
}
/**
* Gets the actual zoom level for the graph bars
*
* @return Zoom level
*/
float GetZoom() const
{
const float MinZoom = 1.0f;
const float MaxZoom = 20.0f;
return MinZoom + ZoomSliderValue * ( MaxZoom - MinZoom );
}
/**
* Callback for scrolling the horizontal scrollbar
*
* @param InScrollOffsetFraction Scrollbar offset fraction
*/
void ScrollBar_OnUserScrolled( float InScrollOffsetFraction );
/**
* Constructs the zoom label string based on the current zoom level value.
*
* @return Zoom label text
*/
FText GetZoomLabel() const;
/**
* Callback used to get the current zoom slider value.
*
* @return Zoom slider value
*/
float GetZoomValue() const;
/**
* Callback used to handle zoom slider
*
* @param NewValue New Zoom slider value
*/
void OnSetZoomValue( float NewValue );
/**
* Function called when the currently selected bar graph changes
*
* @param Selection Currently selected thread events
* @param SelectInfo Provides context on how the selection changed
*/
void OnBarGraphSelectionChanged( TSharedPtr< FVisualizerEvent > Selection, ESelectInfo::Type SelectInfo );
/**
* Function called when the user selects an event bar in the graph
*
* @param Selection Currently selected event
* @param SelectInfo Provides context on how the selection changed
*/
void OnBarEventSelectionChanged( TSharedPtr< FVisualizerEvent > Selection, ESelectInfo::Type SelectInfo, int32 BarId );
/**
* Generates SGraphBar widget for the threads list
*
* @param InItem Graph profile events
* @param OwnerTable Onwer Table
*/
TSharedRef<ITableRow> OnGenerateWidgetForList( TSharedPtr< FVisualizerEvent > InItem, const TSharedRef< STableViewBase >& OwnerTable );
/**
* Generates children for the specified tree view item
*
* @param InItem Graph profile events
* @param OutChildren child graphs
*/
void OnGetChildrenForList( TSharedPtr<FVisualizerEvent> InItem, TArray<TSharedPtr<FVisualizerEvent> >& OutChildren);
/**
* Forwards right-click event to the visualizer main frame
*
* @param BarGeometry Graph bar geometry
* @param MouseEvent Current mouse event
* @param Selection Selected events
*/
FReply OnBarRightClicked( const FGeometry& BarGeometry, const FPointerEvent& MouseEvent, TSharedPtr<FVisualizerEvent> Selection );
/**
* Recursively clears selection on all bar graphs
*
* @param GraphEvents Bar Graph events
* @param Selection Currently selected event
*/
void ClearBarSelection( TSharedPtr< FVisualizerEvent > GraphEvents, TSharedPtr<FVisualizerEvent> Selection );
/** Creates filtered data */
void CreateDataView();
/** Creates flattened data view */
void CreateFlattenedData( TSharedPtr< FVisualizerEvent > InData, TArray< TSharedPtr< FVisualizerEvent > >& FlattenedData );
/**
* Sets the current view mode
*
* @param InMode New view mode
*/
void SetViewMode( EVisualizerViewMode::Type InMode );
/**
* Given a view mode checks if it's the currently selected one
*
* @param InMode View mode to check
*/
bool CheckViewMode( EVisualizerViewMode::Type InMode ) const
{
return (ViewMode == InMode);
}
/** Handles clicking on 'Back to parent' button */
FReply OnToParentClicked();
/** Handles clickong on 'Home' button */
FReply OnHomeClicked();
/** Called when bar graph geometry (size) changes */
void OnBarGeometryChanged( FGeometry Geometry );
/** Gets the currently displayed hierarchy node name */
FText GetSelectedCategoryName() const;
/** Checks if home button should be visible */
EVisibility GetHomeButtonVisibility() const;
/** Checks if 'to parent' button should be visible */
EVisibility GetToParentButtonVisibility() const;
/** Called when the user clicked bar graph's expand button */
FReply ExpandBar( TSharedPtr<FVisualizerEvent> BarGraphEvents );
/** Checks if the selected event has children with children */
bool IsExpandable( TSharedPtr< FVisualizerEvent > InEvent );
/** Adjusts timeline to match the selected event's start and duration */
void AdjustTimeline( TSharedPtr< FVisualizerEvent > InEvent );
TSharedPtr< FVisualizerEvent > FindSelectedEventsParent( TArray< TSharedPtr< FVisualizerEvent > >& BarGraphs, TSharedPtr< FVisualizerEvent > Selection );
/** A pointer to the ListView of threads graph bars */
TSharedPtr< SListView< TSharedPtr< FVisualizerEvent > > > BarGraphsList;
/** Currently selected bar graph */
TSharedPtr< FVisualizerEvent > SelectedBarGraph;
/** Original profiler data */
TSharedPtr< FVisualizerEvent > ProfileData;
/** Profiler data view (filtered data) */
TArray< TSharedPtr< FVisualizerEvent > > ProfileDataView;
/** List of all SGraphBar widgets in the tree */
TArray< TSharedPtr< SGraphBar > > Graphs;
/** A pointer to the Zoom Label widget */
TSharedPtr< STextBlock > ZoomLabel;
/** A pointer to the horizontal scrollbar widget */
TSharedPtr< SScrollBar > ScrollBar;
/** A pointer to the horizontal scrollbar widget */
TSharedPtr< STimeline > Timeline;
/** Zoom slider value */
float ZoomSliderValue;
/** Scrollbar offset */
float ScrollbarOffset;
/** Should the OnBarGraphSelectionChangedDelegate be suppressed to avoid event loops */
bool bSuppressBarGraphSelectionChangedDelegate;
/** Delegate used when bar graph selection changes */
FOnBarGraphSelectionChanged OnBarGraphSelectionChangedDelegate;
/** Delegate used when bar graph selection changes */
FOnBarGraphExpansionChanged OnBarGraphExpansionChangedDelegate;
/** Delegate used when single event on the bar graph is selected */
FOnBarEventSelectionChanged OnBarEventSelectionChangedDelegate;
/** Delegate used when the user right-clicks on a bar graph */
FOnBarGraphContextMenu OnBarGraphContextMenuDelegate;
/** Bar visualizer view mode */
EVisualizerViewMode::Type ViewMode;
};