using AcDream.UI.Abstractions; namespace AcDream.UI.ImGui; /// /// implementation for the ImGui backend. Owns the /// registered panel set; iterates + draws every frame when the caller is /// inside an ImGui frame (between ImGui.NewFrame and /// ImGui.Render). /// /// /// This class does not call ImGui.NewFrame / ImGui.Render /// itself. Those belong to the caller (GameWindow) so GL-state /// ownership is explicit and the render-loop integration point is obvious. /// /// public sealed class ImGuiPanelHost : IPanelHost { private readonly Dictionary _panels = new(); private readonly ImGuiPanelRenderer _renderer = new(); /// public void Register(IPanel panel) { ArgumentNullException.ThrowIfNull(panel); _panels[panel.Id] = panel; // idempotent by Id } /// public void Unregister(string panelId) => _panels.Remove(panelId); /// public void RenderAll(PanelContext ctx) { // Order-independent — ImGui windows stack in the order they're drawn // for focus purposes but we have <=1 panel in D.2a. foreach (var panel in _panels.Values) { if (!panel.IsVisible) continue; panel.Render(ctx, _renderer); } } /// Current registered count (for diagnostics). public int Count => _panels.Count; }