Voltray Engine Docs
Loading...
Searching...
No Matches
Theme.h
Go to the documentation of this file.
1#pragma once
2#include <string>
3#include <unordered_map>
4#include <memory>
5#include <vector>
6#include <imgui.h>
7
13namespace Editor::UI
14{
20 {
21 // Window colors
22 ImVec4 WindowBg = ImVec4(0.06f, 0.06f, 0.06f, 1.0f);
23 ImVec4 ChildBg = ImVec4(0.00f, 0.00f, 0.00f, 0.0f);
24 ImVec4 PopupBg = ImVec4(0.08f, 0.08f, 0.08f, 0.94f);
25
26 // Border colors
27 ImVec4 Border = ImVec4(0.43f, 0.43f, 0.50f, 0.50f);
28 ImVec4 BorderShadow = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
29
30 // Frame colors
31 ImVec4 FrameBg = ImVec4(0.16f, 0.29f, 0.48f, 0.54f);
32 ImVec4 FrameBgHovered = ImVec4(0.26f, 0.59f, 0.98f, 0.40f);
33 ImVec4 FrameBgActive = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
34
35 // Title colors
36 ImVec4 TitleBg = ImVec4(0.04f, 0.04f, 0.04f, 1.0f);
37 ImVec4 TitleBgActive = ImVec4(0.16f, 0.29f, 0.48f, 1.0f);
38 ImVec4 TitleBgCollapsed = ImVec4(0.00f, 0.00f, 0.00f, 0.51f);
39
40 // Menu colors
41 ImVec4 MenuBarBg = ImVec4(0.14f, 0.14f, 0.14f, 1.0f);
42
43 // Scrollbar colors
44 ImVec4 ScrollbarBg = ImVec4(0.02f, 0.02f, 0.02f, 0.53f);
45 ImVec4 ScrollbarGrab = ImVec4(0.31f, 0.31f, 0.31f, 1.0f);
46 ImVec4 ScrollbarGrabHovered = ImVec4(0.41f, 0.41f, 0.41f, 1.0f);
47 ImVec4 ScrollbarGrabActive = ImVec4(0.51f, 0.51f, 0.51f, 1.0f);
48
49 // Button colors
50 ImVec4 Button = ImVec4(0.26f, 0.59f, 0.98f, 0.40f);
51 ImVec4 ButtonHovered = ImVec4(0.26f, 0.59f, 0.98f, 1.0f);
52 ImVec4 ButtonActive = ImVec4(0.06f, 0.53f, 0.98f, 1.0f);
53
54 // Header colors
55 ImVec4 Header = ImVec4(0.26f, 0.59f, 0.98f, 0.31f);
56 ImVec4 HeaderHovered = ImVec4(0.26f, 0.59f, 0.98f, 0.80f);
57 ImVec4 HeaderActive = ImVec4(0.26f, 0.59f, 0.98f, 1.0f);
58
59 // Separator colors
60 ImVec4 Separator = ImVec4(0.43f, 0.43f, 0.50f, 0.50f);
61 ImVec4 SeparatorHovered = ImVec4(0.10f, 0.40f, 0.75f, 0.78f);
62 ImVec4 SeparatorActive = ImVec4(0.10f, 0.40f, 0.75f, 1.0f);
63
64 // Resize grip colors
65 ImVec4 ResizeGrip = ImVec4(0.26f, 0.59f, 0.98f, 0.20f);
66 ImVec4 ResizeGripHovered = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
67 ImVec4 ResizeGripActive = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
68
69 // Tab colors
70 ImVec4 Tab = ImVec4(0.18f, 0.35f, 0.58f, 0.86f);
71 ImVec4 TabHovered = ImVec4(0.26f, 0.59f, 0.98f, 0.80f);
72 ImVec4 TabActive = ImVec4(0.20f, 0.41f, 0.68f, 1.0f);
73 ImVec4 TabUnfocused = ImVec4(0.07f, 0.10f, 0.15f, 0.97f);
74 ImVec4 TabUnfocusedActive = ImVec4(0.14f, 0.26f, 0.42f, 1.0f);
75
76 // Docking colors
77 ImVec4 DockingPreview = ImVec4(0.26f, 0.59f, 0.98f, 0.70f);
78 ImVec4 DockingEmptyBg = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
79
80 // Plot colors
81 ImVec4 PlotLines = ImVec4(0.61f, 0.61f, 0.61f, 1.0f);
82 ImVec4 PlotLinesHovered = ImVec4(1.00f, 0.43f, 0.35f, 1.0f);
83 ImVec4 PlotHistogram = ImVec4(0.90f, 0.70f, 0.00f, 1.0f);
84 ImVec4 PlotHistogramHovered = ImVec4(1.00f, 0.60f, 0.00f, 1.0f);
85
86 // Table colors
87 ImVec4 TableHeaderBg = ImVec4(0.19f, 0.19f, 0.20f, 1.0f);
88 ImVec4 TableBorderStrong = ImVec4(0.31f, 0.31f, 0.35f, 1.0f);
89 ImVec4 TableBorderLight = ImVec4(0.23f, 0.23f, 0.25f, 1.0f);
90 ImVec4 TableRowBg = ImVec4(0.00f, 0.00f, 0.00f, 0.0f);
91 ImVec4 TableRowBgAlt = ImVec4(1.00f, 1.00f, 1.00f, 0.06f);
92
93 // Text colors
94 ImVec4 Text = ImVec4(1.00f, 1.00f, 1.00f, 1.0f);
95 ImVec4 TextDisabled = ImVec4(0.50f, 0.50f, 0.50f, 1.0f);
96 ImVec4 TextSelectedBg = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
97
98 // Drag drop colors
99 ImVec4 DragDropTarget = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
100
101 // Navigation colors
102 ImVec4 NavHighlight = ImVec4(0.26f, 0.59f, 0.98f, 1.0f);
103 ImVec4 NavWindowingHighlight = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
104 ImVec4 NavWindowingDimBg = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
105
106 // Modal colors
107 ImVec4 ModalWindowDimBg = ImVec4(0.80f, 0.80f, 0.80f, 0.35f);
108
109 // Check mark
110 ImVec4 CheckMark = ImVec4(0.26f, 0.59f, 0.98f, 1.0f);
111
112 // Slider colors
113 ImVec4 SliderGrab = ImVec4(0.24f, 0.52f, 0.88f, 1.0f);
114 ImVec4 SliderGrabActive = ImVec4(0.26f, 0.59f, 0.98f, 1.0f);
115 };
116
122 {
123 float Alpha = 1.0f;
124 float DisabledAlpha = 0.60f;
125 ImVec2 WindowPadding = ImVec2(8.0f, 8.0f);
126 float WindowRounding = 0.0f;
127 float WindowBorderSize = 1.0f;
128 ImVec2 WindowMinSize = ImVec2(32.0f, 32.0f);
129 ImVec2 WindowTitleAlign = ImVec2(0.0f, 0.5f);
130 ImGuiDir WindowMenuButtonPosition = ImGuiDir_Left;
131 float ChildRounding = 0.0f;
132 float ChildBorderSize = 1.0f;
133 float PopupRounding = 0.0f;
134 float PopupBorderSize = 1.0f;
135 ImVec2 FramePadding = ImVec2(4.0f, 3.0f);
136 float FrameRounding = 0.0f;
137 float FrameBorderSize = 0.0f;
138 ImVec2 ItemSpacing = ImVec2(8.0f, 4.0f);
139 ImVec2 ItemInnerSpacing = ImVec2(4.0f, 4.0f);
140 ImVec2 CellPadding = ImVec2(4.0f, 2.0f);
141 ImVec2 TouchExtraPadding = ImVec2(0.0f, 0.0f);
142 float IndentSpacing = 21.0f;
143 float ColumnsMinSpacing = 6.0f;
144 float ScrollbarSize = 14.0f;
145 float ScrollbarRounding = 9.0f;
146 float GrabMinSize = 12.0f;
147 float GrabRounding = 0.0f;
148 float LogSliderDeadzone = 4.0f;
149 float TabRounding = 4.0f;
150 float TabBorderSize = 0.0f;
152 ImGuiDir ColorButtonPosition = ImGuiDir_Right;
153 ImVec2 ButtonTextAlign = ImVec2(0.5f, 0.5f);
154 ImVec2 SelectableTextAlign = ImVec2(0.0f, 0.0f);
156 ImVec2 SeparatorTextAlign = ImVec2(0.0f, 0.5f);
157 ImVec2 SeparatorTextPadding = ImVec2(20.0f, 3.0f);
158 ImVec2 DisplayWindowPadding = ImVec2(19.0f, 19.0f);
159 ImVec2 DisplaySafeAreaPadding = ImVec2(3.0f, 3.0f);
160 float MouseCursorScale = 1.0f;
161 bool AntiAliasedLines = true;
163 bool AntiAliasedFill = true;
164 float CurveTessellationTol = 1.25f;
166 };
167
172 class Theme
173 {
174 public:
175 std::string name;
178
179 Theme(const std::string &themeName) : name(themeName) {}
180
184 void Apply() const;
185
190 std::unique_ptr<Theme> Clone() const;
191 };
192
198 {
199 public:
204 static ThemeManager &GetInstance();
205
209 void Initialize();
210
215 void RegisterTheme(std::unique_ptr<Theme> theme);
216
222 bool SetActiveTheme(const std::string &themeName);
223
228 Theme *GetActiveTheme() const;
229
234 std::vector<std::string> GetThemeNames() const;
235
241 Theme *GetTheme(const std::string &themeName) const;
242
246 void ApplyActiveTheme() const;
247
251 void DrawThemeSelector();
252
253 private:
254 std::unordered_map<std::string, std::unique_ptr<Theme>> m_themes;
255 std::string m_activeThemeName = "Dark";
256 static std::unique_ptr<ThemeManager> s_instance;
257
258 ThemeManager() = default;
259
264 std::unique_ptr<Theme> CreateDarkTheme();
265
270 std::unique_ptr<Theme> CreateLightTheme();
271
276 std::unique_ptr<Theme> CreateBlueTheme();
277
282 std::unique_ptr<Theme> CreateHighContrastTheme();
283 };
284}
Manages all themes and provides theme switching functionality.
Definition Theme.h:198
bool SetActiveTheme(const std::string &themeName)
Sets the active theme by name.
Definition Theme.cpp:149
std::vector< std::string > GetThemeNames() const
Gets all available theme names.
Definition Theme.cpp:166
void RegisterTheme(std::unique_ptr< Theme > theme)
Registers a new theme.
Definition Theme.cpp:144
static ThemeManager & GetInstance()
Gets the singleton instance of the theme manager.
Definition Theme.cpp:123
Theme * GetActiveTheme() const
Gets the currently active theme.
Definition Theme.cpp:160
void DrawThemeSelector()
Draws the theme selection UI.
Definition Theme.cpp:191
void ApplyActiveTheme() const
Applies the currently active theme.
Definition Theme.cpp:183
void Initialize()
Initializes the theme manager with default themes.
Definition Theme.cpp:132
Theme * GetTheme(const std::string &themeName) const
Gets a theme by name.
Definition Theme.cpp:177
Represents a complete UI theme with colors and style settings.
Definition Theme.h:173
ThemeStyle style
Definition Theme.h:177
ThemeColors colors
Definition Theme.h:176
Theme(const std::string &themeName)
Definition Theme.h:179
std::string name
Definition Theme.h:175
void Apply() const
Applies this theme to ImGui.
Definition Theme.cpp:9
std::unique_ptr< Theme > Clone() const
Creates a deep copy of this theme.
Definition Theme.cpp:116
Definition Theme.cpp:5
Contains all color definitions for a theme.
Definition Theme.h:20
ImVec4 ResizeGripHovered
Definition Theme.h:66
ImVec4 ResizeGrip
Definition Theme.h:65
ImVec4 TabHovered
Definition Theme.h:71
ImVec4 SliderGrabActive
Definition Theme.h:114
ImVec4 FrameBgActive
Definition Theme.h:33
ImVec4 DragDropTarget
Definition Theme.h:99
ImVec4 SeparatorHovered
Definition Theme.h:61
ImVec4 ChildBg
Definition Theme.h:23
ImVec4 BorderShadow
Definition Theme.h:28
ImVec4 NavHighlight
Definition Theme.h:102
ImVec4 ButtonActive
Definition Theme.h:52
ImVec4 PlotLinesHovered
Definition Theme.h:82
ImVec4 CheckMark
Definition Theme.h:110
ImVec4 TabUnfocusedActive
Definition Theme.h:74
ImVec4 NavWindowingHighlight
Definition Theme.h:103
ImVec4 TableBorderStrong
Definition Theme.h:88
ImVec4 ResizeGripActive
Definition Theme.h:67
ImVec4 ScrollbarBg
Definition Theme.h:44
ImVec4 FrameBg
Definition Theme.h:31
ImVec4 NavWindowingDimBg
Definition Theme.h:104
ImVec4 DockingPreview
Definition Theme.h:77
ImVec4 PopupBg
Definition Theme.h:24
ImVec4 PlotLines
Definition Theme.h:81
ImVec4 TextDisabled
Definition Theme.h:95
ImVec4 MenuBarBg
Definition Theme.h:41
ImVec4 SeparatorActive
Definition Theme.h:62
ImVec4 TabActive
Definition Theme.h:72
ImVec4 TabUnfocused
Definition Theme.h:73
ImVec4 TableRowBgAlt
Definition Theme.h:91
ImVec4 TableBorderLight
Definition Theme.h:89
ImVec4 ScrollbarGrabHovered
Definition Theme.h:46
ImVec4 ScrollbarGrab
Definition Theme.h:45
ImVec4 ButtonHovered
Definition Theme.h:51
ImVec4 TitleBgCollapsed
Definition Theme.h:38
ImVec4 TextSelectedBg
Definition Theme.h:96
ImVec4 TitleBgActive
Definition Theme.h:37
ImVec4 TitleBg
Definition Theme.h:36
ImVec4 DockingEmptyBg
Definition Theme.h:78
ImVec4 Header
Definition Theme.h:55
ImVec4 WindowBg
Definition Theme.h:22
ImVec4 HeaderHovered
Definition Theme.h:56
ImVec4 SliderGrab
Definition Theme.h:113
ImVec4 TableHeaderBg
Definition Theme.h:87
ImVec4 PlotHistogram
Definition Theme.h:83
ImVec4 PlotHistogramHovered
Definition Theme.h:84
ImVec4 ScrollbarGrabActive
Definition Theme.h:47
ImVec4 Separator
Definition Theme.h:60
ImVec4 Border
Definition Theme.h:27
ImVec4 TableRowBg
Definition Theme.h:90
ImVec4 FrameBgHovered
Definition Theme.h:32
ImVec4 Button
Definition Theme.h:50
ImVec4 ModalWindowDimBg
Definition Theme.h:107
ImVec4 HeaderActive
Definition Theme.h:57
ImVec4 Text
Definition Theme.h:94
ImVec4 Tab
Definition Theme.h:70
Contains style settings for a theme.
Definition Theme.h:122
float SeparatorTextBorderSize
Definition Theme.h:155
float WindowRounding
Definition Theme.h:126
float ScrollbarRounding
Definition Theme.h:145
ImVec2 SeparatorTextAlign
Definition Theme.h:156
ImVec2 DisplaySafeAreaPadding
Definition Theme.h:159
ImVec2 ButtonTextAlign
Definition Theme.h:153
float PopupBorderSize
Definition Theme.h:134
float ChildBorderSize
Definition Theme.h:132
float CircleTessellationMaxError
Definition Theme.h:165
float LogSliderDeadzone
Definition Theme.h:148
float ScrollbarSize
Definition Theme.h:144
float TabRounding
Definition Theme.h:149
float GrabRounding
Definition Theme.h:147
float ColumnsMinSpacing
Definition Theme.h:143
float Alpha
Definition Theme.h:123
ImVec2 FramePadding
Definition Theme.h:135
ImGuiDir WindowMenuButtonPosition
Definition Theme.h:130
ImVec2 ItemSpacing
Definition Theme.h:138
ImVec2 CellPadding
Definition Theme.h:140
bool AntiAliasedLines
Definition Theme.h:161
ImVec2 WindowTitleAlign
Definition Theme.h:129
float MouseCursorScale
Definition Theme.h:160
ImVec2 WindowPadding
Definition Theme.h:125
ImGuiDir ColorButtonPosition
Definition Theme.h:152
ImVec2 WindowMinSize
Definition Theme.h:128
float FrameRounding
Definition Theme.h:136
float TabMinWidthForCloseButton
Definition Theme.h:151
ImVec2 ItemInnerSpacing
Definition Theme.h:139
bool AntiAliasedFill
Definition Theme.h:163
float PopupRounding
Definition Theme.h:133
float IndentSpacing
Definition Theme.h:142
float ChildRounding
Definition Theme.h:131
ImVec2 SelectableTextAlign
Definition Theme.h:154
ImVec2 TouchExtraPadding
Definition Theme.h:141
bool AntiAliasedLinesUseTex
Definition Theme.h:162
float DisabledAlpha
Definition Theme.h:124
ImVec2 SeparatorTextPadding
Definition Theme.h:157
float TabBorderSize
Definition Theme.h:150
float WindowBorderSize
Definition Theme.h:127
float CurveTessellationTol
Definition Theme.h:164
ImVec2 DisplayWindowPadding
Definition Theme.h:158
float FrameBorderSize
Definition Theme.h:137
float GrabMinSize
Definition Theme.h:146