Skip to content

Commit dc5ecc1

Browse files
committed
Builds again, doesn't run yet
1 parent 897b8e1 commit dc5ecc1

16 files changed

Lines changed: 790 additions & 776 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ tags
2525
bld/
2626
[Bb]in/
2727
[Oo]bj/
28+
build_llvm/**
2829

2930
imgui.ini
3031
git_stats

app/demo.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ extern "C" {
2222
}
2323

2424
#include <config_nodegraph_app.h>
25+
2526
using namespace NodeGraph;
2627
using namespace Zest;
2728
namespace fs = std::filesystem;
@@ -239,7 +240,9 @@ void demo_resize(const glm::vec2& size, IFontTexture* pFontTexture)
239240
spSocket->SetConstraints(glm::uvec2(LayoutConstraint::Preferred, LayoutConstraint::Expanding));
240241
spHorzLayout->AddChild(spSocket);
241242

242-
ThemeManager::Instance().Load(fs::path(NODEGRAPH_ROOT) / "theme.toml");
243+
auto& settings = Zest::GlobalSettingsManager::Instance();
244+
auto theme = settings.GetCurrentTheme();
245+
settings.Load(fs::path(NODEGRAPH_ROOT) / "theme.toml");
243246
}
244247
spCanvas->SetPixelRegionSize(size);
245248
}
@@ -296,10 +299,11 @@ void demo_theme_editor()
296299
{
297300
if (ImGui::Begin("Theme"))
298301
{
299-
auto& theme = ThemeManager::Instance();
302+
auto& settings = Zest::GlobalSettingsManager::Instance();
303+
auto theme = settings.GetCurrentTheme();
300304
std::vector<Zest::StringId> themeNames;
301305

302-
for (auto& [mstr, val] : theme.m_themes[theme.m_currentSetting])
306+
for (auto& [mstr, val] : settings.GetSection(theme))
303307
{
304308
themeNames.push_back(mstr);
305309
}
@@ -309,7 +313,7 @@ void demo_theme_editor()
309313
});
310314

311315
std::string last;
312-
auto& themeMap = theme.m_themes[theme.m_currentSetting];
316+
auto& themeMap = settings.GetSection(theme);
313317
for (auto& id : themeNames)
314318
{
315319
auto name = id.ToString();
@@ -367,7 +371,7 @@ void demo_draw()
367371

368372
demo_theme_editor();
369373
demo_hierarchy_editor();
370-
Zing::audio_show_gui();
374+
Zing::audio_show_settings_gui();
371375

372376
ImGui::End();
373377

@@ -400,6 +404,10 @@ void demo_draw()
400404
void demo_cleanup()
401405
{
402406
Zing::audio_destroy();
403-
ThemeManager::Instance().Save(fs::path(NODEGRAPH_ROOT) / "theme.toml");
407+
408+
auto& settings = Zest::GlobalSettingsManager::Instance();
409+
auto theme = settings.GetCurrentTheme();
410+
settings.Save(fs::path(NODEGRAPH_ROOT) / "theme.toml");
411+
404412
spCanvas.reset();
405413
}

app/main.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
#include <stdlib.h> // abort
1212
#include <vulkan/vulkan.h>
1313

14-
#include "config_nodegraph_app.h"
14+
#include <config_nodegraph_app.h>
15+
1516
#include <filesystem>
1617
#include <fmt/format.h>
1718

@@ -23,6 +24,7 @@
2324
#include <nodegraph/vulkan/vulkan_imgui_texture.h>
2425
#include <nodegraph/IconsFontAwesome5.h>
2526
#include <nodegraph/canvas.h>
27+
#include <nodegraph/theme.h>
2628

2729

2830
namespace fs = std::filesystem;
@@ -375,18 +377,19 @@ int main(int, char**)
375377
return -1;
376378
}
377379

378-
auto& settings = Zest::GlobalSettingManager::Instance();
380+
auto& settings = Zest::GlobalSettingsManager::Instance();
381+
auto theme = settings.GetCurrentTheme();
379382

380383
settings.Load(fs::path(NODEGRAPH_ROOT) / "settings.toml");
381384

382-
auto windowSize = settings.GetVec2f(Zest::s_windowSize);
385+
auto windowSize = settings.GetVec2f(theme, Zest::s_windowSize);
383386
if (windowSize.x == 0 || windowSize.y == 0)
384387
{
385388
windowSize.x = 1280;
386389
windowSize.y = 720;
387390
}
388391

389-
bool max = settings.GetBool(Zest::b_windowMaximized);
392+
bool max = settings.GetBool(theme, Zest::b_windowMaximized);
390393

391394
// Setup window
392395
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
@@ -629,13 +632,13 @@ int main(int, char**)
629632
CleanupVulkan();
630633

631634
SDL_GetWindowSize(window, &w, &h);
632-
settings.Set(Zest::s_windowSize, glm::vec2(w, h));
633-
settings.Set(Zest::b_windowMaximized, bool(SDL_GetWindowFlags(window) & SDL_WINDOW_MAXIMIZED));
635+
settings.Set(theme, Zest::s_windowSize, glm::vec2(w, h));
636+
settings.Set(theme, Zest::b_windowMaximized, bool(SDL_GetWindowFlags(window) & SDL_WINDOW_MAXIMIZED));
634637

635638
SDL_DestroyWindow(window);
636639
SDL_Quit();
637640

638-
Zest::GlobalSettingManager::Instance().Save(fs::path(NODEGRAPH_ROOT) / "settings.toml");
641+
Zest::GlobalSettingsManager::Instance().Save(fs::path(NODEGRAPH_ROOT) / "settings.toml");
639642

640643
return 0;
641644
}

compile_commands.json

Lines changed: 641 additions & 648 deletions
Large diffs are not rendered by default.

include/nodegraph/theme.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@
55
namespace NodeGraph
66
{
77

8-
class ThemeManager : public Zest::SettingsManager
9-
{
10-
public:
11-
static ThemeManager& Instance()
12-
{
13-
static ThemeManager theme;
14-
return theme;
15-
}
16-
};
17-
188
#ifdef DECLARE_THEME_SETTINGS
199
#define DECLARE_THEME_SETTING_VALUE(name) Zest::StringId name(#name);
2010
#else

libs/zing

Submodule zing updated 1 file

src/canvas.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,30 @@ Canvas::Canvas(IFontTexture* pFontTexture, float worldScale, const glm::vec2& sc
3232
spFontContext = std::make_shared<FontContext>();
3333
fonts_init(*spFontContext, pFontTexture);
3434

35-
auto& theme = ThemeManager::Instance();
35+
auto& settings = Zest::GlobalSettingsManager::Instance();
36+
auto theme = settings.GetCurrentTheme();
3637

3738
// For connectors around side
38-
// theme.Set(s_nodeOuter, 20.0f);
39+
// settings.Set(s_nodeOuter, 20.0f);
3940

4041
float margin = 2.0f;
4142

4243
// Title and padding
43-
theme.Set(s_nodeTitleSize, 26.0f);
44-
theme.Set(s_nodeTitleFontPad, 2.0f);
45-
theme.Set(s_nodeBorderRadius, 4.0f);
46-
theme.Set(s_nodeTitleBorderRadius, 8.0f);
47-
theme.Set(s_nodeShadowSize, 4.0f);
44+
settings.Set(theme, s_nodeTitleSize, 26.0f);
45+
settings.Set(theme, s_nodeTitleFontPad, 2.0f);
46+
settings.Set(theme, s_nodeBorderRadius, 4.0f);
47+
settings.Set(theme, s_nodeTitleBorderRadius, 8.0f);
48+
settings.Set(theme, s_nodeShadowSize, 4.0f);
4849

49-
theme.Set(s_nodeShadowSize, 2.0f);
50-
theme.Set(c_nodeShadowColor, glm::vec4(0.1f, 0.1f, 0.1f, 0.5f));
51-
theme.Set(c_nodeCenterColor, glm::vec4(0.5f, 0.5f, 0.5f, 1.0f));
50+
settings.Set(theme, s_nodeShadowSize, 2.0f);
51+
settings.Set(theme, c_nodeShadowColor, glm::vec4(0.1f, 0.1f, 0.1f, 0.5f));
52+
settings.Set(theme, c_nodeCenterColor, glm::vec4(0.5f, 0.5f, 0.5f, 1.0f));
5253

53-
theme.Set(s_gridLineSize, 2.0f);
54+
settings.Set(theme, s_gridLineSize, 2.0f);
5455

55-
theme.Set(c_gridLines, glm::vec4(0.25f, 0.25f, 0.25f, 1.0f));
56+
settings.Set(theme, c_gridLines, glm::vec4(0.25f, 0.25f, 0.25f, 1.0f));
5657

57-
theme.Set(c_nodeTitleCenterColor, glm::vec4(0.2f, 0.2f, 0.2f, 0.7f));
58+
settings.Set(theme, c_nodeTitleCenterColor, glm::vec4(0.2f, 0.2f, 0.2f, 0.7f));
5859
}
5960

6061
Canvas::~Canvas()
@@ -194,14 +195,15 @@ void Canvas::HandleMouse()
194195

195196
void Canvas::DrawGrid(float worldStep)
196197
{
197-
auto& theme = ThemeManager::Instance();
198+
auto& settings = Zest::GlobalSettingsManager::Instance();
199+
auto theme = settings.GetCurrentTheme();
198200

199201
auto startPos = m_worldOrigin;
200202
startPos.x = std::floor(m_worldOrigin.x / worldStep) * worldStep;
201203
startPos.y = std::floor(m_worldOrigin.y / worldStep) * worldStep;
202204

203-
auto size = (theme.GetVec2f(s_gridLineSize) / m_worldScale);
204-
auto lineColor = theme.GetVec4f(c_gridLines);
205+
auto size = (settings.GetVec2f(theme, s_gridLineSize) / m_worldScale);
206+
auto lineColor = settings.GetVec4f(theme, c_gridLines);
205207

206208
while (startPos.x < PixelToWorld(m_pixelSize).x)
207209
{

src/canvas_imgui.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <nodegraph/fonts.h>
77
#include <nodegraph/nodegraph.h>
88

9-
#include "config_nodegraph_app.h"
9+
#include <config_nodegraph_app.h>
1010

1111
namespace fs = std::filesystem;
1212

src/widgets/layout.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,9 @@ const WidgetList& Layout::GetChildren() const
263263

264264
void Layout::Draw(Canvas& canvas)
265265
{
266-
auto& theme = ThemeManager::Instance();
267-
if (theme.GetBool(b_debugShowLayout))
266+
auto& settings = Zest::GlobalSettingsManager::Instance();
267+
auto theme = settings.GetCurrentTheme();
268+
if (settings.GetBool(theme, b_debugShowLayout))
268269
{
269270
if (m_layoutType == LayoutType::Horizontal)
270271
{

src/widgets/node.cpp

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include <zest/settings/settings.h>
2+
13
#include <nodegraph/canvas.h>
24
#include <nodegraph/theme.h>
35
#include <nodegraph/widgets/node.h>
@@ -13,39 +15,40 @@ Node::Node(const std::string& label)
1315

1416
void Node::Draw(Canvas& canvas)
1517
{
16-
auto& theme = ThemeManager::Instance();
18+
auto& settings = Zest::GlobalSettingsManager::Instance();
19+
auto theme = settings.GetCurrentTheme();
1720
Widget::Draw(canvas);
1821

1922
auto rcWorld = GetWorldRect();
2023

2124
rcWorld = DrawSlab(canvas,
2225
rcWorld,
23-
theme.GetFloat(s_nodeBorderRadius),
24-
theme.GetFloat(s_nodeShadowSize),
25-
theme.GetVec4f(c_nodeShadowColor),
26-
theme.GetFloat(s_nodeBorderSize),
27-
theme.GetVec4f(c_nodeBorderColor),
28-
theme.GetVec4f(c_nodeCenterColor));
26+
settings.GetFloat(theme, s_nodeBorderRadius),
27+
settings.GetFloat(theme, s_nodeShadowSize),
28+
settings.GetVec4f(theme, c_nodeShadowColor),
29+
settings.GetFloat(theme, s_nodeBorderSize),
30+
settings.GetVec4f(theme, c_nodeBorderColor),
31+
settings.GetVec4f(theme, c_nodeCenterColor));
2932

30-
auto fontSize = theme.GetFloat(s_nodeTitleSize);
31-
auto titleHeight = fontSize + theme.GetFloat(s_nodeTitleFontPad) * 2.0f;
32-
auto titlePad = theme.GetFloat(s_nodeTitlePad);
33+
auto fontSize = settings.GetFloat(theme, s_nodeTitleSize);
34+
auto titleHeight = fontSize + settings.GetFloat(theme, s_nodeTitleFontPad) * 2.0f;
35+
auto titlePad = settings.GetFloat(theme, s_nodeTitlePad);
3336

3437
auto titlePanelRect = NRectf(rcWorld.Left() + titlePad, rcWorld.Top() + titlePad, rcWorld.Width() - titlePad * 2.0f, titleHeight);
3538

3639
rcWorld = DrawSlab(canvas,
3740
titlePanelRect,
38-
theme.GetFloat(s_nodeTitleBorderRadius),
39-
theme.GetFloat(s_nodeTitleShadowSize),
40-
theme.GetVec4f(c_nodeTitleShadowColor),
41-
theme.GetFloat(s_nodeTitleBorderSize),
42-
theme.GetVec4f(c_nodeTitleBorderColor),
43-
theme.GetVec4f(c_nodeTitleCenterColor),
41+
settings.GetFloat(theme, s_nodeTitleBorderRadius),
42+
settings.GetFloat(theme, s_nodeTitleShadowSize),
43+
settings.GetVec4f(theme, c_nodeTitleShadowColor),
44+
settings.GetFloat(theme, s_nodeTitleBorderSize),
45+
settings.GetVec4f(theme, c_nodeTitleBorderColor),
46+
settings.GetVec4f(theme, c_nodeTitleCenterColor),
4447
m_label.c_str(),
45-
theme.GetFloat(s_nodeTitleFontPad),
46-
TextColorForBackground(theme.GetVec4f(c_nodeTitleCenterColor)));
48+
settings.GetFloat(theme, s_nodeTitleFontPad),
49+
TextColorForBackground(settings.GetVec4f(theme, c_nodeTitleCenterColor)));
4750

48-
auto bottomGap = theme.GetFloat(s_nodeBorderSize) + theme.GetFloat(s_nodeShadowSize);
51+
auto bottomGap = settings.GetFloat(theme, s_nodeBorderSize) + settings.GetFloat(theme, s_nodeShadowSize);
4952

5053
// Layout in child coordinates
5154
auto layoutRect = NRectf(titlePanelRect.Left(), titlePanelRect.Bottom(), titlePanelRect.Width(), GetWorldRect().Bottom() - bottomGap - titlePanelRect.Bottom());

0 commit comments

Comments
 (0)