CollisionLayersWidget.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 <AzFramework/Physics/Collision/CollisionLayers.h>
  11. #include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI_Internals.h>
  12. #include <AzToolsFramework/UI/PropertyEditor/ReflectedPropertyEditor.hxx>
  13. #include <QWidget>
  14. #endif
  15. namespace AzToolsFramework
  16. {
  17. class ReflectedPropertyEditor;
  18. }
  19. namespace PhysX
  20. {
  21. namespace Editor
  22. {
  23. class CollisionLayersWidget
  24. : public QWidget
  25. , private AzToolsFramework::IPropertyEditorNotify
  26. {
  27. Q_OBJECT
  28. public:
  29. AZ_CLASS_ALLOCATOR(CollisionLayersWidget, AZ::SystemAllocator);
  30. static const AZ::u32 s_maxCollisionLayerNameLength = 32;
  31. static const AZStd::string s_defaultCollisionLayerName;
  32. explicit CollisionLayersWidget(QWidget* parent = nullptr);
  33. void SetValue(const AzPhysics::CollisionLayers& layers);
  34. const AzPhysics::CollisionLayers& GetValue() const;
  35. signals:
  36. void onValueChanged(const AzPhysics::CollisionLayers& newValue);
  37. private:
  38. void CreatePropertyEditor(QWidget* parent);
  39. void BeforePropertyModified(AzToolsFramework::InstanceDataNode* /*node*/) override;
  40. void AfterPropertyModified(AzToolsFramework::InstanceDataNode* /*node*/) override;
  41. void SetPropertyEditingActive(AzToolsFramework::InstanceDataNode* /*node*/) override;
  42. void SetPropertyEditingComplete(AzToolsFramework::InstanceDataNode* /*node*/) override;
  43. void SealUndoStack() override;
  44. void SetWidgetParameters();
  45. /**
  46. * Checks if layer name at specified index is unique in the given array of layer names.
  47. * @return true if the layer name modified to be unique, false otherwise.
  48. */
  49. bool ForceUniqueLayerName(AZ::u32 layerIndex
  50. , const AZStd::array<AZStd::string, AzPhysics::CollisionLayers::MaxCollisionLayers>& layerNames
  51. , AZStd::string& uniqueLayerNameOut);
  52. /**
  53. * Checks if layer name at specified index is unique in the given array of layer names.
  54. * @return true if the layer name is unique, false otherwise.
  55. */
  56. bool IsLayerNameUnique(AZ::u32 layerIndex,
  57. const AZStd::array<AZStd::string, AzPhysics::CollisionLayers::MaxCollisionLayers>& layerNames);
  58. AzToolsFramework::ReflectedPropertyEditor* m_propertyEditor;
  59. AzPhysics::CollisionLayers m_value;
  60. };
  61. } // namespace Editor
  62. } // namespace PhysX