3
0

AnimGraphNodeNameHandler.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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.h>
  11. #include <Editor/LineEditValidatable.h>
  12. #endif
  13. namespace EMotionFX
  14. {
  15. class AnimGraphNode;
  16. class AnimGraphNodeNameLineEdit
  17. : public EMStudio::LineEditValidatable
  18. {
  19. Q_OBJECT // AUTOMOC
  20. public:
  21. AZ_CLASS_ALLOCATOR_DECL
  22. AnimGraphNodeNameLineEdit(QWidget* parent);
  23. ~AnimGraphNodeNameLineEdit() = default;
  24. void SetNode(AnimGraphNode* node);
  25. private:
  26. void focusInEvent(QFocusEvent* event) override;
  27. private:
  28. AnimGraphNode* m_node;
  29. };
  30. /**
  31. * The AnimGraphNodeNameHandler is a custom property handler for the name property of AnimGraphNodes.
  32. * It validates if the currently entered name candidate is unique and blocks a name change in case it isn't.
  33. */
  34. class AnimGraphNodeNameHandler
  35. : public QObject
  36. , public AzToolsFramework::PropertyHandler<AZStd::string, AnimGraphNodeNameLineEdit>
  37. {
  38. Q_OBJECT // AUTOMOC
  39. public:
  40. AZ_CLASS_ALLOCATOR_DECL
  41. AnimGraphNodeNameHandler();
  42. ~AnimGraphNodeNameHandler() = default;
  43. AZ::u32 GetHandlerName() const override;
  44. QWidget* CreateGUI(QWidget* parent) override;
  45. bool AutoDelete() const override { return false; }
  46. void ConsumeAttribute(AnimGraphNodeNameLineEdit* widget, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
  47. void WriteGUIValuesIntoProperty(size_t index, AnimGraphNodeNameLineEdit* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
  48. bool ReadValuesIntoGUI(size_t index, AnimGraphNodeNameLineEdit* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
  49. protected:
  50. AnimGraphNode* m_node;
  51. };
  52. } // namespace EMotionFX