// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "MuR/Image.h" #include "MuR/Mesh.h" #include "MuR/Operations.h" #include "MuR/ModelPrivate.h" #include "Widgets/Views/SHeaderRow.h" #include "Widgets/Views/STileView.h" // Forward declarations template class SMutableMultiPageListView; class ITableRow; class SExpandableArea; class SMutableCodeViewer; class STableViewBase; class SWidget; namespace mu { struct FProgram; } namespace mu { struct FProjector; } namespace mu { struct FShape; } /** * Base Structure to define the different elements used by the lists on this object */ struct FMutableConstantElement { /** The index of this element on the host vector. */ uint32 IndexOnSourceVector; }; /** * Cache object used for the generation of the ui elements related to the constant images found on the model */ struct FMutableConstantImageElement : public FMutableConstantElement { TSharedPtr ImagePtr; }; /** * Cache object used for the generation of the ui elements related to the constant meshes found on the model */ struct FMutableConstantMeshElement : public FMutableConstantElement { TSharedPtr MeshPtr; }; /** * Cache object used for the generation of the ui elements related to the constant strings found on the model */ struct FMutableConstantStringElement : public FMutableConstantElement { FString MutableString; }; /** * Cache object used for the generation of the ui elements related to the constant layouts found on the model */ struct FMutableConstantLayoutElement : public FMutableConstantElement { TSharedPtr Layout; }; /** * Cache object used for the generation of the ui elements related to the constant skeletons found on the model */ struct FMutableConstantSkeletonElement : public FMutableConstantElement { TSharedPtr Skeleton; }; /** * Cache object used for the generation of the ui elements related to the constant skeletons found on the model */ struct FMutableConstantPhysicsElement : public FMutableConstantElement { TSharedPtr Physics; }; /** * Cache object used for the generation of the ui elements related to the constant projectors found on the model */ struct FMutableConstantProjectorElement : public FMutableConstantElement { const mu::FProjector* Projector = nullptr; }; /** * Cache object used for the generation of the ui elements related to the constant matrices found on the model */ struct FMutableConstantMatrixElement : public FMutableConstantElement { FMatrix44f Matrix; }; /** * Cache object used for the generation of the ui elements related to the constant shapes found on the model */ struct FMutableConstantShapeElement : public FMutableConstantElement { const mu::FShape* Shape = nullptr; }; /** * Cache object used for the generation of the ui elements related to the constant curves found on the model */ struct FMutableConstantCurveElement : public FMutableConstantElement { FRichCurve Curve; }; /** * Slate panel object designed to hold all the model constants */ class SMutableConstantsWidget : public SCompoundWidget { SLATE_BEGIN_ARGS(SMutableConstantsWidget) {} SLATE_END_ARGS() public: /** Builds the widget * @param InArgs - Arguments provided when generating this slate object * @param InMutableProgramPtr - Pointer to the mu::FProgram object that holds the constants data. * @param InMutableCodeViewerPtr - Pointer to the MutableCodeViewer tasked with the previewing of the constant values */ void Construct(const FArguments& InArgs, const mu::FProgram* InMutableProgramPtr , TSharedPtr InMutableCodeViewerPtr); /** It clears the selected element for all constant view slates (SListView and STileView) except the one that shows the data of the provided type * @param ExceptionDataType The type of data of the slate container that we want to skip when clearing the selected elements. * EX : We want to clear all selected elements but not the ones from the constant images. Provide as argument "mu::EDataType::Image" * to clear all but the selected item/s of the Image type. */ void ClearSelectedConstantItems(mu::EDataType ExceptionDataType = mu::EDataType::None) const; private: /** Mutable object containing the constants data */ const mu::FProgram* MutableProgramPtr = nullptr; /** Slate capable of accessing the previewer object */ TSharedPtr MutableCodeViewerPtr = nullptr; /** *Sets the back end for the operation of this widget. Each time this is done the ui backend gets updated * @param InProgram - Mutable program object holding all the constants data */ void SetProgram(const mu::FProgram* InProgram); /* * Pointers to all slates showing the constants */ TSharedPtr>> ConstantMeshesSlate; TSharedPtr>> ConstantStringsSlate; TSharedPtr>> ConstantLayoutsSlate; TSharedPtr>> ConstantProjectorsSlate; TSharedPtr>> ConstantMatricesSlate; TSharedPtr>> ConstantShapesSlate; TSharedPtr>> ConstantCurvesSlate; TSharedPtr>> ConstantSkeletonsSlate; TSharedPtr>> ConstantPhysicsSlate; /* * Data backend for the lists of constants */ TSharedPtr>> ImageListViewHandler; TSharedPtr>> ConstantImageElements; TSharedPtr>> MeshListViewHandler; TSharedPtr>> ConstantMeshElements; TArray> ConstantStringElements; TArray> ConstantLayoutElements; TArray> ConstantProjectorElements; TArray> ConstantMatrixElements; TArray> ConstantShapeElements; TArray> ConstantCurveElements; TArray> ConstantSkeletonElements; TArray> ConstantPhysicsElements; /** * Load up all the elements with the data found on the mu::FProgram object onto TArrays after parsing the data found. */ void LoadConstantElements(); void LoadConstantStrings(); void LoadConstantMeshes(); void LoadConstantImages(); void LoadConstantLayouts(); void LoadConstantProjectors(); void LoadConstantMatrices(); void LoadConstantShapes(); void LoadConstantCurves(); void LoadConstantSkeletons(); void LoadConstantPhysics(); /* * Proxy slates operation objects */ void OnSelectedStringChanged(TSharedPtr MutableConstantStringElement, ESelectInfo::Type SelectionType) const; void OnSelectedImageChanged(TSharedPtr MutableConstantImageElement, ESelectInfo::Type SelectionType) const; void OnSelectedMeshChanged(TSharedPtr MutableConstantMeshElement, ESelectInfo::Type SelectionType) const; void OnSelectedLayoutChanged(TSharedPtr MutableConstantLayoutElement, ESelectInfo::Type SelectionType) const; void OnSelectedProjectorChanged(TSharedPtr MutableConstantProjectorElement, ESelectInfo::Type SelectionType) const; void OnSelectedMatrixChanged(TSharedPtr MutableConstantMatrixElement, ESelectInfo::Type SelectionType) const; void OnSelectedShapeChanged(TSharedPtr MutableConstantShapeElement, ESelectInfo::Type SelectionType) const; void OnSelectedCurveChanged(TSharedPtr MutableConstantCurveElement, ESelectInfo::Type SelectionType) const; void OnSelectedSkeletonChanged(TSharedPtr MutableConstantSkeletonElement, ESelectInfo::Type SelectionType) const; void OnSelectedPhysicsChanged(TSharedPtr MutableConstantPhysicsElement, ESelectInfo::Type SelectionType) const; /* * UI updating methods */ TSharedRef OnGenerateStringRow(TSharedPtr MutableConstantStringElement, const TSharedRef& OwnerTable) const; TSharedRef OnGenerateImageRow(TSharedPtr MutableConstantImageElement, const TSharedRef& OwnerTable) const; TSharedRef OnGenerateMeshRow(TSharedPtr MutableConstantMeshElement, const TSharedRef& OwnerTable) const; TSharedRef OnGenerateLayoutRow(TSharedPtr MutableConstantLayoutElement, const TSharedRef& OwnerTable) const; TSharedRef OnGenerateProjectorRow(TSharedPtr MutableConstantProjectorElement, const TSharedRef& OwnerTable)const; TSharedRef OnGenerateMatrixRow(TSharedPtr MutableConstantMatrixElement, const TSharedRef& OwnerTable) const; TSharedRef OnGenerateShapeRow(TSharedPtr MutableConstantShapeElement, const TSharedRef& OwnerTable) const; TSharedRef OnGenerateCurveRow(TSharedPtr MutableConstantCurveElement, const TSharedRef& OwnerTable) const; TSharedRef OnGenerateSkeletonRow(TSharedPtr MutableConstantSkeletonElement, const TSharedRef& OwnerTable) const; TSharedRef OnGeneratePhysicsRow(TSharedPtr MutableConstantPhysicsElement, const TSharedRef& OwnerTable) const; /* * Image List sorting methods */ /** Id of the last column the user decided to Sort. Usefully in order to interpolate ascending and descending sorting * order */ FName ImageConstantsLastSortedColumnID = ""; /** Variable holding what kind of sorting has been used on the last sorting operation*/ EColumnSortMode::Type ImageListSortMode = EColumnSortMode::Type::None; /** Callback method designed to sort the list of images. It sorts ConstantImageElements */ void OnImageTableSortRequested(EColumnSortPriority::Type ColumnSortPriority, const FName& ColumnID, EColumnSortMode::Type ColumnSortMode); EColumnSortMode::Type GetImageListColumnSortMode(FName ColumnName) const; /* * Mesh List sorting methods */ FName MeshConstantsLastSortedColumnID = ""; EColumnSortMode::Type MeshListSortMode = EColumnSortMode::Type::None; void OnMeshTableSortRequested(EColumnSortPriority::Type ColumnSortPriority, const FName& ColumnID, EColumnSortMode::Type ColumnSortMode); EColumnSortMode::Type GetMeshListColumnSortMode(FName ColumnName) const; /* * Expandable areas objects and behaviours */ // Pointers to all expandable areas part of this slate TSharedPtr StringsExpandableArea; TSharedPtr ImagesExpandableArea; TSharedPtr MeshesExpandableArea; TSharedPtr LayoutsExpandableArea; TSharedPtr ProjectorsExpandableArea; TSharedPtr MatricesExpandableArea; TSharedPtr ShapesExpandableArea; TSharedPtr CurvesExpandableArea; TSharedPtr SkeletonsExpandableArea; TSharedPtr PhysicsExpandableArea; /** Array with all expandable areas set on this object. Used for dynamic expansion/contraction */ TArray> ExpandableAreas; /* * Callback methods called each time one expandable area gets expanded or contracted */ void OnStringsRegionExpansionChanged(bool bExpanded); void OnImagesRegionExpansionChanged(bool bExpanded); void OnMeshesRegionExpansionChanged(bool bExpanded); void OnLayoutsRegionExpansionChanged(bool bExpanded); void OnProjectorsRegionExpansionChanged(bool bExpanded); void OnMatricesRegionExpansionChanged(bool bExpanded); void OnShapesRegionExpansionChanged(bool bExpanded); void OnCurvesRegionExpansionChanged(bool bExpanded); void OnSkeletonsRegionExpansionChanged(bool bExpanded); void OnPhysicsRegionExpansionChanged(bool bExpanded); /** Method called each time one expandable area changes expansion state * @param InException - Pointer to the expandable area that will not be contracted while all the others will */ void ContractExpandableAreas(const TSharedPtr& InException); /* * Methods used to get the size of each constant type collection on memory. */ // Sizes decomposed on GB, MB, KB and B FText ConstantStringsFormattedSize; FText ConstantImagesFormattedSize; FText ConstantMeshesFormattedSize; FText ConstantLayoutsFormattedSize; FText ConstantProjectorsFormattedSize; FText ConstantMatricesFormattedSize; FText ConstantShapesFormattedSize; FText ConstantCurvesFormattedSize; FText ConstantSkeletonsFormattedSize; FText ConstantPhysicsFormattedSize; /* * Callback methods used for drawing the titles of each of the constant expandable areas */ FText OnDrawStringsAreaTitle() const; FText OnDrawImagesAreaTitle() const; FText OnDrawMeshesAreaTitle() const; FText OnDrawLayoutsAreaTitle() const; FText OnDrawProjectorsAreaTitle() const; FText OnDrawMatricesAreaTitle() const; FText OnDrawShapesAreaTitle() const; FText OnDrawCurvesAreaTitle() const; FText OnDrawSkeletonsAreaTitle() const; FText OnDrawPhysicsAreaTitle() const; };