ManifestWidgetPage.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #pragma once
  2. /*
  3. * Copyright (c) Contributors to the Open 3D Engine Project.
  4. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. *
  6. * SPDX-License-Identifier: Apache-2.0 OR MIT
  7. *
  8. */
  9. #if !defined(Q_MOC_RUN)
  10. #include <QWidget>
  11. #include <AzCore/std/smart_ptr/shared_ptr.h>
  12. #include <AzCore/std/containers/vector.h>
  13. #include <AzCore/Math/Uuid.h>
  14. #include <AzToolsFramework/UI/PropertyEditor/ReflectedPropertyEditor.hxx>
  15. #include <SceneAPI/SceneCore/Events/ManifestMetaInfoBus.h>
  16. #endif
  17. namespace AZ
  18. {
  19. class SerializeContext;
  20. namespace SceneAPI
  21. {
  22. namespace DataTypes
  23. {
  24. class IManifestObject;
  25. }
  26. namespace UI
  27. {
  28. // QT space
  29. namespace Ui
  30. {
  31. class ManifestWidgetPage;
  32. }
  33. class ManifestWidgetPage
  34. : public QWidget
  35. , public AzToolsFramework::IPropertyEditorNotify
  36. , public Events::ManifestMetaInfoBus::Handler
  37. {
  38. Q_OBJECT
  39. public:
  40. ManifestWidgetPage(SerializeContext* context, AZStd::vector<AZ::Uuid>&& classTypeIds);
  41. ~ManifestWidgetPage() override;
  42. // Sets the number of entries the user can add through this widget. It doesn't limit
  43. // the amount of entries that can be stored.
  44. virtual void SetCapSize(size_t size);
  45. virtual size_t GetCapSize() const;
  46. virtual bool SupportsType(const AZStd::shared_ptr<DataTypes::IManifestObject>& object);
  47. virtual bool AddObject(const AZStd::shared_ptr<DataTypes::IManifestObject>& object);
  48. virtual bool RemoveObject(const AZStd::shared_ptr<DataTypes::IManifestObject>& object);
  49. virtual size_t ObjectCount() const;
  50. virtual void Clear();
  51. virtual void ScrollToBottom();
  52. void RefreshPage(); // Called when a scene is initially loaded, after all objects are populated.
  53. signals:
  54. void SaveClicked();
  55. void ResetSettings();
  56. void ClearChanges();
  57. void AssignScript();
  58. void InspectClicked();
  59. public slots:
  60. void AppendUnsavedChangesToTitle(bool hasUnsavedChanges);
  61. void EnableInspector(bool enableInspector);
  62. protected slots:
  63. //! Callback that's triggered when the add button only has 1 entry.
  64. void OnSingleGroupAdd();
  65. void AddEditMenu();
  66. protected:
  67. //! Callback that's triggered when the add button has multiple entries.
  68. virtual void OnMultiGroupAdd(const Uuid& id);
  69. virtual void OnHelpButtonClicked();
  70. virtual void BuildAndConnectAddButton();
  71. virtual void BuildHelpButton();
  72. virtual AZStd::string ClassIdToName(const Uuid& id) const;
  73. virtual void AddNewObject(const Uuid& id);
  74. //! Report that an object on this page has been updated.
  75. //! @param object Pointer to the changed object. If the manifest itself has been update
  76. //! for instance after adding or removing a group use null to update the entire manifest.
  77. virtual void EmitObjectChanged(const DataTypes::IManifestObject* object = nullptr);
  78. // IPropertyEditorNotify Interface Methods
  79. void BeforePropertyModified(AzToolsFramework::InstanceDataNode* pNode) override;
  80. void AfterPropertyModified(AzToolsFramework::InstanceDataNode* pNode) override;
  81. void SetPropertyEditingActive(AzToolsFramework::InstanceDataNode* pNode) override;
  82. void SetPropertyEditingComplete(AzToolsFramework::InstanceDataNode* pNode) override;
  83. void SealUndoStack() override;
  84. // ManifestMetaInfoBus
  85. void ObjectUpdated(const Containers::Scene& scene, const DataTypes::IManifestObject* target, void* sender) override;
  86. void AddObjects(AZStd::vector<AZStd::shared_ptr<DataTypes::IManifestObject>>& objects) override;
  87. void UpdateAddButtonStatus();
  88. bool SetNodeReadOnlyStatus(const AzToolsFramework::InstanceDataNode* node);
  89. AZStd::vector<AZ::Uuid> m_classTypeIds;
  90. AZStd::vector<AZStd::shared_ptr<DataTypes::IManifestObject>> m_objects;
  91. QScopedPointer<Ui::ManifestWidgetPage> ui;
  92. AzToolsFramework::ReflectedPropertyEditor* m_propertyEditor;
  93. SerializeContext* m_context;
  94. size_t m_capSize;
  95. QString m_helpUrl;
  96. QMenu* m_editMenu;
  97. bool m_scrollToBottomQueued = false;
  98. };
  99. } // namespace UI
  100. } // namespace SceneAPI
  101. } // namespace AZ