ReadOnlyNodePropertyDisplay.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. #include <Components/NodePropertyDisplays/ReadOnlyNodePropertyDisplay.h>
  9. #include <Widgets/GraphCanvasLabel.h>
  10. namespace GraphCanvas
  11. {
  12. ////////////////////////////////
  13. // ReadOnlyNodePropertyDisplay
  14. ////////////////////////////////
  15. ReadOnlyNodePropertyDisplay::ReadOnlyNodePropertyDisplay(ReadOnlyDataInterface* dataInterface)
  16. : NodePropertyDisplay(dataInterface)
  17. , m_dataInterface(dataInterface)
  18. {
  19. m_disabledLabel = aznew GraphCanvasLabel();
  20. m_displayLabel = aznew GraphCanvasLabel();
  21. }
  22. ReadOnlyNodePropertyDisplay::~ReadOnlyNodePropertyDisplay()
  23. {
  24. delete m_dataInterface;
  25. delete m_displayLabel;
  26. delete m_disabledLabel;
  27. }
  28. void ReadOnlyNodePropertyDisplay::RefreshStyle()
  29. {
  30. m_disabledLabel->SetSceneStyle(GetSceneId(), NodePropertyDisplay::CreateDisabledLabelStyle("readOnly").c_str());
  31. m_displayLabel->SetSceneStyle(GetSceneId(), NodePropertyDisplay::CreateDisplayLabelStyle("readOnly").c_str());
  32. }
  33. void ReadOnlyNodePropertyDisplay::UpdateDisplay()
  34. {
  35. AZStd::string value = m_dataInterface->GetString();
  36. m_displayLabel->SetLabel(value);
  37. m_displayLabel->setToolTip(value.c_str());
  38. }
  39. QGraphicsLayoutItem* ReadOnlyNodePropertyDisplay::GetDisabledGraphicsLayoutItem()
  40. {
  41. return m_disabledLabel;
  42. }
  43. QGraphicsLayoutItem* ReadOnlyNodePropertyDisplay::GetDisplayGraphicsLayoutItem()
  44. {
  45. return m_displayLabel;
  46. }
  47. QGraphicsLayoutItem* ReadOnlyNodePropertyDisplay::GetEditableGraphicsLayoutItem()
  48. {
  49. return m_displayLabel;
  50. }
  51. void ReadOnlyNodePropertyDisplay::OnDragDropStateStateChanged(const DragDropState& dragState)
  52. {
  53. Styling::StyleHelper& styleHelper = m_displayLabel->GetStyleHelper();
  54. UpdateStyleForDragDrop(dragState, styleHelper);
  55. m_displayLabel->update();
  56. }
  57. }