You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#UDN: Feature suggestion; Content browser can sort by a second column #branch UE4 #change Added two new images for secondary sort ascending and descending. (Updated styles where needed). Added new enum EColumnSortPriority: currently only lists Primary and Secondary, but can easily accommodate more*. (FOnSortModeChanged was modified to also have the priority as a param, fixedup existing usage). SHeaderRow now also has a SortPriority attribute to specify the SortMode order (Defaults to Primary if unused). Modified TUniquePtr so that assigning one from another worked correctly. (Reviewed by Steve Robb). SAssetView is the only table that has been modified, so far, to take advantage of the secondary sort. SetMajorityAssetType has been updated to correctly filter out all those sorts which are no longer relevant and bump the priority of the remaining sorts to fill in the ægapsÆ made by non-longer-relevant ones. FAssetViewSortManager has been overhauled to take SortPriority into consideration when sortingà Firstly, duplicate comparison structs were removed in favour of single structs which have æascendingÆ as a paramà any remaining duplicate code was removed in favour of an inherited usage. The base struct has an array of æfurther methodsÆ to employ in the result of a tie. Should a tie occur the ænextÆ comparison is done, and so on until itÆs not a tie or we run out of comparisons to perform.* The manager defaults to having no secondary sort, so it relies on the interface thatÆs using it to provide it. Whenever a column is assign the code makes sure that itÆs not already assigned to another column and corrects the order to take this into account. Fixed a bug in FCompareFAssetItemByTagNumericalAscending comparing A with A (instead of B). Various optimizations to the sort to descrease times *The only places æSecondaryÆ is referred to in code is in GetSortingBrush (so it can display the correct icon for the sort), and OnTitleClicked (so it can set to correct sort based on input). The sorting code itself has no concept as to a secondary sort, it can support any number of sorting levels so if in future a tertiary (or more) is added, it is only these two function which should need updating as the sort will automatically accommodate it. reviewed by Thomas.Sarkanen, Bob.Tellez [CL 2119201 by Andrew Brown in Main branch]
272 lines
8.3 KiB
C++
272 lines
8.3 KiB
C++
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
/**
|
|
* Item used in task graph events list
|
|
*/
|
|
class TASKGRAPH_API SEventItem : public SMultiColumnTableRow< TSharedPtr< FVisualizerEvent > >
|
|
{
|
|
public:
|
|
|
|
SLATE_BEGIN_ARGS( SEventItem )
|
|
: _EventName()
|
|
, _EventDuration(0.0)
|
|
{}
|
|
|
|
|
|
SLATE_ARGUMENT( FString, EventName )
|
|
|
|
SLATE_ATTRIBUTE( double, EventDuration )
|
|
|
|
SLATE_END_ARGS()
|
|
|
|
/**
|
|
* Generates a widget for task graph events list column
|
|
*
|
|
* @param InArgs A declaration from which to construct the widget
|
|
*/
|
|
virtual TSharedRef< SWidget > GenerateWidgetForColumn( const FName& ColumnName ) override;
|
|
|
|
|
|
/**
|
|
* Construct the widget
|
|
*
|
|
* @param InArgs A declaration from which to construct the widget
|
|
*/
|
|
void Construct( const FArguments& InArgs, const TSharedRef<STableViewBase>& InOwnerTableView );
|
|
|
|
private:
|
|
|
|
FString GetDurationText() const
|
|
{
|
|
return FString::Printf( TEXT("%.2f"), EventDuration.Get() );
|
|
}
|
|
|
|
FString EventName;
|
|
TAttribute< double > EventDuration;
|
|
};
|
|
|
|
|
|
/**
|
|
* Profiler events tree. Contains a tree of profiler event for the selected graph bar.
|
|
*/
|
|
class TASKGRAPH_API SEventsTree : public SCompoundWidget
|
|
{
|
|
public:
|
|
|
|
/** Delegate used when the selection changes */
|
|
DECLARE_DELEGATE_OneParam( FOnEventSelectionChanged, TSharedPtr< FVisualizerEvent > );
|
|
|
|
SLATE_BEGIN_ARGS( SEventsTree )
|
|
: _ProfileData()
|
|
, _OnEventSelectionChanged()
|
|
{}
|
|
|
|
/** Profiler data */
|
|
SLATE_ATTRIBUTE( TSharedPtr< FVisualizerEvent >, ProfileData )
|
|
|
|
/** Event for handling selection changes */
|
|
SLATE_EVENT( FOnEventSelectionChanged, OnEventSelectionChanged )
|
|
|
|
SLATE_END_ARGS()
|
|
|
|
/**
|
|
* Construct the widget
|
|
*
|
|
* @param InArgs A declaration from which to construct the widget
|
|
*/
|
|
void Construct( const FArguments& InArgs );
|
|
|
|
/**
|
|
* Function called when the currently selected bar graph changes
|
|
*
|
|
* @param Selection Currently selected bar graph
|
|
*/
|
|
void HandleBarGraphSelectionChanged( TSharedPtr< FVisualizerEvent > Selection );
|
|
|
|
/**
|
|
* Function called when the currently expanded bar graph changes
|
|
*
|
|
* @param Selection Currently expanded bar graph
|
|
*/
|
|
void HandleBarGraphExpansionChanged( TSharedPtr< FVisualizerEvent > Selection );
|
|
|
|
/**
|
|
* Function called when the user selects an event bar in the graph
|
|
*
|
|
* @param Selection Currently selected event
|
|
*/
|
|
void HandleBarEventSelectionChanged( int32 Thread, TSharedPtr< FVisualizerEvent > Selection );
|
|
|
|
/** Gets a label for this events tree tab */
|
|
FString GetTabTitle() const;
|
|
|
|
/** Name of 'Name' column */
|
|
static FName NAME_NameColumn;
|
|
|
|
/** Name of 'Duration' column */
|
|
static FName NAME_DurationColumn;
|
|
|
|
protected:
|
|
|
|
/**
|
|
* Function called when the currently selected event in the list of thread events changes
|
|
*
|
|
* @param Selection Currently selected event
|
|
* @param SelectInfo Provides context on how the selection changed
|
|
*/
|
|
void OnEventSelectionChanged( TSharedPtr< FVisualizerEvent > Selection, ESelectInfo::Type SelectInfo );
|
|
|
|
/**
|
|
* Generates SEventItem widgets for the events tree
|
|
*
|
|
* @param InItem Event to generate SEventItem for
|
|
* @param OwnerTable Owner Table
|
|
*/
|
|
TSharedRef< ITableRow > OnGenerateWidgetForEventsList( TSharedPtr< FVisualizerEvent > InItem, const TSharedRef< STableViewBase >& OwnerTable );
|
|
|
|
/**
|
|
* Given a profiler event, generates children for it
|
|
*
|
|
* @param InItem Event to generate children for
|
|
* @param OutChildren Generated children
|
|
*/
|
|
void OnGetChildrenForEventsList( TSharedPtr<FVisualizerEvent> InItem, TArray<TSharedPtr<FVisualizerEvent> >& OutChildren );
|
|
|
|
/**
|
|
* Handles column sorting mode change
|
|
*
|
|
* @param InSortMode New sorting mode
|
|
*/
|
|
void OnColumnSortModeChanged( const EColumnSortPriority::Type SortPriority, const FName& ColumnId, const EColumnSortMode::Type InSortMode );
|
|
|
|
/**
|
|
* @return Returns the current sort mode of the specified column
|
|
*/
|
|
EColumnSortMode::Type GetColumnSortMode( const FName ColumnId );
|
|
|
|
/** Sorts the selected events tree */
|
|
void SortEventsList( void );
|
|
|
|
/** Recursively sorts the selected events tree */
|
|
void SortEventsList( TArray< TSharedPtr< FVisualizerEvent > >& Events );
|
|
|
|
/** Restores event selection after changes to the tree */
|
|
bool RestoreEventSelection( TArray< TSharedPtr< FVisualizerEvent > >& Events );
|
|
|
|
/**
|
|
* Sets 'Duration' column time units
|
|
*
|
|
* @param InUnits New units
|
|
*/
|
|
void SetDurationUnits( EVisualizerTimeUnits::Type InUnits );
|
|
|
|
/** Recursively counts all events in the tree */
|
|
int32 CountEvents( TArray< TSharedPtr< FVisualizerEvent > >& Events );
|
|
|
|
/** Given the selected events from the bar graph creates a copy of the selection applying the current view and sorting mode */
|
|
void CreateSelectedEventsView();
|
|
|
|
/** Helper function for creating a copy of the selected events in a hierarchy */
|
|
TSharedPtr< FVisualizerEvent > CreateSelectedEventsViewRecursively( TSharedPtr< FVisualizerEvent > SourceEvent );
|
|
|
|
/** Helper function for creating a copy of the selected events and flattening the hierarchy */
|
|
void CreateSelectedEventsViewRecursivelyAndFlatten( TSharedPtr< FVisualizerEvent > SourceEvent );
|
|
|
|
/** Helper function for creating a copy of the selected events combining leaves with the same name */
|
|
void CreateSelectedEventsViewRecursivelyCoalesced( TArray< TSharedPtr< FVisualizerEvent > >& SourceEvents, TArray< TSharedPtr< FVisualizerEvent > >& CopiedEvents, TSharedPtr< FVisualizerEvent > InParent );
|
|
|
|
/** Helper function for creating a copy of the selected events combining leaves with the same name and flattening the hierarchy */
|
|
void CreateSelectedEventsViewRecursivelyFlatCoalesced( TArray< TSharedPtr< FVisualizerEvent > >& SourceEvents );
|
|
|
|
/** Gets the currently selected time units */
|
|
bool CheckDurationUnits( EVisualizerTimeUnits::Type InUnits ) const
|
|
{
|
|
return (InUnits == DurationUnits);
|
|
}
|
|
|
|
/**
|
|
* 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);
|
|
}
|
|
|
|
/**
|
|
* Converts ms to currently selected time units.
|
|
*
|
|
* @param InDurationMs duration time in ms.
|
|
*/
|
|
double GetEventDuration( double InDurationMs ) const;
|
|
|
|
/**
|
|
* Called by the editable text control when the filter text is changed by the user
|
|
*
|
|
* @param InFilterText The new text
|
|
*/
|
|
void OnFilterTextChanged( const FText& InFilterText );
|
|
|
|
/** Called by the editable text control when a user presses enter or commits their text change */
|
|
void OnFilterTextCommitted( const FText& InFilterText, ETextCommit::Type CommitInfo );
|
|
|
|
/** Checks if event name passes current filter */
|
|
bool FilterEvent( TSharedPtr< FVisualizerEvent > InEvent ) const
|
|
{
|
|
// Filter only leaves, we want to keep the hierarchy
|
|
return InEvent->Children.Num() > 0 || FilterText.Len() == 0 || InEvent->EventName.StartsWith( FilterText );
|
|
}
|
|
|
|
/** Gets the currently selected time units text */
|
|
FString GetDurationColumnTitle() const;
|
|
|
|
/** A pointer to the ListView of profiler events */
|
|
TSharedPtr< STreeView< TSharedPtr< FVisualizerEvent > > > EventsListView;
|
|
|
|
/** Original profiler data */
|
|
TSharedPtr< FVisualizerEvent > ProfileData;
|
|
|
|
/** Currently selected events for this tree */
|
|
TSharedPtr< FVisualizerEvent > SelectedThread;
|
|
|
|
/** List of events for the currently selected thread */
|
|
TArray< TSharedPtr< FVisualizerEvent > > SelectedEvents;
|
|
|
|
/** List of events for the currently selected thread */
|
|
TArray< TSharedPtr< FVisualizerEvent > > SelectedEventsView;
|
|
|
|
/** Maps the events generated using currently selected view and sorting modes to the source events tree */
|
|
TMap< TSharedPtr< FVisualizerEvent >, TSharedPtr< FVisualizerEvent > > ViewToEventsMap;
|
|
|
|
/** Delegate used to notify when event selection changes */
|
|
FOnEventSelectionChanged OnEventSelectionChangedDelegate;
|
|
|
|
/** Specify which column to sort with */
|
|
FName SortByColumn;
|
|
|
|
/** Currently selected sorting mode */
|
|
EColumnSortMode::Type SortMode;
|
|
|
|
/** Currently selected time units */
|
|
EVisualizerTimeUnits::Type DurationUnits;
|
|
|
|
/** Currently selected view mode */
|
|
EVisualizerViewMode::Type ViewMode;
|
|
|
|
/** Events filter text */
|
|
FString FilterText;
|
|
|
|
/** Suppresses SelectionChanged delegate to avoid event loops between graph visualizer and events tree */
|
|
bool bSuppressSelectionChangedEvent;
|
|
};
|