载入中...
搜索中...
未找到
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};
33
42
43 // --- Colors (RGBA 0..1) ---
44 float text[4] = {0.87f, 0.89f, 0.93f, 1.f};
45 float textDisabled[4] = {0.55f, 0.58f, 0.65f, 1.f};
46 float windowBg[4] = {0.145f, 0.155f, 0.19f, 0.99f};
47 float childBg[4] = {0.18f, 0.195f, 0.24f, 0.98f};
48 float popupBg[4] = {0.18f, 0.195f, 0.24f, 0.99f};
49 float border[4] = {0.095f, 0.105f, 0.135f, 0.92f};
50 float borderShadow[4] = {0.f, 0.f, 0.f, 0.f};
51 float frameBg[4] = {0.16f, 0.17f, 0.21f, 1.f};
52 float frameBgHovered[4] = {0.21f, 0.225f, 0.275f, 1.f};
53 float frameBgActive[4] = {0.25f, 0.22f, 0.26f, 1.f};
54 float titleBg[4] = {0.21f, 0.225f, 0.275f, 1.f};
55 float titleBgActive[4] = {0.235f, 0.25f, 0.305f, 1.f};
56 float titleBgCollapsed[4] = {0.19f, 0.205f, 0.25f, 0.96f};
57 float menuBarBg[4] = {0.225f, 0.24f, 0.29f, 1.f};
58 float button[4] = {0.18f, 0.195f, 0.24f, 1.f};
59 float buttonHovered[4] = {0.43f, 0.25f, 0.30f, 1.f};
60 float buttonActive[4] = {0.98f, 0.36f, 0.43f, 1.f};
61 float header[4] = {0.25f, 0.22f, 0.27f, 0.78f};
62 float headerHovered[4] = {0.43f, 0.25f, 0.30f, 0.92f};
63 float headerActive[4] = {0.60f, 0.29f, 0.34f, 1.f};
64 float checkMark[4] = {1.f, 0.39f, 0.45f, 1.f};
65 float sliderGrab[4] = {0.92f, 0.34f, 0.40f, 0.94f};
66 float sliderGrabActive[4] = {1.f, 0.46f, 0.51f, 1.f};
67 float separator[4] = {0.095f, 0.105f, 0.135f, 0.88f};
68 float scrollbarBg[4] = {0.105f, 0.115f, 0.15f, 0.62f};
69 float scrollbarGrab[4] = {0.29f, 0.31f, 0.37f, 0.90f};
70 float scrollbarGrabHovered[4] = {0.39f, 0.41f, 0.48f, 0.96f};
71 float scrollbarGrabActive[4] = {0.55f, 0.31f, 0.36f, 1.f};
72 float tab[4] = {0.18f, 0.195f, 0.24f, 1.f};
73 float tabHovered[4] = {0.42f, 0.25f, 0.30f, 1.f};
74 float tabActive[4] = {0.28f, 0.225f, 0.27f, 1.f};
75 float tabUnfocused[4] = {0.155f, 0.165f, 0.205f, 1.f};
76 float tabUnfocusedActive[4] = {0.22f, 0.20f, 0.24f, 1.f};
77 float tableHeaderBg[4] = {0.20f, 0.215f, 0.26f, 1.f};
78 float tableBorderStrong[4] = {0.095f, 0.105f, 0.135f, 0.92f};
79 float tableBorderLight[4] = {0.14f, 0.15f, 0.19f, 0.72f};
80 float tableRowBg[4] = {0.f, 0.f, 0.f, 0.f};
81 float tableRowBgAlt[4] = {0.31f, 0.33f, 0.39f, 0.22f};
82 float plotLines[4] = {0.62f, 0.65f, 0.72f, 1.f};
83 float plotLinesHovered[4] = {1.f, 0.39f, 0.45f, 1.f};
84 float plotHistogram[4] = {0.85f, 0.60f, 0.28f, 1.f};
85 float plotHistogramHovered[4] = {0.96f, 0.70f, 0.34f, 1.f};
86 float textSelectedBg[4] = {0.90f, 0.31f, 0.38f, 0.42f};
87 float navHighlight[4] = {1.f, 0.39f, 0.45f, 0.88f};
88 float modalDimBg[4] = {0.055f, 0.06f, 0.08f, 0.72f};
89
90 // --- Geometry (design units @ scale 1) ---
91 float windowRounding = 3.f;
92 float childRounding = 3.f;
93 float frameRounding = 3.f;
94 float popupRounding = 4.f;
95 float scrollbarRounding = 3.f;
96 float grabRounding = 3.f;
97 float tabRounding = 2.f;
98
99 float windowBorderSize = 1.f;
100 float childBorderSize = 1.f;
101 float popupBorderSize = 1.f;
102 float frameBorderSize = 0.f;
103
104 float windowPaddingX = 14.f;
105 float windowPaddingY = 12.f;
106 float framePaddingX = 9.f;
107 float framePaddingY = 5.f;
108 float itemSpacingX = 9.f;
109 float itemSpacingY = 7.f;
110 float itemInnerSpacingX = 6.f;
111 float itemInnerSpacingY = 4.f;
112 float cellPaddingX = 6.f;
113 float cellPaddingY = 3.f;
114 float indentSpacing = 16.f;
115 float scrollbarSize = 10.f;
116 float grabMinSize = 8.f;
117
120 float fontScale = 1.f;
121 bool navEnableKeyboard = true;
122 bool navEnableGamepad = false;
123
125 static Theme dark();
127 static Theme light();
128};
129
132 std::string name;
133 std::string parent;
134 bool hasTextColor = false;
135 bool hasBackgroundColor = false;
136 bool hasBorderColor = false;
137 bool hasAccentColor = false;
138 float textColor[4] = {0.f, 0.f, 0.f, 0.f};
139 float backgroundColor[4] = {0.f, 0.f, 0.f, 0.f};
140 float borderColor[4] = {0.f, 0.f, 0.f, 0.f};
141 float accentColor[4] = {0.f, 0.f, 0.f, 0.f};
142 bool hasPadding = false;
143 float paddingX = 0.f;
144 float paddingY = 0.f;
145 bool hasRounding = false;
146 float rounding = 0.f;
147 bool hasAlpha = false;
148 float alpha = 1.f;
149};
150
152enum class StyleClassStatus : uint8_t {
153 Applied = 0,
159};
160
166[[nodiscard]] EVENGINE_API_WORLD StyleClassStatus defineStyleClass(const std::string &name,
167 const std::string &parent = "");
169[[nodiscard]] EVENGINE_API_WORLD StyleClassStatus setStyleClassColor(const std::string &name,
170 const std::string &property, float r, float g,
171 float b, float a);
173[[nodiscard]] EVENGINE_API_WORLD StyleClassStatus setStyleClassMetric(const std::string &name,
174 const std::string &property, float x,
175 float y = 0.f);
177[[nodiscard]] EVENGINE_API_WORLD StyleClassStatus resolveStyleClass(const std::string &name, StyleClass *out);
182
186EVENGINE_API_WORLD const std::string &globalThemeName();
187
189EVENGINE_API_WORLD void setGlobalTheme(const Theme &theme);
191EVENGINE_API_WORLD void setGlobalTheme(const Theme &theme, const std::string &name);
192
194bool setThemeByName(const std::string &name);
195
200
205void setThemeDpiScale(float dpiScale);
207float themeDpiScale();
208
212EVENGINE_API_WORLD void applyThemeToImGui(const Theme &theme, float uiScale);
213
214} // namespace eve::ui
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
Object::Ptr theme
#define EVENGINE_API_WORLD
Definition Export.h:109
tensor::Graph g
Definition GpuGraph.cpp:7
wgpu::PopErrorScopeStatus status
double r
bool border
std::string text
std::array< float, 3 > scale
std::int32_t parent
std::string name
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
Light3D::Data * light
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:152
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 separator(std::string id)
Horizontal separator line.
Definition Widget.cpp:345
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:131
float backgroundColor[4]
Definition Theme.h:139
std::string name
Definition Theme.h:132
std::string parent
Definition Theme.h:133
float accentColor[4]
Definition Theme.h:141
bool hasBackgroundColor
Definition Theme.h:135
float textColor[4]
Definition Theme.h:138
float borderColor[4]
Definition Theme.h:140
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 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:39
ThemeLayout layout
Definition Theme.h:41