SimulatedObjectSelectionHandler.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #endif
  16. namespace EMotionFX
  17. {
  18. class SimulatedObjectPicker
  19. : public QWidget
  20. {
  21. Q_OBJECT // AUTOMOC
  22. public:
  23. AZ_CLASS_ALLOCATOR_DECL
  24. SimulatedObjectPicker(QWidget* parent);
  25. ~SimulatedObjectPicker() = default;
  26. // Called when the UI wants to update the simulated objects
  27. void UpdateSimulatedObjects(const AZStd::vector<AZStd::string>& simulatedObjectNames);
  28. void SetSimulatedObjects(const AZStd::vector<AZStd::string>& simulatedObjectNames);
  29. const AZStd::vector<AZStd::string>& GetSimulatedObjects() const;
  30. signals:
  31. void SelectionChanged(const AZStd::vector<AZStd::string>& newSimualtedObjectNames);
  32. private slots:
  33. void OnPickClicked();
  34. void OnResetClicked();
  35. private:
  36. void UpdateInterface();
  37. AZStd::vector<AZStd::string> m_simulatedObjectNames;
  38. QPushButton* m_pickButton = nullptr;
  39. QPushButton* m_resetButton = nullptr;
  40. };
  41. class SimulatedObjectSelectionHandler
  42. : public QObject
  43. , public AzToolsFramework::PropertyHandler<AZStd::vector<AZStd::string>, SimulatedObjectPicker>
  44. {
  45. Q_OBJECT // AUTOMOC
  46. public:
  47. AZ_CLASS_ALLOCATOR_DECL
  48. AZ::u32 GetHandlerName() const override;
  49. QWidget* CreateGUI(QWidget* parent) override;
  50. void ConsumeAttribute(SimulatedObjectPicker* widget, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
  51. void WriteGUIValuesIntoProperty(size_t index, SimulatedObjectPicker* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
  52. bool ReadValuesIntoGUI(size_t index, SimulatedObjectPicker* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
  53. };
  54. } // namespace EMotionFX