LODTreeSelectionHandler.cpp 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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/SceneCore/Containers/SceneGraph.h>
  10. #include <Editor/PropertyWidgets/LODTreeSelectionHandler.h>
  11. #include <Editor/PropertyWidgets/PropertyWidgetAllocator.h>
  12. namespace EMotionFX
  13. {
  14. namespace Pipeline
  15. {
  16. namespace UI
  17. {
  18. AZ_CLASS_ALLOCATOR_IMPL(LODTreeSelectionHandler, PropertyWidgetAllocator)
  19. QWidget* LODTreeSelectionHandler::CreateGUI(QWidget* parent)
  20. {
  21. LODTreeSelectionWidget* instance = aznew LODTreeSelectionWidget(parent);
  22. connect(instance, &LODTreeSelectionWidget::valueChanged, this,
  23. [instance]()
  24. {
  25. AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(
  26. &AzToolsFramework::PropertyEditorGUIMessages::Bus::Events::RequestWrite, instance);
  27. });
  28. return instance;
  29. }
  30. AZ::u32 LODTreeSelectionHandler::GetHandlerName() const
  31. {
  32. return AZ_CRC("LODTreeSelection", 0x25c27718);
  33. }
  34. bool LODTreeSelectionHandler::IsDefaultHandler() const
  35. {
  36. return false;
  37. }
  38. void LODTreeSelectionHandler::ConsumeAttribute(SceneUI::NodeTreeSelectionWidget* widget, AZ::u32 attrib,
  39. AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName)
  40. {
  41. // Note: debugName could be nullptr in some cases. We want to avoid passing a nullptr to the ConsumeAttribute function.
  42. AZStd::string debugNameStr;
  43. if(debugName)
  44. {
  45. debugNameStr = debugName;
  46. }
  47. SceneUI::NodeTreeSelectionHandler::ConsumeAttribute(widget, attrib, attrValue, debugNameStr.c_str());
  48. if (attrib == AZ_CRC("HideUncheckable", 0xa5bafb99))
  49. {
  50. ConsumeHideUncheckableAttribute(widget, attrValue);
  51. }
  52. }
  53. void LODTreeSelectionHandler::ConsumeHideUncheckableAttribute(SceneUI::NodeTreeSelectionWidget* widget, AzToolsFramework::PropertyAttributeReader * attrValue)
  54. {
  55. // Upcast to use the LODWidget.
  56. LODTreeSelectionWidget* LODWidget = static_cast<LODTreeSelectionWidget*>(widget);
  57. AZ_Error("EMotionFX", LODWidget, "LODTreeSelectionHandler must handles a LODTreeSelectionWidget.");
  58. bool hide;
  59. if (attrValue->Read<bool>(hide))
  60. {
  61. LODWidget->HideUncheckable(hide);
  62. }
  63. else
  64. {
  65. AZ_Assert(false, "Failed to read boolean from 'HideUncheckable' attribute.");
  66. }
  67. }
  68. }
  69. }
  70. }
  71. #include <Source/Editor/PropertyWidgets/moc_LODTreeSelectionHandler.cpp>