feat(themes): apply theme typography font-size overrides on every activation path
This commit is contained in:
@@ -47,6 +47,12 @@ public sealed class ThemeRegistry
|
||||
public Theme? EditingThemeBuffer => _editingThemeBuffer;
|
||||
public event Action? OnEditingBufferChanged;
|
||||
|
||||
// Fired after _active changes (Switch / RefreshActiveIfStale); the init host
|
||||
// wires it to the font-atlas rebuild. NOT fired by SwitchSilent (boot handles that).
|
||||
private Action? _onActiveChanged;
|
||||
|
||||
internal void SetActiveChangedCallback(Action callback) => _onActiveChanged = callback;
|
||||
|
||||
// Shared slug guard for any code path that turns a slug into a filename.
|
||||
// Both SaveEditingBuffer (F1) and ImportFromPath (M6) call this so the
|
||||
// path-traversal/invalid-char rules live in exactly one place.
|
||||
@@ -190,27 +196,32 @@ public sealed class ThemeRegistry
|
||||
_active = builtin;
|
||||
_active.RecomputeAbgrCache();
|
||||
_activeCustomPath = null;
|
||||
return;
|
||||
}
|
||||
|
||||
var customTheme = LoadCustomBySlug(slug, out var customPath);
|
||||
if (customTheme is not null)
|
||||
else
|
||||
{
|
||||
_active = customTheme;
|
||||
// Defensive — ensures any future theme source always gets a populated cache.
|
||||
_active.RecomputeAbgrCache();
|
||||
_activeCustomPath = customPath;
|
||||
// Force a first-tick reload-check after the switch so the stamp
|
||||
// baseline is established on the next RefreshActiveIfStale call.
|
||||
_lastActiveStamp = DateTime.MinValue;
|
||||
return;
|
||||
var customTheme = LoadCustomBySlug(slug, out var customPath);
|
||||
if (customTheme is not null)
|
||||
{
|
||||
_active = customTheme;
|
||||
// Defensive — ensures any future theme source always gets a populated cache.
|
||||
_active.RecomputeAbgrCache();
|
||||
_activeCustomPath = customPath;
|
||||
// Force a first-tick reload-check after the switch so the stamp
|
||||
// baseline is established on the next RefreshActiveIfStale call.
|
||||
_lastActiveStamp = DateTime.MinValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fallback: neither built-in nor custom matched. Drop to default
|
||||
// and clear the active custom path so RefreshActiveIfStale stays idle.
|
||||
_active = _builtIns[DefaultSlug];
|
||||
_active.RecomputeAbgrCache();
|
||||
_activeCustomPath = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: neither built-in nor custom matched. Drop to default
|
||||
// and clear the active custom path so RefreshActiveIfStale stays idle.
|
||||
_active = _builtIns[DefaultSlug];
|
||||
_active.RecomputeAbgrCache();
|
||||
_activeCustomPath = null;
|
||||
// Notify listeners (the init host wires the font-atlas rebuild here).
|
||||
_onActiveChanged?.Invoke();
|
||||
}
|
||||
|
||||
// SwitchSilent is the plugin-load init path -- identical to Switch
|
||||
@@ -426,6 +437,9 @@ public sealed class ThemeRegistry
|
||||
{
|
||||
reloaded.RecomputeAbgrCache();
|
||||
_active = reloaded;
|
||||
// Same-slug save bypasses Switch's notify (it noop'd on same slug);
|
||||
// fire here so a typography change applies (no-op if size unchanged).
|
||||
_onActiveChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -568,6 +582,7 @@ public sealed class ThemeRegistry
|
||||
// RecomputeAbgrCache happens inside RefreshCustomCache on cache miss.
|
||||
var reloaded = Get(_active.Slug);
|
||||
_active = reloaded;
|
||||
_onActiveChanged?.Invoke();
|
||||
}
|
||||
|
||||
// 0x80070020 = SHARING_VIOLATION, 0x80070021 = LOCK_VIOLATION.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
namespace HellionChat.Themes;
|
||||
|
||||
// Optional per-theme; reserved as an extension point for future theme slots.
|
||||
// Italic body-size override intentionally omitted (v1.9.0 Typography-Polish).
|
||||
public sealed record ThemeTypography(
|
||||
float? OverrideGlobalFontSizePt = null,
|
||||
float? OverrideSymbolsFontSizePt = null
|
||||
|
||||
Reference in New Issue
Block a user