Skip to content

Commit 5dfd795

Browse files
committed
Adds json based themes
1 parent a211c1f commit 5dfd795

File tree

11 files changed

+25213
-212
lines changed

11 files changed

+25213
-212
lines changed

editor/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
file(GLOB_RECURSE EditorSource ./**.cpp)
2-
file(GLOB_RECURSE EditorHeaders ./**.h)
2+
file(GLOB_RECURSE EditorHeaders ./**.h ./**.hpp)
33
file(GLOB_RECURSE EditorLuaScripts ./**.lua)
44
file(GLOB_RECURSE EditorJSONs ./**.json)
55

editor/editor_system.cpp

Lines changed: 92 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,94 @@ bool EditorSystem::initialize(const JSON::json& systemData)
9797
ImGui_ImplWin32_Init(Application::GetSingleton()->getWindow()->getWindowHandle());
9898
ImGui_ImplDX11_Init(RenderingDevice::GetSingleton()->getDevice(), RenderingDevice::GetSingleton()->getContext());
9999

100-
m_Themes.push_back(std::make_unique<DarkTheme>());
101-
m_Themes.push_back(std::make_unique<LightTheme>());
102-
m_CurrentTheme = m_Themes.front().get();
103-
m_CurrentTheme->apply();
100+
// --- Apply layout with default values ---
101+
ImGui::StyleColorsDark();
102+
103+
{
104+
ImGuiStyle& style = ImGui::GetStyle();
105+
style.WindowPadding = ImVec2(15, 15);
106+
style.WindowRounding = 5.0f;
107+
style.FramePadding = ImVec2(5, 5);
108+
style.FrameRounding = 4.0f;
109+
style.ItemSpacing = ImVec2(12, 6);
110+
style.ItemInnerSpacing = ImVec2(8, 4);
111+
style.IndentSpacing = 25.0f;
112+
style.ScrollbarSize = 15.0f;
113+
style.ScrollbarRounding = 9.0f;
114+
style.GrabMinSize = 5.0f;
115+
style.GrabRounding = 3.0f;
116+
117+
ImVec4* colors = ImGui::GetStyle().Colors;
118+
colors[ImGuiCol_Text] = ImVec4(0.80f, 0.80f, 0.83f, 1.00f);
119+
colors[ImGuiCol_TextDisabled] = ImVec4(0.24f, 0.23f, 0.29f, 1.00f);
120+
colors[ImGuiCol_WindowBg] = ImVec4(0.05f, 0.05f, 0.07f, 1.00f);
121+
colors[ImGuiCol_ChildBg] = ImVec4(0.07f, 0.07f, 0.09f, 1.00f);
122+
colors[ImGuiCol_PopupBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f);
123+
colors[ImGuiCol_Border] = ImVec4(0.23f, 0.23f, 0.23f, 1.00f);
124+
colors[ImGuiCol_BorderShadow] = ImVec4(0.68f, 0.63f, 0.63f, 1.00f);
125+
colors[ImGuiCol_FrameBg] = ImVec4(0.10f, 0.09f, 0.12f, 1.00f);
126+
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.24f, 0.23f, 0.29f, 1.00f);
127+
colors[ImGuiCol_FrameBgActive] = ImVec4(0.56f, 0.56f, 0.58f, 1.00f);
128+
colors[ImGuiCol_TitleBg] = ImVec4(0.10f, 0.09f, 0.12f, 1.00f);
129+
colors[ImGuiCol_TitleBgActive] = ImVec4(0.07f, 0.07f, 0.09f, 1.00f);
130+
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(1.00f, 0.98f, 0.95f, 0.75f);
131+
colors[ImGuiCol_MenuBarBg] = ImVec4(0.10f, 0.09f, 0.12f, 1.00f);
132+
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.10f, 0.09f, 0.12f, 1.00f);
133+
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.80f, 0.80f, 0.83f, 0.31f);
134+
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.56f, 0.56f, 0.58f, 1.00f);
135+
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.06f, 0.05f, 0.07f, 1.00f);
136+
colors[ImGuiCol_CheckMark] = ImVec4(0.20f, 0.68f, 0.42f, 0.83f);
137+
colors[ImGuiCol_SliderGrab] = ImVec4(0.80f, 0.80f, 0.83f, 0.31f);
138+
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.06f, 0.05f, 0.07f, 1.00f);
139+
colors[ImGuiCol_Button] = ImVec4(0.12f, 0.43f, 0.33f, 0.88f);
140+
colors[ImGuiCol_ButtonHovered] = ImVec4(0.20f, 0.68f, 0.42f, 0.83f);
141+
colors[ImGuiCol_ButtonActive] = ImVec4(0.56f, 0.56f, 0.58f, 1.00f);
142+
colors[ImGuiCol_Header] = ImVec4(0.20f, 0.68f, 0.42f, 0.58f);
143+
colors[ImGuiCol_HeaderHovered] = ImVec4(0.20f, 0.68f, 0.42f, 0.83f);
144+
colors[ImGuiCol_HeaderActive] = ImVec4(0.06f, 0.05f, 0.07f, 1.00f);
145+
colors[ImGuiCol_Separator] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f);
146+
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.20f, 0.68f, 0.42f, 0.83f);
147+
colors[ImGuiCol_SeparatorActive] = ImVec4(0.36f, 0.75f, 0.10f, 1.00f);
148+
colors[ImGuiCol_ResizeGrip] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
149+
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.56f, 0.56f, 0.58f, 1.00f);
150+
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.06f, 0.05f, 0.07f, 1.00f);
151+
colors[ImGuiCol_Tab] = ImVec4(0.18f, 0.57f, 0.58f, 0.86f);
152+
colors[ImGuiCol_TabHovered] = ImVec4(0.20f, 0.68f, 0.42f, 0.83f);
153+
colors[ImGuiCol_TabActive] = ImVec4(0.20f, 0.68f, 0.42f, 1.00f);
154+
colors[ImGuiCol_TabUnfocused] = ImVec4(0.14f, 0.41f, 0.42f, 0.46f);
155+
colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.14f, 0.41f, 0.42f, 1.00f);
156+
colors[ImGuiCol_DockingPreview] = ImVec4(0.00f, 1.00f, 0.21f, 0.70f);
157+
colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
158+
colors[ImGuiCol_PlotLines] = ImVec4(0.40f, 0.39f, 0.38f, 0.63f);
159+
colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.25f, 1.00f, 0.00f, 1.00f);
160+
colors[ImGuiCol_PlotHistogram] = ImVec4(0.40f, 0.39f, 0.38f, 0.63f);
161+
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(0.25f, 1.00f, 0.00f, 1.00f);
162+
colors[ImGuiCol_TableHeaderBg] = ImVec4(0.19f, 0.19f, 0.20f, 1.00f);
163+
colors[ImGuiCol_TableBorderStrong] = ImVec4(0.31f, 0.31f, 0.35f, 1.00f);
164+
colors[ImGuiCol_TableBorderLight] = ImVec4(0.23f, 0.23f, 0.25f, 1.00f);
165+
colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
166+
colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.06f);
167+
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.25f, 1.00f, 0.00f, 0.48f);
168+
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
169+
colors[ImGuiCol_NavHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
170+
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
171+
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
172+
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(1.00f, 0.98f, 0.95f, 0.73f);
173+
}
174+
175+
// --- Load json theme data ---
176+
for (const auto& entry : std::filesystem::directory_iterator("editor/themes"))
177+
{
178+
if (entry.path().extension() == ".json")
179+
{
180+
std::ifstream f(entry.path());
181+
nlohmann::json data;
182+
f >> data;
183+
m_ThemeDefinitions.push_back({ data.value("name", entry.path().stem().string()),
184+
entry.path().string(),
185+
data });
186+
}
187+
}
104188

105189
return true;
106190
}
@@ -348,14 +432,13 @@ void EditorSystem::drawDefaultUI(float deltaMilliseconds)
348432
static bool styleEditor = false;
349433
if (ImGui::BeginMenu("View"))
350434
{
351-
if (ImGui::BeginMenu("Theme"))
435+
if (ImGui::BeginMenu("Themes"))
352436
{
353-
for (auto& theme : m_Themes)
437+
for (size_t i = 0; i < m_ThemeDefinitions.size(); ++i)
354438
{
355-
if (ImGui::MenuItem(theme->getName().c_str(), "", m_CurrentTheme == theme.get()))
439+
if (ImGui::MenuItem(m_ThemeDefinitions[i].m_Name.c_str()))
356440
{
357-
m_CurrentTheme = theme.get();
358-
m_CurrentTheme->apply();
441+
m_ThemeDefinitions[i].apply();
359442
}
360443
}
361444
ImGui::EndMenu();

editor/editor_system.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#include "Tracy/Tracy.hpp"
1313

1414
#include "themes/theme.h"
15-
#include "themes/dark_theme.h"
16-
#include "themes/light_theme.h"
1715

1816
ImColor ColorToImColor(Color& c);
1917

@@ -86,8 +84,7 @@ class EditorSystem : public System
8684
int exportScene(const String& sceneName, const String& sceneFilePath, Atomic<int>& progress);
8785
void postExport();
8886

89-
Vector<std::unique_ptr<Theme>> m_Themes;
90-
Theme* m_CurrentTheme = nullptr;
87+
Vector<ThemeDefinition> m_ThemeDefinitions;
9188

9289
public:
9390
static EditorSystem* GetSingleton();

editor/themes/classic.json

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"name": "Classic",
3+
"style": {
4+
"WindowPadding": [8.0, 8.0],
5+
"WindowRounding": 0.0,
6+
"FramePadding": [4.0, 3.0],
7+
"FrameRounding": 0.0,
8+
"ItemSpacing": [8.0, 4.0],
9+
"ItemInnerSpacing": [4.0, 4.0],
10+
"IndentSpacing": 20.0,
11+
"ScrollbarSize": 12.0,
12+
"ScrollbarRounding": 0.0,
13+
"GrabMinSize": 8.0,
14+
"GrabRounding": 0.0
15+
},
16+
"colors": {
17+
"Text": [0.00, 0.00, 0.00, 1.00],
18+
"TextDisabled": [0.50, 0.50, 0.50, 1.00],
19+
"WindowBg": [0.82, 0.82, 0.82, 1.00],
20+
"ChildBg": [0.85, 0.85, 0.85, 1.00],
21+
"PopupBg": [0.90, 0.90, 0.90, 1.00],
22+
"Border": [0.50, 0.50, 0.50, 1.00],
23+
"BorderShadow": [0.00, 0.00, 0.00, 0.00],
24+
"FrameBg": [0.75, 0.75, 0.75, 1.00],
25+
"FrameBgHovered": [0.70, 0.70, 0.70, 1.00],
26+
"FrameBgActive": [0.60, 0.60, 0.60, 1.00],
27+
"TitleBg": [0.50, 0.50, 0.60, 1.00],
28+
"TitleBgActive": [0.45, 0.45, 0.55, 1.00],
29+
"TitleBgCollapsed": [0.60, 0.60, 0.70, 1.00],
30+
"MenuBarBg": [0.75, 0.75, 0.75, 1.00],
31+
"ScrollbarBg": [0.85, 0.85, 0.85, 1.00],
32+
"ScrollbarGrab": [0.60, 0.60, 0.60, 1.00],
33+
"ScrollbarGrabHovered": [0.55, 0.55, 0.55, 1.00],
34+
"ScrollbarGrabActive": [0.50, 0.50, 0.50, 1.00],
35+
"CheckMark": [0.00, 0.00, 0.00, 1.00],
36+
"SliderGrab": [0.50, 0.50, 0.50, 1.00],
37+
"SliderGrabActive": [0.30, 0.30, 0.30, 1.00],
38+
"Button": [0.82, 0.82, 0.82, 1.00],
39+
"ButtonHovered": [0.90, 0.90, 0.90, 1.00],
40+
"ButtonActive": [0.65, 0.65, 0.65, 1.00],
41+
"Header": [0.70, 0.70, 0.70, 1.00],
42+
"HeaderHovered": [0.80, 0.80, 0.80, 1.00],
43+
"HeaderActive": [0.60, 0.60, 0.60, 1.00],
44+
"Separator": [0.50, 0.50, 0.50, 1.00],
45+
"SeparatorHovered": [0.30, 0.30, 0.30, 1.00],
46+
"SeparatorActive": [0.20, 0.20, 0.20, 1.00],
47+
"ResizeGrip": [0.50, 0.50, 0.50, 1.00],
48+
"ResizeGripHovered": [0.60, 0.60, 0.60, 1.00],
49+
"ResizeGripActive": [0.40, 0.40, 0.40, 1.00],
50+
"Tab": [0.80, 0.80, 0.85, 1.00],
51+
"TabHovered": [0.90, 0.90, 0.95, 1.00],
52+
"TabActive": [0.70, 0.70, 0.90, 1.00],
53+
"TabUnfocused": [0.85, 0.85, 0.85, 1.00],
54+
"TabUnfocusedActive": [0.80, 0.80, 0.90, 1.00],
55+
"DockingPreview": [0.20, 0.40, 0.70, 0.70],
56+
"DockingEmptyBg": [0.90, 0.90, 0.90, 1.00],
57+
"PlotLines": [0.20, 0.20, 0.20, 1.00],
58+
"PlotLinesHovered": [0.00, 0.00, 0.00, 1.00],
59+
"PlotHistogram": [0.25, 0.25, 0.25, 1.00],
60+
"PlotHistogramHovered": [0.00, 0.00, 0.00, 1.00],
61+
"TableHeaderBg": [0.80, 0.80, 0.80, 1.00],
62+
"TableBorderStrong": [0.50, 0.50, 0.50, 1.00],
63+
"TableBorderLight": [0.75, 0.75, 0.75, 1.00],
64+
"TableRowBg": [1.00, 1.00, 1.00, 0.00],
65+
"TableRowBgAlt": [0.90, 0.90, 0.90, 0.30],
66+
"TextSelectedBg": [0.50, 0.50, 1.00, 0.35],
67+
"DragDropTarget": [0.00, 0.00, 1.00, 0.90],
68+
"NavHighlight": [0.00, 0.00, 1.00, 1.00],
69+
"NavWindowingHighlight": [0.25, 0.25, 0.25, 0.70],
70+
"NavWindowingDimBg": [0.80, 0.80, 0.80, 0.20],
71+
"ModalWindowDimBg": [0.90, 0.90, 0.90, 0.60]
72+
}
73+
}
74+

editor/themes/dark.json

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"name": "Dark",
3+
"style": {
4+
"WindowPadding": [15.0, 15.0],
5+
"WindowRounding": 5.0,
6+
"FramePadding": [5.0, 5.0],
7+
"FrameRounding": 4.0,
8+
"ItemSpacing": [12.0, 6.0],
9+
"ItemInnerSpacing": [8.0, 4.0],
10+
"IndentSpacing": 25.0,
11+
"ScrollbarSize": 15.0,
12+
"ScrollbarRounding": 9.0,
13+
"GrabMinSize": 5.0,
14+
"GrabRounding": 3.0
15+
},
16+
"colors": {
17+
"Text": [0.80, 0.80, 0.83, 1.00],
18+
"TextDisabled": [0.24, 0.23, 0.29, 1.00],
19+
"WindowBg": [0.05, 0.05, 0.07, 1.00],
20+
"ChildBg": [0.07, 0.07, 0.09, 1.00],
21+
"PopupBg": [0.14, 0.14, 0.14, 1.00],
22+
"Border": [0.23, 0.23, 0.23, 1.00],
23+
"BorderShadow": [0.68, 0.63, 0.63, 1.00],
24+
"FrameBg": [0.10, 0.09, 0.12, 1.00],
25+
"FrameBgHovered": [0.24, 0.23, 0.29, 1.00],
26+
"FrameBgActive": [0.56, 0.56, 0.58, 1.00],
27+
"TitleBg": [0.10, 0.09, 0.12, 1.00],
28+
"TitleBgActive": [0.07, 0.07, 0.09, 1.00],
29+
"TitleBgCollapsed": [1.00, 0.98, 0.95, 0.75],
30+
"MenuBarBg": [0.10, 0.09, 0.12, 1.00],
31+
"ScrollbarBg": [0.10, 0.09, 0.12, 1.00],
32+
"ScrollbarGrab": [0.80, 0.80, 0.83, 0.31],
33+
"ScrollbarGrabHovered": [0.56, 0.56, 0.58, 1.00],
34+
"ScrollbarGrabActive": [0.06, 0.05, 0.07, 1.00],
35+
"CheckMark": [0.20, 0.68, 0.42, 0.83],
36+
"SliderGrab": [0.80, 0.80, 0.83, 0.31],
37+
"SliderGrabActive": [0.06, 0.05, 0.07, 1.00],
38+
"Button": [0.12, 0.43, 0.33, 0.88],
39+
"ButtonHovered": [0.20, 0.68, 0.42, 0.83],
40+
"ButtonActive": [0.56, 0.56, 0.58, 1.00],
41+
"Header": [0.20, 0.68, 0.42, 0.58],
42+
"HeaderHovered": [0.20, 0.68, 0.42, 0.83],
43+
"HeaderActive": [0.06, 0.05, 0.07, 1.00],
44+
"Separator": [0.43, 0.43, 0.50, 0.50],
45+
"SeparatorHovered": [0.20, 0.68, 0.42, 0.83],
46+
"SeparatorActive": [0.36, 0.75, 0.10, 1.00],
47+
"ResizeGrip": [0.00, 0.00, 0.00, 0.00],
48+
"ResizeGripHovered": [0.56, 0.56, 0.58, 1.00],
49+
"ResizeGripActive": [0.06, 0.05, 0.07, 1.00],
50+
"Tab": [0.18, 0.57, 0.58, 0.86],
51+
"TabHovered": [0.20, 0.68, 0.42, 0.83],
52+
"TabActive": [0.20, 0.68, 0.42, 1.00],
53+
"TabUnfocused": [0.14, 0.41, 0.42, 0.46],
54+
"TabUnfocusedActive": [0.14, 0.41, 0.42, 1.00],
55+
"DockingPreview": [0.00, 1.00, 0.21, 0.70],
56+
"DockingEmptyBg": [0.20, 0.20, 0.20, 1.00],
57+
"PlotLines": [0.40, 0.39, 0.38, 0.63],
58+
"PlotLinesHovered": [0.25, 1.00, 0.00, 1.00],
59+
"PlotHistogram": [0.40, 0.39, 0.38, 0.63],
60+
"PlotHistogramHovered": [0.25, 1.00, 0.00, 1.00],
61+
"TableHeaderBg": [0.19, 0.19, 0.20, 1.00],
62+
"TableBorderStrong": [0.31, 0.31, 0.35, 1.00],
63+
"TableBorderLight": [0.23, 0.23, 0.25, 1.00],
64+
"TableRowBg": [0.00, 0.00, 0.00, 0.00],
65+
"TableRowBgAlt": [1.00, 1.00, 1.00, 0.06],
66+
"TextSelectedBg": [0.25, 1.00, 0.00, 0.48],
67+
"DragDropTarget": [1.00, 1.00, 0.00, 0.90],
68+
"NavHighlight": [1.00, 1.00, 1.00, 1.00],
69+
"NavWindowingHighlight": [1.00, 1.00, 1.00, 0.70],
70+
"NavWindowingDimBg": [0.80, 0.80, 0.80, 0.20],
71+
"ModalWindowDimBg": [1.00, 0.98, 0.95, 0.73]
72+
}
73+
}
74+

editor/themes/dark_theme.h

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)