载入中...
搜索中...
未找到
Theme.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4#include <cstdint>
5#include <string>
6
7namespace eve::ui {
8
17 float toolbarHeight = 48.f;
18 float statusBarHeight = 36.f;
19 float sidebarWidth = 240.f;
20 float toolboxCellSize = 44.f;
21 float splitterSize = 6.f;
22 float minPaneSize = 160.f;
23 float panelPaddingX = 12.f;
24 float panelPaddingY = 10.f;
25 float cardPaddingX = 14.f;
26 float cardPaddingY = 12.f;
27 float barPaddingX = 10.f;
28 float barPaddingY = 6.f;
29 float sectionSpacingY = 6.f;
30 float searchMinWidth = 120.f;
31 float searchIconGap = 7.f;
32 float tabBarHeight = 32.f;
33 float panelHeaderHeight = 28.f;
34};
35
44
45 // --- Colors (RGBA 0..1) ---
46 float text[4] = {0.87f, 0.89f, 0.93f, 1.f};
47 float textDisabled[4] = {0.55f, 0.58f, 0.65f, 1.f};
48 float windowBg[4] = {0.145f, 0.155f, 0.19f, 0.99f};
49 float childBg[4] = {0.18f, 0.195f, 0.24f, 0.98f};
50 float popupBg[4] = {0.18f, 0.195f, 0.24f, 0.99f};
51 float border[4] = {0.095f, 0.105f, 0.135f, 0.92f};
52 float borderShadow[4] = {0.f, 0.f, 0.f, 0.f};
53 float frameBg[4] = {0.16f, 0.17f, 0.21f, 1.f};
54 float frameBgHovered[4] = {0.21f, 0.225f, 0.275f, 1.f};
55 float frameBgActive[4] = {0.25f, 0.22f, 0.26f, 1.f};
56 float titleBg[4] = {0.21f, 0.225f, 0.275f, 1.f};
57 float titleBgActive[4] = {0.235f, 0.25f, 0.305f, 1.f};
58 float titleBgCollapsed[4] = {0.19f, 0.205f, 0.25f, 0.96f};
59 float menuBarBg[4] = {0.225f, 0.24f, 0.29f, 1.f};
60 float button[4] = {0.18f, 0.195f, 0.24f, 1.f};
61 float buttonHovered[4] = {0.43f, 0.25f, 0.30f, 1.f};
62 float buttonActive[4] = {0.98f, 0.36f, 0.43f, 1.f};
63 float header[4] = {0.25f, 0.22f, 0.27f, 0.78f};
64 float headerHovered[4] = {0.43f, 0.25f, 0.30f, 0.92f};
65 float headerActive[4] = {0.60f, 0.29f, 0.34f, 1.f};
66 float checkMark[4] = {1.f, 0.39f, 0.45f, 1.f};
67 float sliderGrab[4] = {0.92f, 0.34f, 0.40f, 0.94f};
68 float sliderGrabActive[4] = {1.f, 0.46f, 0.51f, 1.f};
69 float separator[4] = {0.095f, 0.105f, 0.135f, 0.88f};
70 float scrollbarBg[4] = {0.105f, 0.115f, 0.15f, 0.62f};
71 float scrollbarGrab[4] = {0.29f, 0.31f, 0.37f, 0.90f};
72 float scrollbarGrabHovered[4] = {0.39f, 0.41f, 0.48f, 0.96f};
73 float scrollbarGrabActive[4] = {0.55f, 0.31f, 0.36f, 1.f};
74 float tab[4] = {0.18f, 0.195f, 0.24f, 1.f};
75 float tabHovered[4] = {0.42f, 0.25f, 0.30f, 1.f};
76 float tabActive[4] = {0.28f, 0.225f, 0.27f, 1.f};
77 float tabUnfocused[4] = {0.155f, 0.165f, 0.205f, 1.f};
78 float tabUnfocusedActive[4] = {0.22f, 0.20f, 0.24f, 1.f};
79 float tableHeaderBg[4] = {0.20f, 0.215f, 0.26f, 1.f};
80 float tableBorderStrong[4] = {0.095f, 0.105f, 0.135f, 0.92f};
81 float tableBorderLight[4] = {0.14f, 0.15f, 0.19f, 0.72f};
82 float tableRowBg[4] = {0.f, 0.f, 0.f, 0.f};
83 float tableRowBgAlt[4] = {0.31f, 0.33f, 0.39f, 0.22f};
84 float plotLines[4] = {0.62f, 0.65f, 0.72f, 1.f};
85 float plotLinesHovered[4] = {1.f, 0.39f, 0.45f, 1.f};
86 float plotHistogram[4] = {0.85f, 0.60f, 0.28f, 1.f};
87 float plotHistogramHovered[4] = {0.96f, 0.70f, 0.34f, 1.f};
88 float textSelectedBg[4] = {0.90f, 0.31f, 0.38f, 0.42f};
89 float navHighlight[4] = {1.f, 0.39f, 0.45f, 0.88f};
90 float modalDimBg[4] = {0.055f, 0.06f, 0.08f, 0.72f};
91
92 // --- Geometry (design units @ scale 1) ---
93 float windowRounding = 3.f;
94 float childRounding = 3.f;
95 float frameRounding = 3.f;
96 float popupRounding = 4.f;
97 float scrollbarRounding = 3.f;
98 float grabRounding = 3.f;
99 float tabRounding = 2.f;
100
101 float windowBorderSize = 1.f;
102 float childBorderSize = 1.f;
103 float popupBorderSize = 1.f;
104 float frameBorderSize = 0.f;
105
106 float windowPaddingX = 14.f;
107 float windowPaddingY = 12.f;
108 float framePaddingX = 9.f;
109 float framePaddingY = 5.f;
110 float itemSpacingX = 9.f;
111 float itemSpacingY = 7.f;
112 float itemInnerSpacingX = 6.f;
113 float itemInnerSpacingY = 4.f;
114 float cellPaddingX = 6.f;
115 float cellPaddingY = 3.f;
116 float indentSpacing = 16.f;
117 float scrollbarSize = 10.f;
118 float grabMinSize = 8.f;
119
122 float fontScale = 1.f;
123 bool navEnableKeyboard = true;
124 bool navEnableGamepad = false;
125
127 static Theme dark();
129 static Theme light();
130};
131
134 std::string name;
135 std::string parent;
136 bool hasTextColor = false;
137 bool hasBackgroundColor = false;
138 bool hasBorderColor = false;
139 bool hasAccentColor = false;
140 float textColor[4] = {0.f, 0.f, 0.f, 0.f};
141 float backgroundColor[4] = {0.f, 0.f, 0.f, 0.f};
142 float borderColor[4] = {0.f, 0.f, 0.f, 0.f};
143 float accentColor[4] = {0.f, 0.f, 0.f, 0.f};
144 bool hasPadding = false;
145 float paddingX = 0.f;
146 float paddingY = 0.f;
147 bool hasRounding = false;
148 float rounding = 0.f;
149 bool hasAlpha = false;
150 float alpha = 1.f;
151};
152
154enum class StyleClassStatus : uint8_t {
155 Applied = 0,
161};
162
168[[nodiscard]] EVENGINE_API_WORLD StyleClassStatus defineStyleClass(const std::string &name,
169 const std::string &parent = "");
171[[nodiscard]] EVENGINE_API_WORLD StyleClassStatus setStyleClassColor(const std::string &name,
172 const std::string &property, float r, float g,
173 float b, float a);
175[[nodiscard]] EVENGINE_API_WORLD StyleClassStatus setStyleClassMetric(const std::string &name,
176 const std::string &property, float x,
177 float y = 0.f);
179[[nodiscard]] EVENGINE_API_WORLD StyleClassStatus resolveStyleClass(const std::string &name, StyleClass *out);
184
188EVENGINE_API_WORLD const std::string &globalThemeName();
189
191EVENGINE_API_WORLD void setGlobalTheme(const Theme &theme);
193EVENGINE_API_WORLD void setGlobalTheme(const Theme &theme, const std::string &name);
194
196bool setThemeByName(const std::string &name);
197
202
207void setThemeDpiScale(float dpiScale);
209float themeDpiScale();
210
214EVENGINE_API_WORLD void applyThemeToImGui(const Theme &theme, float uiScale);
215
216} // namespace eve::ui
double y
double x
std::string name
Definition ECS.cpp:154
#define EVENGINE_API_WORLD
Definition Export.h:109
tensor::Graph g
Definition GpuGraph.cpp:7
wgpu::PopErrorScopeStatus status
double r
bool border
const ColourScope * parent
std::array< float, 3 > scale
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
std::string text
ScriptStructure out
Light3D::Data * light
Definition Shadow.cpp:147
StyleClassStatus defineStyleClass(const std::string &name, const std::string &parent)
Declares or replaces one sparse style class. @thread UI thread only. @reentrancy Does not invoke call...
Definition Theme.cpp:82
float themeDpiScale()
Theme dpi scale.
Definition Theme.cpp:311
StyleClassStatus
Explicit result of a style-registry mutation.
Definition Theme.h:154
const std::string & globalThemeName()
Current preset name: "dark", "light", or "custom".
Definition Theme.cpp:279
void clearStyleClasses()
Clears user-defined style classes. Intended for runtime/test teardown.
Definition Theme.cpp:160
void setThemeDpiScale(float dpiScale)
Sets the theme dpi scale.
Definition Theme.cpp:307
bool setThemeByName(const std::string &name)
Apply a named preset ("dark" / "light"). Case-insensitive. Returns false if unknown.
Definition Theme.cpp:288
void setThemeUiScale(float scale)
Logical (point-space) UI scale. Default 1.0.
Definition Theme.cpp:301
StyleClassStatus setStyleClassMetric(const std::string &name, const std::string &property, float x, float y)
Sets padding, rounding, or alpha on an existing style class.
Definition Theme.cpp:128
const char * styleClassStatusName(StyleClassStatus status)
Stable script-facing spelling of a mutation status.
Definition Theme.cpp:162
void setGlobalTheme(const Theme &theme)
Sets the global theme.
Definition Theme.cpp:281
StyleClassStatus resolveStyleClass(const std::string &name, StyleClass *out)
Resolves inheritance into a sparse class and reports an explicit lookup status.
Definition Theme.cpp:150
Theme & globalTheme()
Global theme.
Definition Theme.cpp:277
void applyThemeToImGui(const Theme &theme)
Push tokens into ImGui style. Metrics are multiplied by uiScale (default: themeUiScale()).
Definition Theme.cpp:313
WidgetDesc tab(std::string label, std::string pageId, bool selected, std::string id, std::function< void()> onClick)
Selectable tab label.
Definition Widget.cpp:715
WidgetDesc separator(std::string id)
Horizontal separator line.
Definition Widget.cpp:379
float themeUiScale()
Theme ui scale.
Definition Theme.cpp:305
StyleClassStatus setStyleClassColor(const std::string &name, const std::string &property, float r, float g, float b, float a)
Sets text/background/border/accent RGBA on an existing style class.
Definition Theme.cpp:99
Sparse reusable widget style resolved once while a retained tree is built.
Definition Theme.h:133
float backgroundColor[4]
Definition Theme.h:141
std::string name
Definition Theme.h:134
std::string parent
Definition Theme.h:135
float accentColor[4]
Definition Theme.h:143
bool hasBackgroundColor
Definition Theme.h:137
float textColor[4]
Definition Theme.h:140
float borderColor[4]
Definition Theme.h:142
Semantic layout tokens shared by editor-oriented widgets.
Definition Theme.h:16
float panelPaddingY
Definition Theme.h:24
float searchIconGap
Definition Theme.h:31
float toolbarHeight
Definition Theme.h:17
float toolboxCellSize
Definition Theme.h:20
float searchMinWidth
Definition Theme.h:30
float panelPaddingX
Definition Theme.h:23
float panelHeaderHeight
Definition Theme.h:33
float sectionSpacingY
Definition Theme.h:29
float statusBarHeight
Definition Theme.h:18
Unified UI design tokens (colors, geometry, typography). Applied to ImGui each frame via applyThemeTo...
Definition Theme.h:41
ThemeLayout layout
Definition Theme.h:43
Object::Ptr theme