ezEngine  Milestone 9
DearImgui.h
1 #pragma once
2 
3 #include <Core/ResourceManager/ResourceHandle.h>
5 #include <Foundation/Math/Size.h>
6 #include <Foundation/Types/UniquePtr.h>
7 #include <GameEngine/GameEngineDLL.h>
8 #include <RendererCore/Pipeline/Declarations.h>
9 #include <ThirdParty/Imgui/imgui.h>
10 
12 
13 struct ImGuiContext;
14 
17 
29 class EZ_GAMEENGINE_DLL ezImgui
30 {
32 
33 public:
36  ~ezImgui();
37 
39  void SetCurrentContextForView(const ezViewHandle& hView);
40 
42  ezSizeU32 GetCurrentWindowResolution() const { return m_CurrentWindowResolution; }
43 
46  void SetPassInputToImgui(bool bPassInput) { m_bPassInputToImgui = bPassInput; }
47 
51  bool WantsInput() const { return m_bImguiWantsInput; }
52 
54  ImFontAtlas& GetFontAtlas() { return *m_pSharedFontAtlas; }
55 
56 private:
57  friend class ezImguiExtractor;
58  friend class ezImguiRenderer;
59 
60  void Startup(ezImguiConfigFontCallback configFontCallback);
61  void Shutdown();
62 
63  ImGuiContext* CreateContext();
64  void BeginFrame(const ezViewHandle& hView);
65 
66  bool m_bPassInputToImgui = true;
67  bool m_bImguiWantsInput = false;
68  ezSizeU32 m_CurrentWindowResolution;
70 
71  ezImguiConfigStyleCallback m_ConfigStyleCallback;
72 
73  ezUniquePtr<ImFontAtlas> m_pSharedFontAtlas;
74 
75  struct Context
76  {
77  ImGuiContext* m_pImGuiContext = nullptr;
78  ezUInt64 m_uiFrameBeginCounter = -1;
79  ezUInt64 m_uiFrameRenderCounter = -1;
80  };
81 
82  ezHashTable<ezViewHandle, Context> m_ViewToContextTable;
83 };
84 
#define EZ_DECLARE_SINGLETON(self)
Insert this into a class declaration to turn the class into a singleton.
Definition: Singleton.h:63
ezSizeU32 GetCurrentWindowResolution() const
Returns the value that was passed to BeginFrame(). Useful for positioning UI elements.
Definition: DearImgui.h:42
Definition: HybridArray.h:79
ImFontAtlas & GetFontAtlas()
Returns the shared font atlas.
Definition: DearImgui.h:54
Singleton class through which one can control the third-party library &#39;Dear Imgui&#39;.
Definition: DearImgui.h:29
Definition: DearImguiRenderer.h:54
Definition: DearImguiRenderer.h:44
bool WantsInput() const
If this returns true, the GUI wants to use the input, and thus you might want to not use the input fo...
Definition: DearImgui.h:51
Definition: Declarations.h:53
A generic delegate class which supports static functions and member functions.
Definition: MathExpression.h:11
void SetPassInputToImgui(bool bPassInput)
When this is disabled, the GUI will be rendered, but it will not react to any input. Useful if something else shall get exclusive input.
Definition: DearImgui.h:46