SExtDependencyViewer.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. // Copyright 2017-2021 marynate. All Rights Reserved.
  2. #pragma once
  3. #include "CoreMinimal.h"
  4. #include "Input/Reply.h"
  5. #include "Widgets/DeclarativeSyntaxSupport.h"
  6. #include "Widgets/SCompoundWidget.h"
  7. #include "Widgets/Input/SSearchBox.h"
  8. #include "GraphEditor.h"
  9. #include "ExtDependencyHistoryManager.h"
  10. #include "CollectionManagerTypes.h"
  11. class UEdGraph;
  12. class UEdGraph_ExtDependencyViewer;
  13. class SComboButton;
  14. /**
  15. *
  16. */
  17. class SExtDependencyViewer : public SCompoundWidget
  18. {
  19. public:
  20. SLATE_BEGIN_ARGS( SExtDependencyViewer ){}
  21. SLATE_END_ARGS()
  22. ~SExtDependencyViewer();
  23. /** Constructs this widget with InArgs */
  24. void Construct( const FArguments& InArgs );
  25. /** Sets a new root package name */
  26. void SetGraphRootIdentifiers(const TArray<FExtAssetIdentifier>& NewGraphRootIdentifiers);
  27. /** Gets graph editor */
  28. TSharedPtr<SGraphEditor> GetGraphEditor() const { return GraphEditorPtr; }
  29. /** Called when the current registry source changes */
  30. void SetCurrentRegistrySource(/*const FAssetManagerEditorRegistrySource* RegistrySource*/);
  31. // SWidget inherited
  32. virtual void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override;
  33. private:
  34. /** Call after a structural change is made that causes the graph to be recreated */
  35. void RebuildGraph();
  36. /** Called to create context menu when right-clicking on graph */
  37. FActionMenuContent OnCreateGraphActionMenu(UEdGraph* InGraph, const FVector2D& InNodePosition, const TArray<UEdGraphPin*>& InDraggedPins, bool bAutoExpand, SGraphEditor::FActionMenuClosed InOnMenuClosed);
  38. /** Called when a node is double clicked */
  39. void OnNodeDoubleClicked(class UEdGraphNode* Node);
  40. /** True if the user may use the history back button */
  41. bool IsBackEnabled() const;
  42. /** True if the user may use the history forward button */
  43. bool IsForwardEnabled() const;
  44. /** Handler for clicking the history back button */
  45. FReply BackClicked();
  46. /** Handler for clicking the history forward button */
  47. FReply ForwardClicked();
  48. /** Handler for when the graph panel tells us to go back in history (like using the mouse thumb button) */
  49. void GraphNavigateHistoryBack();
  50. /** Handler for when the graph panel tells us to go forward in history (like using the mouse thumb button) */
  51. void GraphNavigateHistoryForward();
  52. /** Gets the tool tip text for the history back button */
  53. FText GetHistoryBackTooltip() const;
  54. /** Gets the tool tip text for the history forward button */
  55. FText GetHistoryForwardTooltip() const;
  56. /** Gets the text to be displayed in the address bar */
  57. FText GetAddressBarText() const;
  58. /** Called when the path is being edited */
  59. void OnAddressBarTextChanged(const FText& NewText);
  60. /** Sets the new path for the viewer */
  61. void OnAddressBarTextCommitted(const FText& NewText, ETextCommit::Type CommitInfo);
  62. void OnApplyHistoryData(const FExtDependencyViewerHistoryData& History);
  63. void OnUpdateHistoryData(FExtDependencyViewerHistoryData& HistoryData) const;
  64. void OnSearchDepthEnabledChanged( ECheckBoxState NewState );
  65. ECheckBoxState IsSearchDepthEnabledChecked() const;
  66. int32 GetSearchDepthCount() const;
  67. void OnSearchDepthCommitted(int32 NewValue);
  68. void OnSearchBreadthEnabledChanged( ECheckBoxState NewState );
  69. ECheckBoxState IsSearchBreadthEnabledChecked() const;
  70. void OnEnableCollectionFilterChanged(ECheckBoxState NewState);
  71. ECheckBoxState IsEnableCollectionFilterChecked() const;
  72. TSharedRef<SWidget> GenerateCollectionFilterItem(TSharedPtr<FName> InItem);
  73. void HandleCollectionFilterChanged(TSharedPtr<FName> Item, ESelectInfo::Type SelectInfo);
  74. FText GetCollectionFilterText() const;
  75. void OnShowSoftReferencesChanged( ECheckBoxState NewState );
  76. ECheckBoxState IsShowSoftReferencesChecked() const;
  77. void OnShowHardReferencesChanged(ECheckBoxState NewState);
  78. ECheckBoxState IsShowHardReferencesChecked() const;
  79. EVisibility GetManagementReferencesVisibility() const;
  80. void OnShowManagementReferencesChanged(ECheckBoxState NewState);
  81. ECheckBoxState IsShowManagementReferencesChecked() const;
  82. void OnShowSearchableNamesChanged(ECheckBoxState NewState);
  83. ECheckBoxState IsShowSearchableNamesChecked() const;
  84. void OnShowNativePackagesChanged(ECheckBoxState NewState);
  85. ECheckBoxState IsShowNativePackagesChecked() const;
  86. int32 GetSearchBreadthCount() const;
  87. void OnSearchBreadthCommitted(int32 NewValue);
  88. void RegisterActions();
  89. void ShowSelectionInContentBrowser();
  90. void OpenSelectedInAssetEditor();
  91. void ReCenterGraph();
  92. void CopyReferencedObjects();
  93. void CopyReferencingObjects();
  94. void ShowReferencedObjects();
  95. void ShowReferencingObjects();
  96. void MakeCollectionWithReferencersOrDependencies(ECollectionShareType::Type ShareType, bool bReferencers);
  97. void ShowReferenceTree();
  98. void ViewSizeMap();
  99. void ViewAssetAudit();
  100. void ZoomToFitSelected();
  101. void ZoomToFitAll();
  102. bool CanZoomToFit() const;
  103. void OnFind();
  104. /** Handlers for searching */
  105. void HandleOnSearchTextChanged(const FText& SearchText);
  106. void HandleOnSearchTextCommitted(const FText& SearchText, ETextCommit::Type CommitType);
  107. void ReCenterGraphOnNodes(const TSet<UObject*>& Nodes);
  108. FString GetReferencedObjectsList() const;
  109. FString GetReferencingObjectsList() const;
  110. UObject* GetObjectFromSingleSelectedNode() const;
  111. void GetPackageNamesFromSelectedNodes(TSet<FName>& OutNames) const;
  112. bool HasExactlyOneNodeSelected() const;
  113. bool HasExactlyOnePackageNodeSelected() const;
  114. bool HasAtLeastOnePackageNodeSelected() const;
  115. bool HasAtLeastOneRealNodeSelected() const;
  116. void OnInitialAssetRegistrySearchComplete();
  117. EActiveTimerReturnType TriggerZoomToFit(double InCurrentTime, float InDeltaTime);
  118. public:
  119. /** Saves any settings to config that should be persistent between editor sessions */
  120. void SaveSettings(const FString& IniFilename, const FString& IniSection, const FString& SettingsString) const;
  121. /** Loads any settings to config that should be persistent between editor sessions */
  122. void LoadSettings(const FString& IniFilename, const FString& IniSection, const FString& SettingsString);
  123. private:
  124. /** Gets the current value for the scale slider (0 to 1) */
  125. float GetNodeSpacingScale() const;
  126. /** Sets the current scale value (0 to 1) */
  127. void SetNodeSpacingScale(float NewValue);
  128. /** Is node spacing slider locked? */
  129. bool IsNodeSpacingScaleLocked() const;
  130. /** Returns the foreground color for the view button */
  131. FSlateColor GetViewButtonForegroundColor() const;
  132. /** Handler for when the view combo button is clicked */
  133. TSharedRef<SWidget> GetViewButtonContent();
  134. /** The widget holds node spacing slider */
  135. TSharedPtr<SWidget> NodeSpacingSliderContainer;
  136. /** The button that displays view options */
  137. TSharedPtr<SComboButton> ViewOptionsComboButton;
  138. private:
  139. /** The manager that keeps track of history data for this browser */
  140. FExtDependencyViewerHistoryManager HistoryManager;
  141. TSharedPtr<SGraphEditor> GraphEditorPtr;
  142. TSharedPtr<FUICommandList> ReferenceViewerActions;
  143. TSharedPtr<SSearchBox> SearchBox;
  144. UEdGraph_ExtDependencyViewer* GraphObj;
  145. /** The temporary copy of the path text when it is actively being edited. */
  146. FText TemporaryPathBeingEdited;
  147. /** List of collection filter options */
  148. TArray<TSharedPtr<FName>> CollectionsComboList;
  149. float NodeSpacingScale = 0.1f;
  150. };