Skip to content

Commit fdb81b9

Browse files
committed
More consistent styles
1 parent 117ccd1 commit fdb81b9

2 files changed

Lines changed: 33 additions & 18 deletions

File tree

Sources/OvUI/include/OvUI/Styling/Style.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ namespace OvUI::Styling
171171
void PopulateFromImGuiStyle(const struct ImGuiStyle& p_style);
172172

173173
// Sets semantic colors. Pass darkTheme=true for dark backgrounds, false for light.
174-
void SetSemanticDefaults(bool darkTheme);
174+
// Pass lighterOnActive=true to match ImGui built-in styles (active brighter than hover),
175+
// or false (default) for custom styles (active darker than base).
176+
void SetSemanticDefaults(bool darkTheme, bool lighterOnActive = false);
175177
};
176178
}

Sources/OvUI/src/OvUI/Styling/Style.cpp

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -114,27 +114,37 @@ void OvUI::Styling::Style::PopulateFromImGuiStyle(const ImGuiStyle& p_style)
114114
PopupBorderSize = p_style.PopupBorderSize;
115115
}
116116

117-
void OvUI::Styling::Style::SetSemanticDefaults(bool darkTheme)
117+
void OvUI::Styling::Style::SetSemanticDefaults(bool darkTheme, bool lighterOnActive)
118118
{
119119
using Types::Color;
120120

121121
Success = darkTheme ? Color{0.15f, 0.49f, 0.15f, 1.00f} : Color{0.22f, 0.75f, 0.22f, 1.00f};
122122
SuccessHovered = darkTheme ? Color{0.20f, 0.64f, 0.20f, 1.00f} : Color{0.32f, 0.85f, 0.32f, 1.00f};
123-
SuccessActive = darkTheme ? Color{0.11f, 0.37f, 0.11f, 1.00f} : Color{0.15f, 0.62f, 0.15f, 1.00f};
123+
// lighter: step up from hovered (ImGui built-in style behavior)
124+
// darker: step down from base (custom style behavior)
125+
SuccessActive = lighterOnActive
126+
? (darkTheme ? Color{0.26f, 0.76f, 0.26f, 1.00f} : Color{0.42f, 0.95f, 0.42f, 1.00f})
127+
: (darkTheme ? Color{0.11f, 0.37f, 0.11f, 1.00f} : Color{0.15f, 0.62f, 0.15f, 1.00f});
124128

125129
Danger = darkTheme ? Color{0.50f, 0.08f, 0.08f, 1.00f} : Color{0.85f, 0.22f, 0.22f, 1.00f};
126130
DangerHovered = darkTheme ? Color{0.65f, 0.11f, 0.11f, 1.00f} : Color{0.92f, 0.35f, 0.35f, 1.00f};
127-
DangerActive = darkTheme ? Color{0.38f, 0.06f, 0.06f, 1.00f} : Color{0.72f, 0.15f, 0.15f, 1.00f};
131+
DangerActive = lighterOnActive
132+
? (darkTheme ? Color{0.78f, 0.15f, 0.15f, 1.00f} : Color{1.00f, 0.48f, 0.48f, 1.00f})
133+
: (darkTheme ? Color{0.38f, 0.06f, 0.06f, 1.00f} : Color{0.72f, 0.15f, 0.15f, 1.00f});
128134

129135
Warning = darkTheme ? Color{0.70f, 0.50f, 0.00f, 1.00f} : Color{0.90f, 0.65f, 0.08f, 1.00f};
130136
WarningHovered = darkTheme ? Color{0.80f, 0.60f, 0.00f, 1.00f} : Color{1.00f, 0.75f, 0.18f, 1.00f};
131-
WarningActive = darkTheme ? Color{0.55f, 0.38f, 0.00f, 1.00f} : Color{0.78f, 0.54f, 0.04f, 1.00f};
137+
WarningActive = lighterOnActive
138+
? (darkTheme ? Color{0.92f, 0.72f, 0.04f, 1.00f} : Color{1.00f, 0.86f, 0.30f, 1.00f})
139+
: (darkTheme ? Color{0.55f, 0.38f, 0.00f, 1.00f} : Color{0.78f, 0.54f, 0.04f, 1.00f});
132140

133141
Info = darkTheme ? Color{0.30f, 0.85f, 1.00f, 1.00f} : Color{0.00f, 0.40f, 0.75f, 1.00f};
134142

135143
Accent = darkTheme ? Color{0.10f, 0.30f, 0.70f, 1.00f} : Color{0.15f, 0.45f, 0.90f, 1.00f};
136144
AccentHovered = darkTheme ? Color{0.15f, 0.40f, 0.85f, 1.00f} : Color{0.25f, 0.55f, 1.00f, 1.00f};
137-
AccentActive = darkTheme ? Color{0.07f, 0.22f, 0.55f, 1.00f} : Color{0.10f, 0.35f, 0.75f, 1.00f};
145+
AccentActive = lighterOnActive
146+
? (darkTheme ? Color{0.20f, 0.52f, 1.00f, 1.00f} : Color{0.36f, 0.67f, 1.00f, 1.00f})
147+
: (darkTheme ? Color{0.07f, 0.22f, 0.55f, 1.00f} : Color{0.10f, 0.35f, 0.75f, 1.00f});
138148

139149
InspectorTitle = darkTheme ? Color{0.85f, 0.65f, 0.00f, 1.00f} : Color{0.55f, 0.35f, 0.00f, 1.00f};
140150

@@ -146,23 +156,23 @@ void OvUI::Styling::Style::ApplyImClassicStyle()
146156
ImGuiStyle tmp;
147157
ImGui::StyleColorsClassic(&tmp);
148158
PopulateFromImGuiStyle(tmp);
149-
SetSemanticDefaults(true);
159+
SetSemanticDefaults(true, true);
150160
}
151161

152162
void OvUI::Styling::Style::ApplyImDarkStyle()
153163
{
154164
ImGuiStyle tmp;
155165
ImGui::StyleColorsDark(&tmp);
156166
PopulateFromImGuiStyle(tmp);
157-
SetSemanticDefaults(true);
167+
SetSemanticDefaults(true, true);
158168
}
159169

160170
void OvUI::Styling::Style::ApplyImLightStyle()
161171
{
162172
ImGuiStyle tmp;
163173
ImGui::StyleColorsLight(&tmp);
164174
PopulateFromImGuiStyle(tmp);
165-
SetSemanticDefaults(false);
175+
SetSemanticDefaults(false, true);
166176
}
167177

168178
void OvUI::Styling::Style::ApplyDuneDarkStyle()
@@ -179,7 +189,7 @@ void OvUI::Styling::Style::ApplyDuneDarkStyle()
179189
BorderShadow = { 0.92f, 0.91f, 0.88f, 0.00f };
180190
FrameBg = { 0.10f, 0.09f, 0.12f, 1.00f };
181191
FrameBgHovered = { 0.24f, 0.23f, 0.29f, 1.00f };
182-
FrameBgActive = { 0.56f, 0.56f, 0.58f, 1.00f };
192+
FrameBgActive = { 0.07f, 0.06f, 0.09f, 1.00f };
183193
TitleBg = { 0.10f, 0.09f, 0.12f, 1.00f };
184194
TitleBgCollapsed = { 0.30f, 0.30f, 0.30f, 0.75f };
185195
TitleBgActive = { 0.07f, 0.07f, 0.09f, 1.00f };
@@ -193,7 +203,7 @@ void OvUI::Styling::Style::ApplyDuneDarkStyle()
193203
SliderGrabActive = { 0.06f, 0.05f, 0.07f, 1.00f };
194204
Button = { 0.10f, 0.09f, 0.12f, 1.00f };
195205
ButtonHovered = { 0.24f, 0.23f, 0.29f, 1.00f };
196-
ButtonActive = { 0.56f, 0.56f, 0.58f, 1.00f };
206+
ButtonActive = { 0.07f, 0.06f, 0.09f, 1.00f };
197207
Header = { 0.10f, 0.09f, 0.12f, 1.00f };
198208
HeaderHovered = { 0.56f, 0.56f, 0.58f, 1.00f };
199209
HeaderActive = { 0.06f, 0.05f, 0.07f, 1.00f };
@@ -222,6 +232,9 @@ void OvUI::Styling::Style::ApplyDuneDarkStyle()
222232
ScrollbarRounding= 9.0f;
223233
GrabMinSize = 5.0f;
224234
GrabRounding = 3.0f;
235+
236+
// Override semantics inherited from ApplyImDarkStyle() — this is a custom style.
237+
SetSemanticDefaults(true, false);
225238
}
226239

227240
void OvUI::Styling::Style::ApplyDefaultDarkStyle()
@@ -235,7 +248,7 @@ void OvUI::Styling::Style::ApplyDefaultDarkStyle()
235248
BorderShadow = { 0.00f, 0.00f, 0.00f, 0.00f };
236249
FrameBg = { 0.12f, 0.12f, 0.13f, 1.00f };
237250
FrameBgHovered = { 0.20f, 0.20f, 0.22f, 1.00f };
238-
FrameBgActive = { 0.27f, 0.27f, 0.29f, 1.00f };
251+
FrameBgActive = { 0.08f, 0.08f, 0.09f, 1.00f };
239252
TitleBg = { 0.07f, 0.07f, 0.07f, 1.00f };
240253
TitleBgActive = { 0.07f, 0.07f, 0.07f, 1.00f };
241254
TitleBgCollapsed = { 0.07f, 0.07f, 0.07f, 1.00f };
@@ -249,10 +262,10 @@ void OvUI::Styling::Style::ApplyDefaultDarkStyle()
249262
SliderGrabActive = { 0.59f, 0.59f, 0.61f, 1.00f };
250263
Button = { 0.20f, 0.20f, 0.22f, 1.00f };
251264
ButtonHovered = { 0.44f, 0.44f, 0.47f, 1.00f };
252-
ButtonActive = { 0.59f, 0.59f, 0.61f, 1.00f };
265+
ButtonActive = { 0.13f, 0.13f, 0.14f, 1.00f };
253266
Header = { 0.20f, 0.20f, 0.22f, 1.00f };
254267
HeaderHovered = { 0.44f, 0.44f, 0.47f, 1.00f };
255-
HeaderActive = { 0.59f, 0.59f, 0.61f, 1.00f };
268+
HeaderActive = { 0.13f, 0.13f, 0.14f, 1.00f };
256269
Separator = { 1.00f, 1.00f, 1.00f, 0.20f };
257270
SeparatorHovered = { 0.44f, 0.44f, 0.47f, 0.39f };
258271
SeparatorActive = { 0.44f, 0.44f, 0.47f, 0.59f };
@@ -320,8 +333,8 @@ void OvUI::Styling::Style::ApplyEvenDarkerStyle()
320333
Border = { 0.06f, 0.07f, 0.08f, 1.00f };
321334
BorderShadow = { 0.00f, 0.00f, 0.00f, 0.00f };
322335
FrameBg = { 0.12f, 0.12f, 0.13f, 1.00f };
323-
FrameBgHovered = { 0.12f, 0.12f, 0.13f, 1.00f };
324-
FrameBgActive = { 0.12f, 0.12f, 0.13f, 1.00f };
336+
FrameBgHovered = { 0.20f, 0.20f, 0.22f, 1.00f };
337+
FrameBgActive = { 0.08f, 0.08f, 0.09f, 1.00f };
325338
TitleBg = { 0.01f, 0.02f, 0.03f, 1.00f };
326339
TitleBgActive = { 0.01f, 0.02f, 0.03f, 1.00f };
327340
TitleBgCollapsed = { 0.01f, 0.02f, 0.03f, 1.00f };
@@ -335,10 +348,10 @@ void OvUI::Styling::Style::ApplyEvenDarkerStyle()
335348
SliderGrabActive = { 0.59f, 0.59f, 0.61f, 1.00f };
336349
Button = { 0.20f, 0.20f, 0.22f, 1.00f };
337350
ButtonHovered = { 0.44f, 0.44f, 0.47f, 1.00f };
338-
ButtonActive = { 0.59f, 0.59f, 0.61f, 1.00f };
351+
ButtonActive = { 0.13f, 0.13f, 0.14f, 1.00f };
339352
Header = { 0.10f, 0.10f, 0.11f, 1.00f };
340353
HeaderHovered = { 0.15f, 0.15f, 0.17f, 1.00f };
341-
HeaderActive = { 0.20f, 0.20f, 0.22f, 1.00f };
354+
HeaderActive = { 0.06f, 0.06f, 0.07f, 1.00f };
342355
Separator = { 1.00f, 1.00f, 1.00f, 0.20f };
343356
SeparatorHovered = { 0.44f, 0.44f, 0.47f, 0.39f };
344357
SeparatorActive = { 0.44f, 0.44f, 0.47f, 0.59f };

0 commit comments

Comments
 (0)