-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathUIManager.h
More file actions
177 lines (147 loc) · 3.83 KB
/
UIManager.h
File metadata and controls
177 lines (147 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/**
* @project: Overload
* @author: Overload Tech.
* @licence: MIT
*/
#pragma once
#include <string>
#include <unordered_map>
#include "OvUI/Modules/Canvas.h"
#include "OvUI/Styling/EStyle.h"
namespace OvUI::Core
{
/**
* Handle the creation and drawing of the UI
*/
class UIManager
{
public:
/**
* Create the UI manager. Will setup ImGui internally\
* @param p_glfwWindow
* @param p_style
* @param p_glslVersion (Ex: #version 450)
*/
UIManager(GLFWwindow* p_glfwWindow, Styling::EStyle p_style = Styling::EStyle::IM_DARK_STYLE, std::string_view p_glslVersion = "#version 450");
/**
* Destroy the UI manager. Will handle ImGui destruction internally
*/
~UIManager();
/**
* Apply a new style to the UI elements
* @param p_style
*/
void ApplyStyle(Styling::EStyle p_style);
/**
* Load a font (Returns true on success)
* @param p_id
* @param p_path
* @param p_fontSize
*/
bool LoadFont(const std::string& p_id, const std::string& p_path, float p_fontSize);
/**
* Unload a font (Returns true on success)
* @param p_id
*/
bool UnloadFont(const std::string& p_id);
/**
* Set the given font as the current one (Returns true on success)
*/
bool UseFont(const std::string& p_id);
/**
* Use the default font (ImGui default font)
*/
void UseDefaultFont();
/**
* Allow the user to enable/disable .ini generation to save his editor layout
* @param p_value
*/
void EnableEditorLayoutSave(bool p_value);
/**
* Return true if the editor layout save system is on
*/
bool IsEditorLayoutSaveEnabled() const;
/**
* Defines a filename for the editor layout save file
*/
void SetEditorLayoutSaveFilename(const std::string& p_filename);
/**
* Defines a frequency (in seconds) for the auto saving system of the editor layout
* @param p_frequency
*/
void SetEditorLayoutAutosaveFrequency(float p_frequency);
/**
* Returns the current frequency (in seconds) for the auto saving system of the editor layout
*/
float GetEditorLayoutAutosaveFrequency(float p_frequeny);
/**
* Enable the docking system
* @param p_value
*/
void EnableDocking(bool p_value);
/**
* Reset the UI layout to the given configuration file
* @param p_config
*/
void ResetLayout(const std::string& p_config) const;
/**
* Load the UI layout from the given configuration file
* @param p_fileName
*/
void LoadLayout(const std::string& p_fileName);
/**
* Save the UI layout to the given configuration file
* @param p_fileName
*/
void SaveLayout(const std::string& p_fileName);
/**
* Save the current UI layout to the last used configuration file
*/
void SaveCurrentLayout();
/**
* Set and load the UI layout from the given configuration file
* @param p_fileName
*/
void SetLayout(const std::string& p_fileName);
/**
* Delete the UI layout configuration file
* @param p_fileName
*/
void DeleteLayout(const std::string& p_fileName);
/**
* Rename a UI layout configuration file
* @param p_fileName
* @param p_newFileName
*/
void RenameLayout(const std::string& p_fileName, const std::string& p_newFileName);
/**
* Return true if the docking system is enabled
*/
bool IsDockingEnabled() const;
/**
* Defines the canvas to use
* @param p_canvas
*/
void SetCanvas(Modules::Canvas& p_canvas);
/**
* Stop considering the current canvas (if any)
*/
void RemoveCanvas();
/**
* Render ImGui current frane
* @note Should be called once per frame
*/
void Render();
std::string GetLayoutsPath();
private:
void PushCurrentFont();
void PopCurrentFont();
private:
bool m_dockingState;
Modules::Canvas* m_currentCanvas = nullptr;
std::unordered_map<std::string, ImFont*> m_fonts;
std::string m_layoutSaveFilename = "imgui.ini";
const std::string m_defaultLayout;
const std::string m_layoutsPath;
};
}