ComboBoxNodePropertyDisplay.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. class QEvent;
  10. #include <AzCore/Component/EntityBus.h>
  11. #include <AzToolsFramework/UI/PropertyEditor/PropertyEntityIdCtrl.hxx>
  12. #include <GraphCanvas/Components/NodePropertyDisplay/NodePropertyDisplay.h>
  13. #include <GraphCanvas/Components/NodePropertyDisplay/ComboBoxDataInterface.h>
  14. #include <GraphCanvas/Components/MimeDataHandlerBus.h>
  15. #include <Widgets/GraphCanvasComboBox.h>
  16. namespace GraphCanvas
  17. {
  18. class GraphCanvasLabel;
  19. class ComboBoxGraphicsEventFilter;
  20. class ComboBoxNodePropertyDisplay
  21. : public NodePropertyDisplay
  22. , public GeometryNotificationBus::Handler
  23. , public ViewNotificationBus::Handler
  24. {
  25. friend class ComboBoxGraphicsEventFilter;
  26. public:
  27. AZ_CLASS_ALLOCATOR(ComboBoxNodePropertyDisplay, AZ::SystemAllocator, 0);
  28. ComboBoxNodePropertyDisplay(ComboBoxDataInterface* dataInterface);
  29. virtual ~ComboBoxNodePropertyDisplay();
  30. // Will color the outline of the label with the data type of the contained
  31. // type when enabled.
  32. void SetDataTypeOutlineEnabled(bool enableOutline);
  33. // NodePropertyDisplay
  34. void RefreshStyle() override;
  35. void UpdateDisplay() override;
  36. QGraphicsLayoutItem* GetDisabledGraphicsLayoutItem() override;
  37. QGraphicsLayoutItem* GetDisplayGraphicsLayoutItem() override;
  38. QGraphicsLayoutItem* GetEditableGraphicsLayoutItem() override;
  39. ////
  40. // GeometryNotificationBus
  41. void OnPositionChanged(const AZ::EntityId& targetEntity, const AZ::Vector2& position) override;
  42. ////
  43. // ViewNotificationBus
  44. void OnZoomChanged(qreal zoomLevel) override;
  45. ////
  46. // DataSlotNotifications
  47. void OnDisplayTypeChanged(const AZ::Uuid& dataTypes, const AZStd::vector<AZ::Uuid>& containerTypes) override;
  48. void OnDragDropStateStateChanged(const DragDropState& dragState) override;
  49. ////
  50. protected:
  51. void OnSlotIdSet() override;
  52. private:
  53. void UpdateOutlineColor();
  54. void ShowContextMenu(const QPoint&);
  55. void EditStart();
  56. void EditFinished();
  57. void SubmitValue();
  58. void SetupProxyWidget();
  59. void CleanupProxyWidget();
  60. void OnMenuAboutToDisplay();
  61. void UpdateMenuDisplay(const ViewId& viewId, bool forceUpdate = false);
  62. bool m_valueDirty;
  63. bool m_menuDisplayDirty;
  64. ComboBoxDataInterface* m_dataInterface;
  65. ComboBoxGraphicsEventFilter* m_eventFilter;
  66. GraphCanvasLabel* m_disabledLabel;
  67. GraphCanvasComboBox* m_comboBox;
  68. QGraphicsProxyWidget* m_proxyWidget;
  69. GraphCanvasLabel* m_displayLabel;
  70. bool m_dataTypeOutlineEnabled;
  71. };
  72. }