// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "PoseSearchDebuggerDatabaseRowData.h" #include "Widgets/Input/SSearchBox.h" #include "Widgets/Views/SHeaderRow.h" template class SListView; namespace UE::PoseSearch { namespace DebuggerDatabaseColumns { struct IColumn; } struct FTraceMotionMatchingStateMessage; /** Sets model selection data on row selection */ DECLARE_DELEGATE_ThreeParams(FOnPoseSelectionChanged, const UPoseSearchDatabase*, int32, float) /** * Database panel view widget of the PoseSearch debugger */ class SDebuggerDatabaseView : public SCompoundWidget { SLATE_BEGIN_ARGS(SDebuggerDatabaseView) {} SLATE_ARGUMENT(TWeakPtr, Parent) SLATE_EVENT(FOnPoseSelectionChanged, OnPoseSelectionChanged) SLATE_END_ARGS() void Construct(const FArguments& InArgs); void Update(const FTraceMotionMatchingStateMessage& State); const TSharedPtr>>& GetActiveRow() const { return ActiveView.ListView; } const TSharedPtr>>& GetContinuingPoseRow() const { return ContinuingPoseView.ListView; } const TSharedPtr>>& GetDatabaseRows() const { return FilteredDatabaseView.ListView; } const TSharedRef& GetPoseIdxDatabaseRow(int32 PoseIdx) const; /** Used by database rows to acquire column-specific information */ using FColumnMap = TMap>; private: /** Adds a column to the existing list */ void AddColumn(TSharedRef&& Column); /** Retrieves current column map, used as an attribute by rows */ const FColumnMap* GetColumnMap() const { return &Columns; } /** Sorts the database by the current sort predicate, updating the view order */ void SortDatabaseRows(); void PopulateViewRows(); /** Acquires sort predicate for the given column */ EColumnSortMode::Type GetColumnSortMode(const FName ColumnId) const; /** Gets active column width, used to align active and database view */ float GetColumnWidth(const FName ColumnId) const; /** Updates the active sort predicate, setting the sorting order of all other columns to none * (to be dependent on active column */ void OnColumnSortModeChanged(const EColumnSortPriority::Type SortPriority, const FName & ColumnId, const EColumnSortMode::Type InSortMode); /** Aligns the active and database views */ void OnColumnWidthChanged(const float NewWidth, FName ColumnId) const; /** Called when the text in the filter box is modified to update the filtering */ void OnFilterTextChanged(const FText& SearchText); /** Called when the ShowAllPoses Checkbox is Toggled */ void OnShowAllPosesCheckboxChanged(ECheckBoxState State); /** Called when the ShowOnlyBestAssetPose Checkbox is Toggled */ void OnShowOnlyBestAssetPoseCheckboxChanged(ECheckBoxState State); /** Called when the HideInvalidPoses Checkbox is Toggled */ void OnHideInvalidPosesCheckboxChanged(ECheckBoxState State); /** Called when the UseRegex Checkbox is Toggled */ void OnUseRegexCheckboxChanged(ECheckBoxState State); /** Row selection to update model view */ void OnDatabaseRowSelectionChanged(TSharedPtr Row, ESelectInfo::Type SelectInfo); /** Generates a database row widget for the given data */ TSharedRef HandleGenerateDatabaseRow(TSharedRef Item, const TSharedRef& OwnerTable) const; /** Generates the active row widget for the given data */ TSharedRef HandleGenerateActiveRow(TSharedRef Item, const TSharedRef& OwnerTable) const; /** Generates the continuing pose row widget for the given data */ TSharedRef HandleGenerateContinuingPoseRow(TSharedRef Item, const TSharedRef& OwnerTable) const; TWeakPtr ParentDebuggerViewPtr; FOnPoseSelectionChanged OnPoseSelectionChanged; /** Current column to sort by */ FName SortColumn = ""; /** Current sorting mode */ EColumnSortMode::Type SortMode = EColumnSortMode::Ascending; /** Column data container, used to emplace defined column structures of various types */ FColumnMap Columns; TArray OldLabels; bool bHasPCACostColumn = false; bool bWasVerbose = false; struct FTable { /** Header row*/ TSharedPtr HeaderRow; /** Widget for displaying the list of row objects */ TSharedPtr>> ListView; // @TODO: Explore options for active row other than displaying array of 1 element /** List of row objects */ TArray> Rows; /** Background style for the list view */ FTableRowStyle RowStyle; /** Row color */ FSlateBrush RowBrush; /** Scroll bar for the data table */ TSharedPtr ScrollBar; }; /** Active row at the top of the view */ FTable ActiveView; /** Continuing pose row below Active row */ FTable ContinuingPoseView; /** All database poses */ TArray> UnfilteredDatabaseRows; /** Database listing for filtered poses */ FTable FilteredDatabaseView; /** Search box widget */ TSharedPtr FilterBox; /** Text used to filter DatabaseView */ FText FilterText; FText ReasonForNoActivePose; FText ReasonForNoContinuingPose; FText ReasonForNoCandidates; }; } // namespace UE::PoseSearch