BooleanNodePropertyDisplay.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 <QComboBox>
  9. #include <QGraphicsProxyWidget>
  10. #include <QPushButton>
  11. #include <Components/NodePropertyDisplays/BooleanNodePropertyDisplay.h>
  12. #include <Widgets/GraphCanvasCheckBox.h>
  13. #include <Widgets/GraphCanvasLabel.h>
  14. namespace GraphCanvas
  15. {
  16. ///////////////////////////////
  17. // BooleanNodePropertyDisplay
  18. ///////////////////////////////
  19. BooleanNodePropertyDisplay::BooleanNodePropertyDisplay(BooleanDataInterface* dataInterface)
  20. : NodePropertyDisplay(dataInterface)
  21. , m_dataInterface(dataInterface)
  22. , m_checkBox(nullptr)
  23. {
  24. m_disabledLabel = aznew GraphCanvasLabel();
  25. m_checkBox = aznew GraphCanvasCheckBox();
  26. GraphCanvasCheckBoxNotificationBus::Handler::BusConnect(m_checkBox);
  27. }
  28. BooleanNodePropertyDisplay::~BooleanNodePropertyDisplay()
  29. {
  30. GraphCanvasCheckBoxNotificationBus::Handler::BusDisconnect();
  31. delete m_dataInterface;
  32. delete m_checkBox;
  33. delete m_disabledLabel;
  34. }
  35. void BooleanNodePropertyDisplay::RefreshStyle()
  36. {
  37. m_disabledLabel->SetSceneStyle(GetSceneId(), NodePropertyDisplay::CreateDisabledLabelStyle("boolean").c_str());
  38. m_checkBox->SetSceneStyle(GetSceneId());
  39. }
  40. void BooleanNodePropertyDisplay::UpdateDisplay()
  41. {
  42. bool value = m_dataInterface->GetBool();
  43. m_checkBox->SetChecked(value);
  44. }
  45. QGraphicsLayoutItem* BooleanNodePropertyDisplay::GetDisabledGraphicsLayoutItem()
  46. {
  47. return m_disabledLabel;
  48. }
  49. QGraphicsLayoutItem* BooleanNodePropertyDisplay::GetDisplayGraphicsLayoutItem()
  50. {
  51. return m_checkBox;
  52. }
  53. QGraphicsLayoutItem* BooleanNodePropertyDisplay::GetEditableGraphicsLayoutItem()
  54. {
  55. return m_checkBox;
  56. }
  57. void BooleanNodePropertyDisplay::OnValueChanged(bool value)
  58. {
  59. m_dataInterface->SetBool(value);
  60. UpdateDisplay();
  61. }
  62. void BooleanNodePropertyDisplay::OnClicked()
  63. {
  64. TryAndSelectNode();
  65. }
  66. }