HeaderHandler.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 <AzCore/EBus/EBus.h>
  9. #include <SceneAPI/SceneUI/RowWidgets/HeaderHandler.h>
  10. namespace AZ
  11. {
  12. namespace SceneAPI
  13. {
  14. namespace UI
  15. {
  16. AZ_CLASS_ALLOCATOR_IMPL(HeaderHandler, SystemAllocator);
  17. HeaderHandler* HeaderHandler::s_instance = nullptr;
  18. QWidget* HeaderHandler::CreateGUI(QWidget* parent)
  19. {
  20. return aznew HeaderWidget(parent);
  21. }
  22. u32 HeaderHandler::GetHandlerName() const
  23. {
  24. return AZ_CRC_CE("Header");
  25. }
  26. bool HeaderHandler::AutoDelete() const
  27. {
  28. return false;
  29. }
  30. bool HeaderHandler::IsDefaultHandler() const
  31. {
  32. return true;
  33. }
  34. void HeaderHandler::ConsumeAttribute(HeaderWidget* /*widget*/, u32 /*attrib*/,
  35. AzToolsFramework::PropertyAttributeReader* /*attrValue*/, const char* /*debugName*/)
  36. {
  37. // No attributes are used by this handler, but the function is mandatory.
  38. }
  39. void HeaderHandler::WriteGUIValuesIntoProperty(size_t /*index*/, HeaderWidget* GUI,
  40. property_t& instance, AzToolsFramework::InstanceDataNode* /*node*/)
  41. {
  42. instance = *GUI->GetManifestObject();
  43. }
  44. bool HeaderHandler::ReadValuesIntoGUI(size_t /*index*/, HeaderWidget* GUI, const property_t& instance,
  45. AzToolsFramework::InstanceDataNode* /*node*/)
  46. {
  47. GUI->SetManifestObject(&instance);
  48. return false;
  49. }
  50. void HeaderHandler::Register()
  51. {
  52. if (!s_instance)
  53. {
  54. s_instance = aznew HeaderHandler();
  55. EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, s_instance);
  56. }
  57. }
  58. void HeaderHandler::Unregister()
  59. {
  60. if (s_instance)
  61. {
  62. EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, UnregisterPropertyType, s_instance);
  63. delete s_instance;
  64. s_instance = nullptr;
  65. }
  66. }
  67. bool HeaderHandler::ModifyTooltip(QWidget* widget, QString& toolTipString)
  68. {
  69. HeaderWidget* headerWidget = qobject_cast<HeaderWidget*>(widget);
  70. if (!headerWidget)
  71. {
  72. return false;
  73. }
  74. return headerWidget->ModifyTooltip(toolTipString);
  75. }
  76. } // UI
  77. } // SceneAPI
  78. } // AZ
  79. #include <RowWidgets/moc_HeaderHandler.cpp>