Files
HellionChat/HellionChat/Ui/Components/Settings/LivePreviewPanel.cs
T

89 lines
2.4 KiB
C#

using System.Numerics;
using System.Threading;
using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Utility.Raii;
using HellionChat.Themes;
using HellionChat.Ui.StyleEngine;
namespace HellionChat.Ui.Components.Settings;
internal sealed class LivePreviewPanel : IDisposable
{
// Static counter for S5 reload-stress verification: after 10 reloads the
// counter must read 0 (plugin disabled) or 1 (plugin enabled). Anything
// higher signals a Dispose skip and a subscriber leak against ThemeRegistry.
internal static int InstanceCount;
private readonly ThemeRegistry _themes;
private readonly TokenResolver _resolver;
public LivePreviewPanel(ThemeRegistry themes, TokenResolver resolver)
{
_themes = themes;
_resolver = resolver;
_themes.OnEditingBufferChanged += OnBufferChanged;
Interlocked.Increment(ref InstanceCount);
}
public void Dispose()
{
_themes.OnEditingBufferChanged -= OnBufferChanged;
Interlocked.Decrement(ref InstanceCount);
}
private void OnBufferChanged()
{
// Visual repaint already runs per frame via Draw(); hook reserved for
// future telemetry or invalidation. Keep empty in v1.7.0.
}
public void Draw()
{
using var child = ImRaii.Child("##settings-live-preview", new Vector2(280, 0), true);
if (!child.Success)
{
return;
}
var theme = _themes.EditingThemeBuffer ?? _themes.Active;
DrawBrandBar(theme);
DrawHonorificHeader(theme);
DrawSidebar(theme);
DrawMessageList(theme);
DrawInputBar(theme);
DrawStatusBar(theme);
}
private void DrawBrandBar(Theme theme)
{
// Mini gradient: PrimaryDark → Primary → PrimaryLight → PrimaryGlow.
// Implementation lands in next sub-step.
}
private void DrawHonorificHeader(Theme theme)
{
// Crown + Brackets-Title in Identity. Implementation in next sub-step.
}
private void DrawSidebar(Theme theme)
{
// 3 channel rows. Implementation in next sub-step.
}
private void DrawMessageList(Theme theme)
{
// 4 mock messages. Implementation in next sub-step.
}
private void DrawInputBar(Theme theme)
{
// Pill + text + cog. Implementation in next sub-step.
}
private void DrawStatusBar(Theme theme)
{
// Status icons. Implementation in next sub-step.
}
}