Polyphase Game Engine
Loading...
Searching...
No Matches
CssThemeParser.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4
5#include <string>
6#include <unordered_map>
7#include "imgui.h"
8
9struct CssThemeData
10{
11 std::unordered_map<int, ImVec4> Colors;
12
13 // Style overrides with flags for partial themes
14 float Alpha = 1.0f; bool hasAlpha = false;
15 float DisabledAlpha = 1.0f; bool hasDisabledAlpha = false;
16 ImVec2 WindowPadding; bool hasWindowPadding = false;
17 float WindowRounding = 0.0f; bool hasWindowRounding = false;
18 float WindowBorderSize = 1.0f; bool hasWindowBorderSize = false;
19 ImVec2 WindowMinSize; bool hasWindowMinSize = false;
20 ImVec2 WindowTitleAlign; bool hasWindowTitleAlign = false;
21 float ChildRounding = 0.0f; bool hasChildRounding = false;
22 float ChildBorderSize = 1.0f; bool hasChildBorderSize = false;
23 float PopupRounding = 0.0f; bool hasPopupRounding = false;
24 float PopupBorderSize = 1.0f; bool hasPopupBorderSize = false;
25 ImVec2 FramePadding; bool hasFramePadding = false;
26 float FrameRounding = 0.0f; bool hasFrameRounding = false;
27 float FrameBorderSize = 0.0f; bool hasFrameBorderSize = false;
28 ImVec2 ItemSpacing; bool hasItemSpacing = false;
29 ImVec2 ItemInnerSpacing; bool hasItemInnerSpacing = false;
30 ImVec2 CellPadding; bool hasCellPadding = false;
31 float IndentSpacing = 21.0f; bool hasIndentSpacing = false;
32 float ColumnsMinSpacing = 6.0f; bool hasColumnsMinSpacing = false;
33 float ScrollbarSize = 14.0f; bool hasScrollbarSize = false;
34 float ScrollbarRounding = 9.0f; bool hasScrollbarRounding = false;
35 float GrabMinSize = 10.0f; bool hasGrabMinSize = false;
36 float GrabRounding = 0.0f; bool hasGrabRounding = false;
37 float TabRounding = 4.0f; bool hasTabRounding = false;
38 float TabBorderSize = 0.0f; bool hasTabBorderSize = false;
39 ImVec2 ButtonTextAlign; bool hasButtonTextAlign = false;
40 ImVec2 SelectableTextAlign; bool hasSelectableTextAlign = false;
41
42 // Polyphase-specific: visual size for editor checkboxes (drawn via Polyphase::Checkbox).
43 float CheckboxSize = 16.0f; bool hasCheckboxSize = false;
44
45 // Dock tab text color (separate from ImGuiCol_Text)
46 ImVec4 DockTabTextColor; bool hasDockTabTextColor = false;
47
48 // Dock splitter / tab bar overrides
49 ImVec4 DockSplitterColor; bool hasDockSplitterColor = false;
50 ImVec4 DockSplitterHoverColor; bool hasDockSplitterHoverColor = false;
51 ImVec4 DockTabBarBg; bool hasDockTabBarBg = false;
52
53 // Per-panel background overrides
54 ImVec4 PanelAssetsBg; bool hasPanelAssetsBg = false;
55 ImVec4 PanelSceneBg; bool hasPanelSceneBg = false;
56 ImVec4 PanelPropertiesBg; bool hasPanelPropertiesBg = false;
57 ImVec4 PanelDebugLogBg; bool hasPanelDebugLogBg = false;
58};
59
60struct SelectorMapping
61{
62 const char* selector;
63 const char* property;
64 int imguiCol;
65};
66
67namespace CssThemeParser
68{
69 // Parse a CSS file into theme data
70 bool ParseFile(const std::string& filePath, CssThemeData& outTheme);
71
72 // Parse a CSS string into theme data
73 bool ParseString(const std::string& css, CssThemeData& outTheme);
74
75 // Apply parsed theme data to ImGui (uses StyleColorsDark as base)
76 void ApplyTheme(const CssThemeData& themeData);
77
78 // Color parsing utilities
79 bool ParseHexColor(const std::string& hex, ImVec4& outColor);
80 bool ParseRgbColor(const std::string& rgb, ImVec4& outColor);
81 bool ParseRgbaColor(const std::string& rgba, ImVec4& outColor);
82 float ParsePxValue(const std::string& value);
83
84 // Selector mapping accessors (for Theme Editor reverse-lookup)
85 const SelectorMapping* GetSelectorMappings();
86 int GetSelectorMappingCount();
87
88 // Panel background color accessors
89 bool GetPanelAssetsBg(ImVec4& outColor);
90 bool GetPanelSceneBg(ImVec4& outColor);
91 bool GetPanelPropertiesBg(ImVec4& outColor);
92 bool GetPanelDebugLogBg(ImVec4& outColor);
93 void SetPanelColors(const CssThemeData& data);
94 void ClearPanelColors();
95}
96
97#endif