载入中...
搜索中...
未找到
Theme.h
浏览该文件的文档.
1#pragma once
2
3#include <string>
4
5namespace eve::ui {
6
12struct Theme {
13 // --- Colors (RGBA 0..1) ---
14 float text[4] = {0.92f, 0.93f, 0.95f, 1.f};
15 float textDisabled[4] = {0.50f, 0.52f, 0.55f, 1.f};
16 float windowBg[4] = {0.09f, 0.10f, 0.12f, 0.96f};
17 float childBg[4] = {0.07f, 0.08f, 0.10f, 0.90f};
18 float popupBg[4] = {0.11f, 0.12f, 0.14f, 0.98f};
19 float border[4] = {0.28f, 0.30f, 0.35f, 0.70f};
20 float frameBg[4] = {0.16f, 0.18f, 0.22f, 1.f};
21 float frameBgHovered[4] = {0.22f, 0.26f, 0.32f, 1.f};
22 float frameBgActive[4] = {0.26f, 0.32f, 0.40f, 1.f};
23 float titleBg[4] = {0.07f, 0.08f, 0.10f, 1.f};
24 float titleBgActive[4] = {0.12f, 0.18f, 0.28f, 1.f};
25 float titleBgCollapsed[4] = {0.07f, 0.08f, 0.10f, 0.75f};
26 float button[4] = {0.22f, 0.45f, 0.78f, 0.70f};
27 float buttonHovered[4] = {0.28f, 0.55f, 0.92f, 1.f};
28 float buttonActive[4] = {0.16f, 0.38f, 0.72f, 1.f};
29 float header[4] = {0.22f, 0.45f, 0.78f, 0.45f};
30 float headerHovered[4] = {0.28f, 0.55f, 0.92f, 0.70f};
31 float headerActive[4] = {0.22f, 0.45f, 0.78f, 1.f};
32 float checkMark[4] = {0.45f, 0.75f, 1.f, 1.f};
33 float sliderGrab[4] = {0.35f, 0.60f, 0.95f, 0.90f};
34 float sliderGrabActive[4] = {0.45f, 0.70f, 1.f, 1.f};
35 float separator[4] = {0.35f, 0.38f, 0.42f, 0.60f};
36 float scrollbarBg[4] = {0.05f, 0.06f, 0.07f, 0.55f};
37 float scrollbarGrab[4] = {0.35f, 0.38f, 0.42f, 0.80f};
38 float scrollbarGrabHovered[4] = {0.45f, 0.48f, 0.52f, 0.90f};
39 float scrollbarGrabActive[4] = {0.55f, 0.58f, 0.62f, 1.f};
40
41 // --- Geometry (design units @ scale 1) ---
42 float windowRounding = 6.f;
43 float childRounding = 4.f;
44 float frameRounding = 4.f;
45 float popupRounding = 6.f;
46 float scrollbarRounding = 8.f;
47 float grabRounding = 3.f;
48 float tabRounding = 4.f;
49
50 float windowBorderSize = 1.f;
51 float childBorderSize = 1.f;
52 float popupBorderSize = 1.f;
53 float frameBorderSize = 0.f;
54
55 float windowPaddingX = 12.f;
56 float windowPaddingY = 10.f;
57 float framePaddingX = 8.f;
58 float framePaddingY = 5.f;
59 float itemSpacingX = 8.f;
60 float itemSpacingY = 6.f;
61 float itemInnerSpacingX = 6.f;
62 float itemInnerSpacingY = 4.f;
63 float indentSpacing = 18.f;
64 float scrollbarSize = 14.f;
65 float grabMinSize = 12.f;
66
69 float fontScale = 1.f;
70 bool navEnableKeyboard = true;
71 bool navEnableGamepad = false;
72
74 static Theme dark();
75 static Theme light();
76};
77
80const std::string &globalThemeName();
81
82void setGlobalTheme(const Theme &theme);
83void setGlobalTheme(const Theme &theme, const std::string &name);
84
86bool setThemeByName(const std::string &name);
87
89void setThemeUiScale(float scale);
90float themeUiScale();
91
96void setThemeDpiScale(float dpiScale);
97float themeDpiScale();
98
100void applyThemeToImGui(const Theme &theme);
101void applyThemeToImGui(const Theme &theme, float uiScale);
102
103} // namespace eve::ui
Object::Ptr theme
const char * name
Definition RockMesh.cpp:21
float scale
Definition TreeMesh.cpp:122
void applyThemeToImGui(const Theme &theme)
Push tokens into ImGui style. Metrics are multiplied by uiScale (default: themeUiScale()).
Definition Theme.cpp:135
void setGlobalTheme(const Theme &theme)
Definition Theme.cpp:103
float themeDpiScale()
Definition Theme.cpp:133
void setThemeDpiScale(float dpiScale)
Definition Theme.cpp:129
bool setThemeByName(const std::string &name)
Apply a named preset ("dark" / "light"). Case-insensitive. Returns false if unknown.
Definition Theme.cpp:110
void setThemeUiScale(float scale)
Logical (point-space) UI scale. Default 1.0.
Definition Theme.cpp:123
float themeUiScale()
Definition Theme.cpp:127
const std::string & globalThemeName()
Current preset name: "dark", "light", or "custom".
Definition Theme.cpp:101
Theme & globalTheme()
Definition Theme.cpp:99
Unified UI design tokens (colors, geometry, typography). Applied to ImGui each frame via applyThemeTo...
Definition Theme.h:12
float titleBg[4]
Definition Theme.h:23
float frameBg[4]
Definition Theme.h:20
float checkMark[4]
Definition Theme.h:32
float itemSpacingX
Definition Theme.h:59
float scrollbarSize
Definition Theme.h:64
float indentSpacing
Definition Theme.h:63
float sliderGrab[4]
Definition Theme.h:33
float scrollbarGrab[4]
Definition Theme.h:37
float buttonHovered[4]
Definition Theme.h:27
float itemSpacingY
Definition Theme.h:60
float buttonActive[4]
Definition Theme.h:28
float windowPaddingX
Definition Theme.h:55
float frameBorderSize
Definition Theme.h:53
float childRounding
Definition Theme.h:43
float textDisabled[4]
Definition Theme.h:15
float separator[4]
Definition Theme.h:35
float titleBgActive[4]
Definition Theme.h:24
float popupBg[4]
Definition Theme.h:18
float fontScale
Definition Theme.h:69
float header[4]
Definition Theme.h:29
float grabMinSize
Definition Theme.h:65
float windowPaddingY
Definition Theme.h:56
float titleBgCollapsed[4]
Definition Theme.h:25
float framePaddingY
Definition Theme.h:58
bool navEnableKeyboard
Definition Theme.h:70
float scrollbarGrabHovered[4]
Definition Theme.h:38
float text[4]
Definition Theme.h:14
float itemInnerSpacingX
Definition Theme.h:61
float scrollbarGrabActive[4]
Definition Theme.h:39
float scrollbarRounding
Definition Theme.h:46
float grabRounding
Definition Theme.h:47
float frameBgActive[4]
Definition Theme.h:22
float windowBg[4]
Definition Theme.h:16
float windowRounding
Definition Theme.h:42
float windowBorderSize
Definition Theme.h:50
float framePaddingX
Definition Theme.h:57
static Theme light()
Definition Theme.cpp:40
float sliderGrabActive[4]
Definition Theme.h:34
float itemInnerSpacingY
Definition Theme.h:62
float headerHovered[4]
Definition Theme.h:30
float frameBgHovered[4]
Definition Theme.h:21
float popupBorderSize
Definition Theme.h:52
float childBg[4]
Definition Theme.h:17
float childBorderSize
Definition Theme.h:51
float frameRounding
Definition Theme.h:44
float headerActive[4]
Definition Theme.h:31
float button[4]
Definition Theme.h:26
float scrollbarBg[4]
Definition Theme.h:36
float tabRounding
Definition Theme.h:48
static Theme dark()
Built-in presets with matching geometry; only colors differ.
Definition Theme.cpp:34
float border[4]
Definition Theme.h:19
bool navEnableGamepad
Definition Theme.h:71
float popupRounding
Definition Theme.h:45