BlendTreeRotationLimitHandler.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 <QWidget>
  12. #include <QPushButton>
  13. #include <QGridLayout>
  14. #include <QLabel>
  15. #include <EMotionFX/Source/BlendTreeRotationLimitNode.h>
  16. #include <AzQtComponents/Components/Widgets/SpinBox.h>
  17. #include <AzCore/std/containers/array.h>
  18. #endif
  19. namespace EMotionFX
  20. {
  21. class RotationLimitWdget : public QWidget
  22. {
  23. Q_OBJECT //AUTOMOC
  24. public:
  25. AZ_CLASS_ALLOCATOR_DECL
  26. RotationLimitWdget(QWidget* parent);
  27. void SetRotationLimit(const BlendTreeRotationLimitNode::RotationLimit& rotationLimit);
  28. void UpdateGui();
  29. float GetMin() const;
  30. float GetMax() const;
  31. signals:
  32. void DataChanged();
  33. private slots:
  34. void HandleMinValueChanged(double value);
  35. void HandleMaxValueChanged(double value);
  36. private:
  37. static const int s_decimalPlaces;
  38. QString m_tooltipText;
  39. AzQtComponents::DoubleSpinBox* m_spinBoxMin = nullptr;
  40. AzQtComponents::DoubleSpinBox* m_spinBoxMax = nullptr;
  41. const BlendTreeRotationLimitNode::RotationLimit* m_rotationLimit = nullptr;
  42. };
  43. class BlendTreeRotationLimitHandler
  44. : public QObject,
  45. public AzToolsFramework::PropertyHandler<BlendTreeRotationLimitNode::RotationLimit, RotationLimitWdget>
  46. {
  47. Q_OBJECT
  48. public:
  49. AZ_CLASS_ALLOCATOR_DECL
  50. // Method to create the new widget - returns a GrowTextEdit*
  51. QWidget* CreateGUI(QWidget* parent) override;
  52. bool AutoDelete() const override { return false; }
  53. // Method to return the name of the new handler - returns AZ::Edit::UIHandlers::MultiLineEdit, so it can be used
  54. // by when reflecting properties
  55. AZ::u32 GetHandlerName() const override;
  56. // Method used to parse attributes specified when a property is reflected, to configure the
  57. // the property handler
  58. void ConsumeAttribute(RotationLimitWdget* widget, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
  59. // Used to pull the values out of the widget
  60. void WriteGUIValuesIntoProperty(size_t index, RotationLimitWdget* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
  61. // Used to set the values on the widget
  62. bool ReadValuesIntoGUI(size_t index, RotationLimitWdget* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
  63. };
  64. class RotationLimitContainerWdget : public QWidget
  65. {
  66. Q_OBJECT //AUTOMOC
  67. public:
  68. AZ_CLASS_ALLOCATOR_DECL
  69. RotationLimitContainerWdget(QWidget* parent);
  70. };
  71. class BlendTreeRotationLimitContainerHandler
  72. : public QObject,
  73. public AzToolsFramework::PropertyHandler<AZStd::array<BlendTreeRotationLimitNode::RotationLimit, 3>, RotationLimitContainerWdget>
  74. {
  75. Q_OBJECT
  76. public:
  77. AZ_CLASS_ALLOCATOR_DECL
  78. // Method to create the new widget - returns a GrowTextEdit*
  79. QWidget* CreateGUI(QWidget* parent) override;
  80. bool AutoDelete() const override { return false; }
  81. // Method to return the name of the new handler - returns AZ::Edit::UIHandlers::MultiLineEdit, so it can be used
  82. // by when reflecting properties
  83. AZ::u32 GetHandlerName() const override;
  84. // Method used to parse attributes specified when a property is reflected, to configure the
  85. // the property handler
  86. void ConsumeAttribute(RotationLimitContainerWdget* widget, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
  87. // Used to pull the values out of the widget
  88. void WriteGUIValuesIntoProperty(size_t index, RotationLimitContainerWdget* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
  89. // Used to set the values on the widget
  90. bool ReadValuesIntoGUI(size_t index, RotationLimitContainerWdget* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
  91. };
  92. }