From 8128baa107fbd9f186caf6d15d131a14fe679f4f Mon Sep 17 00:00:00 2001 From: OmniaX-Dev Date: Thu, 16 Apr 2026 00:13:18 +0200 Subject: [PATCH] Added default theme --- extra/DefaultTheme.oss | 87 +++++++++++++++++++++++++++++ src/ogfx/gui/widgets/Containers.cpp | 1 + src/test/GuiTest.cpp | 7 +-- 3 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 extra/DefaultTheme.oss diff --git a/extra/DefaultTheme.oss b/extra/DefaultTheme.oss new file mode 100644 index 0000000..fb5fcc4 --- /dev/null +++ b/extra/DefaultTheme.oss @@ -0,0 +1,87 @@ +% ================== DefaultTheme.oss ================== + + +% ---- Variables ---- +const $accentColor = #DC143CFF +const $textColor = #111111FF +const $accentColorLight = #F16A85FF +const $accentColorDark = #6B0A1DFF +% ------------------- + + +% ------ Root Widget ------ +window.backgroundColor = rgba(160, 160, 160, 255) +% ------------------------- + + +% ------ Panel ------ +(panel) { + backgroundColor = #AAAAAAFF + titleColor = $accentColorDark + titlebarColor = #999999FF + titlebarBorderColor = #909090FF + borderColor = #909090FF + borderRadius = 10 + borderWidth = 2 + titlebarBorderWidth = 2 + showBorder = true + showBackground = true + titlebarType = full + titlebarHeight = 18 + titlebarFontSize = 18 + titlebarTextAlign = text_left + padding = Rect(15, 15, 15, 15) + margin = Rect(0, 0, 0, 0) +} +% ------------------- + + + +% ------ CheckBox ------ +(checkbox) { + checkBorderColor = $accentColorDark + checkBoxColor = $accentColor + textColor = $textColor + backgroundColor = color_transparent + borderColor = color_transparent + fontSize = 20 + borderRadius = 0 + borderWidth = 0 + checkBorderRadius = 6 + checkBorderWidth = 2 + showBackground = false + showBorder = false + padding = Rect(15, 15, 15, 15) + margin = Rect(0, 0, 0, 0) +} +(checkbox:hover) { + checkBorderColor = $accentColorLight +} +(checkbox:pressed) { + checkBoxColor = $accentColor + textColor = $accentColorDark + checkBorderColor = $accentColor +} +(checkbox:active) { + checkBoxColor = $accentColor + checkBorderColor = $accentColor + textColor = $accentColorDark +} +% ---------------------- + + + +% ------ Label ------ +(label) { + textColor = $textColor + backgroundColor = color_transparent + borderColor = color_transparent + fontSize = 20 + borderRadius = 0 + borderWidth = 0 + showBackground = false + showBorder = false + padding = Rect(15, 15, 15, 15) + margin = Rect(0, 0, 0, 0) +} +% ------------------- diff --git a/src/ogfx/gui/widgets/Containers.cpp b/src/ogfx/gui/widgets/Containers.cpp index 3b9f31d..279cc39 100644 --- a/src/ogfx/gui/widgets/Containers.cpp +++ b/src/ogfx/gui/widgets/Containers.cpp @@ -48,6 +48,7 @@ namespace ogfx enableBackground(getThemeValue(theme, "panel.showBackground", true)); setBorderColor(getThemeValue(theme, "panel.borderColor", Colors::Black)); setPadding(getThemeValue(theme, "panel.padding", { 15, 15, 15, 15 })); + setMargin(getThemeValue(theme, "panel.margin", { 0, 0, 0, 0 })); m_basePadding = getPadding(); m_titleColor = getThemeValue(theme, "panel.titleColor", Colors::Black); m_titlebarColor = getThemeValue(theme, "panel.titlebarColor", Colors::Transparent); diff --git a/src/test/GuiTest.cpp b/src/test/GuiTest.cpp index 7efb7c4..cb40723 100644 --- a/src/test/GuiTest.cpp +++ b/src/test/GuiTest.cpp @@ -124,7 +124,7 @@ class Window : public ogfx::gui::Window m_label1.addThemeOverride("@:pressed.label.textColor", Colors::Crimson); - m_theme.loadFromFile("./testTheme.oss", true, getDefaultStylesheetVariableList()); + m_theme.loadFromFile("./DefaultTheme.oss", true, getDefaultStylesheetVariableList()); m_label2.addThemeOverride("@:hover.label.showBackground", true); m_label2.addThemeOverride("@:hover.label.backgroundColor", Colors::DarkGreen); @@ -155,13 +155,12 @@ class Window : public ogfx::gui::Window void onRedraw(ogfx::BasicRenderer2D& gfx) override { - gfx.drawAnimation(m_anim, { 200, 200 }); - gfx.outlinedTriangle({ 30, 30 }, { 100, 50 }, { 60, 90 }, { 255, 0, 0, 80 }, Colors::DarkBlue, 5); + // gfx.drawAnimation(m_anim, { 200, 200 }); } void onFixedUpdate(void) override { - m_anim.update(); + // m_anim.update(); } private: