CGUIManager.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include <ionMath.h>
5 #include <ionFramework.h>
6 #include <ionWindow.h>
7 #include <ionGraphics.h>
8 
9 #include "imGUI.h"
10 
11 
12 namespace ion
13 {
14 
15  ImVec2 ToImGui(vec2f const & v);
16  vec2f ToIon(ImVec2 const & v);
17 
18  class CGUIManager : public Singleton<CGUIManager>, public IEventListener
19  {
20 
21  public:
22 
23  bool Init(CWindow * Window);
24  void Shutdown();
25  void NewFrame();
26  void Draw();
27 
28  template <typename... Args>
29  void Text(vec2i const & Position, color3i const & Color, char const * const Format, Args const &... args)
30  {
31  TextUnformatted(Position, Color, tfm::format(Format, args...));
32  }
33 
34  void TextUnformatted(vec2i const & Position, color3i const & Color, string const & Text);
35 
36  void OnEvent(IEvent & Event);
37  void AddFontFromFile(string const & FileName, float const Size);
38  static ImTextureID GetTextureID(SharedPointer<Graphics::ITexture2D> const Texture);
39 
40  ImGuiIO & IO = ImGui::GetIO();
41 
42  protected:
43 
44  void DrawCallback(ImDrawData* draw_data);
45  void CreateFontsTexture();
46  bool CreateDeviceObjects();
47 
48  size_t const StartVboMaxSize = 20000;
49 
50  CWindow * Window = nullptr;
51  double Time = 0;
52  bool MousePressed[3];
53  float MouseWheel = 0;
55  int ShaderHandle = 0, VertHandle = 0, FragHandle = 0;
59 
60  struct SDrawText
61  {
64  string Text;
65  };
66 
67  vector<SDrawText> TextQueue;
68 
69  private:
70 
71  friend class Singleton<CGUIManager>;
72 
73  CGUIManager();
74 
75  friend void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data);
76  friend char const * ImGui_ImplGlfwGL3_GetClipboardText(void * user_data);
77  friend void ImGui_ImplGlfwGL3_SetClipboardText(void * user_data, char const * text);
78 
79  };
80 
81 }
void Shutdown()
Definition: CGUIManager.cpp:322
Definition: SColor.h:8
void DrawCallback(ImDrawData *draw_data)
Definition: CGUIManager.cpp:13
color3i Color
Definition: CGUIManager.h:63
void CreateFontsTexture()
Definition: CGUIManager.cpp:150
bool CreateDeviceObjects()
Definition: CGUIManager.cpp:183
int AttribLocationPosition
Definition: CGUIManager.h:57
std::shared_ptr< T > SharedPointer
Definition: ionSmartPointer.h:22
CWindow * Window
Definition: CGUIManager.h:50
void OnEvent(IEvent &Event)
Definition: CGUIManager.cpp:107
int AttribLocationTex
Definition: CGUIManager.h:56
Customized variant of vec3 that intelligently handles conversion between floating point and integer c...
Definition: SColor.h:67
void Draw()
Definition: CGUIManager.cpp:400
uint VboHandle
Definition: CGUIManager.h:58
string Text
Definition: CGUIManager.h:64
uint ElementsHandle
Definition: CGUIManager.h:58
unsigned int uint
Definition: ionTypes.h:99
static ImTextureID GetTextureID(SharedPointer< Graphics::ITexture2D > const Texture)
Definition: CGUIManager.cpp:177
void NewFrame()
Definition: CGUIManager.cpp:352
Definition: CCatmullRomAdvancedSplineInterpolator.h:7
void AddFontFromFile(string const &FileName, float const Size)
Definition: CGUIManager.cpp:171
uint VaoHandle
Definition: CGUIManager.h:58
Definition: IEvent.h:7
friend char const * ImGui_ImplGlfwGL3_GetClipboardText(void *user_data)
Definition: CGUIManager.cpp:278
bool Init(CWindow *Window)
Definition: CGUIManager.cpp:290
Definition: CWindow.h:17
friend void ImGui_ImplGlfwGL3_SetClipboardText(void *user_data, char const *text)
Definition: CGUIManager.cpp:284
Definition: IEventListener.h:8
float MouseWheel
Definition: CGUIManager.h:53
int AttribLocationColor
Definition: CGUIManager.h:57
vec2i Position
Definition: CGUIManager.h:62
void Text(vec2i const &Position, color3i const &Color, char const *const Format, Args const &...args)
Definition: CGUIManager.h:29
size_t const StartVboMaxSize
Definition: CGUIManager.h:48
int AttribLocationProjMtx
Definition: CGUIManager.h:56
friend void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData *draw_data)
Definition: CGUIManager.cpp:272
double Time
Definition: CGUIManager.h:51
int VertHandle
Definition: CGUIManager.h:55
Base class for Singleton design pattern implementation.
Definition: ionClass.h:90
void TextUnformatted(vec2i const &Position, color3i const &Color, string const &Text)
Definition: CGUIManager.cpp:423
vec2f ToIon(ImVec2 const &v)
Definition: CGUIManager.cpp:267
int ShaderHandle
Definition: CGUIManager.h:55
ImVec2 ToImGui(vec2f const &v)
Definition: CGUIManager.cpp:262
bool MousePressed[3]
Definition: CGUIManager.h:52
int FragHandle
Definition: CGUIManager.h:55
ImGuiIO & IO
Definition: CGUIManager.h:40
Definition: CGUIManager.h:60
vector< SDrawText > TextQueue
Definition: CGUIManager.h:67
uint FontTexture
Definition: CGUIManager.h:54
int AttribLocationUV
Definition: CGUIManager.h:57
Definition: CGUIManager.h:18