ImGuiSidebar.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 <AzFramework/Windowing/WindowBus.h>
  10. struct ImGuiContext;
  11. namespace AtomSampleViewer
  12. {
  13. class ImGuiSidebar
  14. {
  15. public:
  16. static void Reflect(AZ::ReflectContext* context);
  17. ImGuiSidebar() = default;
  18. /// @param configFilePath - Path to a local json file for maintaining state between runs. Should start with "@user@/"
  19. explicit ImGuiSidebar(AZStd::string_view configFilePath);
  20. void Activate();
  21. void Deactivate();
  22. void SetHideSidebar(bool isHidden);
  23. bool Begin();
  24. void End();
  25. private:
  26. struct ConfigFile final
  27. {
  28. AZ_TYPE_INFO(ImGuiSidebar::ConfigFile, "{8B5F54D4-1DE8-4476-AE2F-80B2EE02E0A1}");
  29. AZ_CLASS_ALLOCATOR(ConfigFile, AZ::SystemAllocator, 0);
  30. static void Reflect(AZ::ReflectContext* context);
  31. float m_width = 300.0f;
  32. };
  33. AzFramework::WindowSize BeginFrame();
  34. void EndFrame();
  35. bool LoadConfigFile();
  36. void SaveConfigFile();
  37. static const float s_widthMin;
  38. static const float s_widthMax;
  39. static const float s_widthStepSmall;
  40. static const float s_widthStepBig;
  41. bool m_hideSidebar = false;
  42. bool m_isSidebarReady = false;
  43. AZStd::string m_configFilePath;
  44. ConfigFile m_configFile;
  45. };
  46. } // namespace AtomSampleViewer