PropertyGrid.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #if !defined(Q_MOC_RUN)
  10. #include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI_Internals.h>
  11. #include <AzToolsFramework/API/ToolsApplicationAPI.h>
  12. #include <AzQtComponents/Components/StyledDockWidget.h>
  13. #include <AzCore/Component/EntityId.h>
  14. #include <AzCore/Asset/AssetCommon.h>
  15. #include <Core/Node.h>
  16. #include <GraphCanvas/Components/GraphCanvasPropertyBus.h>
  17. #include <ScriptCanvas/Core/GraphBus.h>
  18. #include "PropertyGridBus.h"
  19. #endif
  20. class QSpacerItem;
  21. class QScrollArea;
  22. namespace AzToolsFramework
  23. {
  24. class PropertiesWidget;
  25. class EntityPropertyEditor;
  26. namespace UndoSystem
  27. {
  28. class URSequencePoint;
  29. }
  30. class ComponentEditor;
  31. }
  32. namespace ScriptCanvasEditor
  33. {
  34. namespace Widget
  35. {
  36. class PropertyGrid
  37. : public AzQtComponents::StyledDockWidget
  38. , public AzToolsFramework::IPropertyEditorNotify
  39. , public PropertyGridRequestBus::Handler
  40. , public ScriptCanvas::EndpointNotificationBus::MultiHandler
  41. , public ScriptCanvas::NodeNotificationsBus::MultiHandler
  42. , public GraphCanvas::GraphCanvasPropertyInterfaceNotificationBus::MultiHandler
  43. {
  44. Q_OBJECT
  45. public:
  46. PropertyGrid(QWidget* parent = nullptr, const char* name = "Properties");
  47. ~PropertyGrid() override;
  48. // AzToolsFramework::IPropertyEditorNotify
  49. void BeforePropertyModified(AzToolsFramework::InstanceDataNode* pNode) override;
  50. void AfterPropertyModified(AzToolsFramework::InstanceDataNode* pNode) override;
  51. void SetPropertyEditingActive(AzToolsFramework::InstanceDataNode* pNode) override;
  52. void SetPropertyEditingComplete(AzToolsFramework::InstanceDataNode* pNode) override;
  53. void RequestPropertyContextMenu(AzToolsFramework::InstanceDataNode* node, const QPoint& point) override;
  54. /////
  55. // NodeNotificationsBus
  56. void OnSlotDisplayTypeChanged(const ScriptCanvas::SlotId& slotId, const ScriptCanvas::Data::Type& slotType) override;
  57. ////
  58. // PropertyGridRequestHandler
  59. void RefreshPropertyGrid() override;
  60. void RebuildPropertyGrid() override;
  61. void SetSelection(const AZStd::vector<AZ::EntityId>& selectedEntityIds) override;
  62. void ClearSelection() override;
  63. ////
  64. // GraphCanvasPropertyInterfaceNotificationBus
  65. void OnPropertyComponentChanged() override;
  66. ////
  67. void SealUndoStack() override {};
  68. void OnNodeUpdate(const AZ::EntityId&);
  69. struct InstancesToDisplay
  70. {
  71. //! This is ONLY used to get the title of the node.
  72. //! This entity ISN'T necessarily the owner of m_gcInstances and m_scInstances.
  73. AZ::EntityId m_gcEntityId;
  74. AZStd::list<AZ::Component*> m_gcInstances;
  75. AZStd::list<AZ::Component*> m_scInstances;
  76. };
  77. void DisableGrid();
  78. void EnableGrid();
  79. private slots:
  80. void UpdateContents(const AZStd::vector<AZ::EntityId>& selectedEntityIds);
  81. // ScriptCanvas::EndpointNotificationBus::MultiHandler
  82. void OnEndpointConnected(const ScriptCanvas::Endpoint& targetEndpoint) override;
  83. void OnEndpointDisconnected(const ScriptCanvas::Endpoint& targetEndpoint) override;
  84. void OnEndpointConvertedToValue() override;
  85. void OnEndpointConvertedToReference() override;
  86. ////////////////////////////
  87. void UpdateEndpointVisibility(const ScriptCanvas::Endpoint& endpoint);
  88. private:
  89. void SignalUndo(AzToolsFramework::InstanceDataNode* pNode);
  90. void SetVisibility(const AZStd::vector<AZ::EntityId>& selectedEntityIds);
  91. void DisplayInstances(const InstancesToDisplay& instances);
  92. ScriptCanvas::ScriptCanvasId GetScriptCanvasId(AZ::Component* component);
  93. AzToolsFramework::ComponentEditor* CreateComponentEditor();
  94. AZStd::vector<AZStd::unique_ptr<AzToolsFramework::ComponentEditor> > m_componentEditors;
  95. // the spacer's job is to make sure that its always at the end of the list of components.
  96. QSpacerItem* m_spacer = nullptr;
  97. QScrollArea* m_scrollArea = nullptr;
  98. QWidget* m_host = nullptr;
  99. bool m_propertyModified = false;
  100. };
  101. }
  102. }