PropertyHandlerAnchor.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 <AzCore/base.h>
  11. #include <AzCore/Memory/SystemAllocator.h>
  12. #include <AzToolsFramework/UI/PropertyEditor/PropertyVectorCtrl.hxx>
  13. #include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
  14. #include <LyShine/UiBase.h>
  15. #include <LyShine/Bus/UiTransform2dBus.h>
  16. #endif
  17. class AnchorPresetsWidget;
  18. class PropertyAnchorCtrl
  19. : public QWidget
  20. {
  21. Q_OBJECT
  22. public:
  23. AZ_CLASS_ALLOCATOR(PropertyAnchorCtrl, AZ::SystemAllocator);
  24. PropertyAnchorCtrl(QWidget* parent = nullptr);
  25. void ConsumeAttribute(AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName);
  26. AnchorPresetsWidget* GetAnchorPresetsWidget();
  27. AzQtComponents::VectorInput* GetPropertyVectorCtrl();
  28. bool IsReadOnly() { return m_isReadOnly; }
  29. private:
  30. AzToolsFramework::VectorPropertyHandlerCommon m_common;
  31. AzQtComponents::VectorInput* m_propertyVectorCtrl;
  32. AnchorPresetsWidget* m_anchorPresetsWidget;
  33. QLabel* m_disabledLabel;
  34. QLabel* m_controlledByFitterLabel;
  35. bool m_isReadOnly;
  36. };
  37. //-------------------------------------------------------------------------------
  38. class PropertyHandlerAnchor
  39. : public AzToolsFramework::PropertyHandler < UiTransform2dInterface::Anchors, PropertyAnchorCtrl >
  40. {
  41. public:
  42. AZ_CLASS_ALLOCATOR(PropertyHandlerAnchor, AZ::SystemAllocator);
  43. AZ::u32 GetHandlerName(void) const override { return AZ_CRC_CE("Anchor"); }
  44. bool IsDefaultHandler() const override { return true; }
  45. QWidget* CreateGUI(QWidget* pParent) override;
  46. void ConsumeAttribute(PropertyAnchorCtrl* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
  47. void WriteGUIValuesIntoProperty(size_t index, PropertyAnchorCtrl* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
  48. bool ReadValuesIntoGUI(size_t index, PropertyAnchorCtrl* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
  49. bool ModifyTooltip(QWidget* widget, QString& toolTipString) override;
  50. AZ::EntityId GetParentEntityId(AzToolsFramework::InstanceDataNode* node, size_t index);
  51. static void Register();
  52. };