Theme: every button state keeps its type's margins (checked CheckBox label no longer jumps)

This commit is contained in:
cthangover committed 2026-10-24 18:39:42 +02:00
1 parent 532c2babd4
commit c88ddaab74
3 files changed
+31 -1

No files matched your search

+1
View File
@@ -54,3 +54,4 @@ jobs/
/site_github/
build_site.*
sync_mod_repos*
__pycache__/
+29
View File
@@ -98,10 +98,39 @@ namespace Cthangover.Core.UI.Theming
ConfigureLists(theme);
ConfigureWindows(theme);
ConfigureMisc(theme);
CompleteButtonStates(theme);
return theme;
}
/// <summary>
/// A state a button type leaves out is looked up elsewhere: <c>hover_pressed</c> (a checked
/// CheckBox or toggle under the mouse) in Godot's default theme, a variation's
/// <c>disabled</c> in the plain Button. Their margins differ (CheckBox: 4 px instead of 18,
/// a tab: 18 instead of 13), so the label jumped right after a click. Every type that styles
/// <c>normal</c> gets each missing state from its nearest own one.
/// </summary>
private static void CompleteButtonStates(Theme theme)
{
var fallbacks = new[]
{
("hover", "normal"),
("pressed", "hover"),
("hover_pressed", "pressed"),
("disabled", "normal"),
};
foreach (var type in theme.GetStyleboxTypeList())
{
if (!theme.HasStylebox("normal", type))
continue;
foreach (var (state, from) in fallbacks)
{
if (!theme.HasStylebox(state, type))
theme.SetStylebox(state, type, theme.GetStylebox(from, type));
}
}
}
// ── Globals ─────────────────────────────────────────────────────
private static void ConfigureGlobals(Theme theme)
Submodule mods/editor_tools updated: 80c86063c4...84894b1e98.