ImguiAtomSystemComponent.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #include <AzCore/Component/Component.h>
  10. #include <AzCore/Component/TickBus.h>
  11. #include <DebugConsole.h>
  12. #include <Atom/RPI.Public/ViewportContextBus.h>
  13. namespace AZ
  14. {
  15. namespace LYIntegration
  16. {
  17. class ImGuiFeatureProcessor;
  18. //! When Atom is enabled, ImGuiManager from LY's ImGui gem will hand over drawing of ImGui via @OtherActiveImGuiRequestBus to this system component.
  19. //! Note: The LY ImGui gem only supports a single ImGui context, so Atom must have a single ImGui pass marked as the default.
  20. class ImguiAtomSystemComponent final
  21. : public AZ::Component
  22. , public AZ::RPI::ViewportContextNotificationBus::Handler
  23. {
  24. public:
  25. AZ_COMPONENT(ImguiAtomSystemComponent, "{D423E075-D971-435A-A9C1-57C3B0623A9B}");
  26. static void Reflect(AZ::ReflectContext* context);
  27. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  28. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  29. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatbile);
  30. ~ImguiAtomSystemComponent() override = default;
  31. // AZ::Component
  32. void Activate() override;
  33. void Deactivate() override;
  34. private:
  35. void InitializeViewportSizeIfNeeded();
  36. // ViewportContextNotificationBus overrides...
  37. void OnRenderTick() override;
  38. void OnViewportSizeChanged(AzFramework::WindowSize size) override;
  39. void OnViewportDpiScalingChanged(float dpiScale) override;
  40. DebugConsole m_debugConsole;
  41. bool m_initialized = false;
  42. };
  43. } // namespace LYIntegration
  44. } // namespace AZ