From e8dffde54dbdffe388bf219aa3398461bc4549ba Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 18 May 2026 04:27:15 +0100 Subject: [PATCH] Render client navigation panels as floating UI --- .../Ui/AquariumUi.cs | 10 ++++- src/Aquarium.Engine/Render/D3D12Renderer.cs | 31 ++++++------- .../Render/DirectWriteOverlay.cs | 43 ++++++++++++++----- src/Aquarium.Engine/Render/Ui/DebugUi.cs | 32 ++++++++++++-- src/Aquarium.Zyphos/ZyphosRuntime.cs | 30 +++++++++++++ state/evidence.jsonl | 1 + state/map.yaml | 1 + 7 files changed, 114 insertions(+), 34 deletions(-) diff --git a/src/Aquarium.Engine.Contracts/Ui/AquariumUi.cs b/src/Aquarium.Engine.Contracts/Ui/AquariumUi.cs index e467613..ada68f2 100644 --- a/src/Aquarium.Engine.Contracts/Ui/AquariumUi.cs +++ b/src/Aquarium.Engine.Contracts/Ui/AquariumUi.cs @@ -17,10 +17,15 @@ public sealed class AquariumUiDocument } public AquariumUiDocument Panel(string title, float left, float top, float width, Action compose) + { + return Panel(title, left, top, width, fadeWhenMouseDistant: false, compose); + } + + public AquariumUiDocument Panel(string title, float left, float top, float width, bool fadeWhenMouseDistant, Action compose) { var controls = new List(); compose(new AquariumUiPanelBuilder(controls)); - panels.Add(new AquariumUiPanel(title, left, top, width, controls)); + panels.Add(new AquariumUiPanel(title, left, top, width, controls, fadeWhenMouseDistant)); return this; } @@ -36,7 +41,8 @@ public sealed record AquariumUiPanel( float Left, float Top, float Width, - IReadOnlyList Controls); + IReadOnlyList Controls, + bool FadeWhenMouseDistant = false); public sealed class AquariumUiPanelBuilder(List controls) { diff --git a/src/Aquarium.Engine/Render/D3D12Renderer.cs b/src/Aquarium.Engine/Render/D3D12Renderer.cs index 76aa631..7721b72 100644 --- a/src/Aquarium.Engine/Render/D3D12Renderer.cs +++ b/src/Aquarium.Engine/Render/D3D12Renderer.cs @@ -95,6 +95,7 @@ public sealed class D3D12Renderer : IAquariumRenderer private readonly ID3D12Fence fence; private readonly AutoResetEvent fenceEvent = new(false); private DebugUi debugUi; + private IReadOnlyList clientUiPanels = []; private AquariumUiDocument? currentClientUi; private int activeDebugTab; private string[] debugTabTitles = ["Aquarium", "Terminal", "Synth"]; @@ -211,7 +212,7 @@ public sealed class D3D12Renderer : IAquariumRenderer CreateRenderTargetViews(); CreateBackBufferOverlays(); - debugUi = CreateDebugUi(AquariumUiDocument.Empty); + debugUi = CreateDebugUi(); heightFieldRenderTarget = CreateHeightFieldRenderTarget(); sceneRenderTarget = CreateSceneRenderTarget(); sceneMetadataRenderTarget = CreateSceneAuxiliaryRenderTarget("scene-metadata-target", "Aquarium D3D12 Scene Metadata Target"); @@ -263,7 +264,7 @@ public sealed class D3D12Renderer : IAquariumRenderer public bool HasPresentedReadyFrame => hasPresentedReadyFrame; - public bool CapturesInput => debugUi.WantsKeyboard || debugUi.WantsMouse; + public bool CapturesInput => debugUi.WantsKeyboard || debugUi.WantsMouse || clientUiPanels.Any(panel => panel.WantsKeyboard || panel.WantsMouse); public AquariumSynthDocument DebugSynth => new AquariumSynthDocument { @@ -284,12 +285,17 @@ public sealed class D3D12Renderer : IAquariumRenderer { currentClientUi = clientUi; clientCommands = clientUi.Commands; - debugTabTitles = ["Aquarium", "Terminal", "Synth", .. clientUi.Panels.Select(panel => panel.Title)]; + debugTabTitles = ["Aquarium", "Terminal", "Synth"]; activeDebugTab = Math.Clamp(activeDebugTab, 0, debugTabTitles.Length - 1); - debugUi = CreateDebugUi(clientUi); + debugUi = CreateDebugUi(); + clientUiPanels = clientUi.Panels.Select(DebugUi.FromContract).ToArray(); } debugUi.Update(input); + foreach (var panel in clientUiPanels) + { + panel.Update(input); + } } public void CycleRenderDebugMode() @@ -307,7 +313,7 @@ public sealed class D3D12Renderer : IAquariumRenderer settings = graphicsSettings.Normalized(); } - private DebugUi CreateDebugUi(AquariumUiDocument clientUi) + private DebugUi CreateDebugUi() { var ui = new DebugUi("Debug", 18.0f, 18.0f, 520.0f, debugTabTitles, () => activeDebugTab, SelectDebugTab) .Panel(panel => @@ -329,14 +335,6 @@ public sealed class D3D12Renderer : IAquariumRenderer .Slider("Gain", () => synthPlaygroundGain, value => synthPlaygroundGain = Math.Clamp(value, 0.0f, 1.0f), 0.0f, 1.0f, "0.###", "Playground patch gain.", () => activeDebugTab == 2) .Button("Play", () => synthPlaygroundPlayRevision++, "Triggers the compiled playground patch.", () => activeDebugTab == 2); }); - for (var panelIndex = 0; panelIndex < clientUi.Panels.Count; panelIndex++) - { - var tabIndex = panelIndex + 3; - foreach (var control in clientUi.Panels[panelIndex].Controls) - { - ui.AddContractControl(control with { IsVisible = ComposeVisibility(control.IsVisible, () => activeDebugTab == tabIndex) }); - } - } return ui; } @@ -346,11 +344,6 @@ public sealed class D3D12Renderer : IAquariumRenderer activeDebugTab = Math.Clamp(index, 0, Math.Max(0, debugTabTitles.Length - 1)); } - private static Func ComposeVisibility(Func? source, Func tabVisible) - { - return () => tabVisible() && (source?.Invoke() ?? true); - } - private string TerminalDisplay() { return string.Join('\n', terminalLines.TakeLast(10).Append($"> {terminalInput}")); @@ -820,7 +813,7 @@ public sealed class D3D12Renderer : IAquariumRenderer { var wrappedBackBuffer = overlayWrappedBackBuffers[frameIndex]; overlayOn12Device.AcquireWrappedResources([wrappedBackBuffer]); - overlays[frameIndex].Render(frame, RenderDebugMode, debugUi, []); + overlays[frameIndex].Render(frame, RenderDebugMode, debugUi, clientUiPanels); overlayOn12Device.ReleaseWrappedResources([wrappedBackBuffer]); overlayContext.Flush(); frameResources.BackBuffer.MarkState(ResourceStates.Present); diff --git a/src/Aquarium.Engine/Render/DirectWriteOverlay.cs b/src/Aquarium.Engine/Render/DirectWriteOverlay.cs index b1698a3..4968813 100644 --- a/src/Aquarium.Engine/Render/DirectWriteOverlay.cs +++ b/src/Aquarium.Engine/Render/DirectWriteOverlay.cs @@ -87,12 +87,23 @@ internal sealed class DirectWriteOverlay : IDisposable public void Render(AquariumFrame frame, int renderDebugMode, DebugUi? debugUi, IReadOnlyList clientUiPanels) { renderTarget.BeginDraw(); - debugUi?.Draw( - renderTarget, - directWriteFactory, - titleFormat, - smallFormat, - monospaceFormat, + if (debugUi is not null) + { + DrawPanel(debugUi, 1.0f); + } + + foreach (var panel in clientUiPanels) + { + DrawPanel(panel, panel.DrawOpacity()); + } + + renderTarget.EndDraw(); + } + + private void DrawPanel(DebugUi panel, float opacity) + { + var brushes = new ID2D1SolidColorBrush[] + { panelBrush, rowBrush, hoverRowBrush, @@ -106,9 +117,15 @@ internal sealed class DirectWriteOverlay : IDisposable dimAccentBrush, trackHoverBrush, trackActiveBrush, - width, - height); - foreach (var panel in clientUiPanels) + }; + var originalOpacity = new float[brushes.Length]; + for (var index = 0; index < brushes.Length; index++) + { + originalOpacity[index] = brushes[index].Opacity; + brushes[index].Opacity = originalOpacity[index] * opacity; + } + + try { panel.Draw( renderTarget, @@ -132,7 +149,13 @@ internal sealed class DirectWriteOverlay : IDisposable width, height); } - renderTarget.EndDraw(); + finally + { + for (var index = 0; index < brushes.Length; index++) + { + brushes[index].Opacity = originalOpacity[index]; + } + } } public void Dispose() diff --git a/src/Aquarium.Engine/Render/Ui/DebugUi.cs b/src/Aquarium.Engine/Render/Ui/DebugUi.cs index 2d845ce..2f88c5b 100644 --- a/src/Aquarium.Engine/Render/Ui/DebugUi.cs +++ b/src/Aquarium.Engine/Render/Ui/DebugUi.cs @@ -36,6 +36,7 @@ internal sealed class DebugUi private readonly float panelLeft; private readonly float panelTop; private readonly float panelWidth; + private readonly bool fadeWhenMouseDistant; private int? activeSliderId; private int? activeControlId; private int? focusedTextId; @@ -44,6 +45,7 @@ internal sealed class DebugUi private Rect panelBounds; private Vector2 mousePosition; private int lastViewportHeight = 720; + private int lastViewportWidth = 1280; private float bodyScrollOffset; private float bodyContentHeight; private Rect bodyClipBounds; @@ -59,11 +61,17 @@ internal sealed class DebugUi } public DebugUi(string title, float left, float top, float width, IReadOnlyList tabs, Func readActiveTab, Action writeActiveTab) + : this(title, left, top, width, fadeWhenMouseDistant: false, tabs, readActiveTab, writeActiveTab) + { + } + + public DebugUi(string title, float left, float top, float width, bool fadeWhenMouseDistant, IReadOnlyList tabs, Func readActiveTab, Action writeActiveTab) { Title = title; panelLeft = left; panelTop = top; panelWidth = width; + this.fadeWhenMouseDistant = fadeWhenMouseDistant; this.tabs = tabs; this.readActiveTab = readActiveTab; this.writeActiveTab = writeActiveTab; @@ -79,7 +87,7 @@ internal sealed class DebugUi public static DebugUi FromContract(AquariumUiPanel source) { - var ui = new DebugUi(source.Title, source.Left, source.Top, source.Width); + var ui = new DebugUi(source.Title, source.Left, source.Top, source.Width, source.FadeWhenMouseDistant, [], () => 0, _ => { }); foreach (var control in source.Controls) { ui.AddContractControl(control); @@ -361,6 +369,7 @@ internal sealed class DebugUi return; } + lastViewportWidth = viewportWidth; lastViewportHeight = viewportHeight; Layout(); @@ -452,13 +461,14 @@ internal sealed class DebugUi private void Layout() { + var left = ResolvedPanelLeft(); var bodyTop = panelTop + HeaderHeight + (tabs.Count > 0 ? TabRowHeight : 0.0f) + 10.0f; var maxPanelBottom = MathF.Max(bodyTop + RowHeight, lastViewportHeight - ScreenMargin); var visibleControls = controls.Where(control => control.IsVisible).ToArray(); bodyContentHeight = ContentHeight(visibleControls); var desiredBottom = bodyTop + bodyContentHeight + 12.0f; var bottom = lastViewportHeight > 0 ? Math.Min(desiredBottom, maxPanelBottom) : desiredBottom; - panelBounds = RectFromEdges(panelLeft, panelTop, panelLeft + panelWidth, bottom); + panelBounds = RectFromEdges(left, panelTop, left + panelWidth, bottom); bodyClipBounds = RectFromEdges(panelBounds.Left, bodyTop, panelBounds.Right, MathF.Max(bodyTop, panelBounds.Bottom - 8.0f)); bodyScrollOffset = Math.Clamp(bodyScrollOffset, 0.0f, MaxBodyScrollOffset()); @@ -466,11 +476,27 @@ internal sealed class DebugUi foreach (var control in visibleControls) { var height = control.LayoutHeight; - control.Bounds = RectFromEdges(panelLeft + 10.0f, y, panelLeft + panelWidth - 10.0f, y + height); + control.Bounds = RectFromEdges(left + 10.0f, y, left + panelWidth - 10.0f, y + height); y += height + (control is SectionControl ? 2.0f : RowGap); } } + public float DrawOpacity() + { + if (!fadeWhenMouseDistant) + { + return 1.0f; + } + + var near = RectFromEdges(panelBounds.Left - 72.0f, panelBounds.Top - 72.0f, panelBounds.Right + 72.0f, panelBounds.Bottom + 72.0f); + return Contains(near, mousePosition) ? 1.0f : 0.1f; + } + + private float ResolvedPanelLeft() + { + return panelLeft < 0.0f ? MathF.Max(ScreenMargin, lastViewportWidth + panelLeft - panelWidth) : panelLeft; + } + private static float ContentHeight(IReadOnlyList visibleControls) { var height = 0.0f; diff --git a/src/Aquarium.Zyphos/ZyphosRuntime.cs b/src/Aquarium.Zyphos/ZyphosRuntime.cs index 20be00b..86e1a06 100644 --- a/src/Aquarium.Zyphos/ZyphosRuntime.cs +++ b/src/Aquarium.Zyphos/ZyphosRuntime.cs @@ -17,6 +17,17 @@ public sealed class ZyphosRuntime : IAquariumRuntime private float timeScale = 1.0f; private bool autoOrbit = true; private ZyphosCameraFrame cameraFrame; + private bool showSolarDomain = true; + private bool showOrbitalDomain = true; + private bool showPlanetaryDomains = true; + private bool showSurfaceDomains = true; + + private static readonly AquariumUiOption[] CameraFrameOptions = + [ + new((int)ZyphosCameraFrame.Planet, "Planet"), + new((int)ZyphosCameraFrame.Umbros, "Umbros"), + new((int)ZyphosCameraFrame.Binary, "Binary"), + ]; public AquariumRuntimeOptions Options { get; private set; } @@ -61,6 +72,25 @@ public sealed class ZyphosRuntime : IAquariumRuntime panel.Readout("Binary", () => $"Umbros {ZyphosUmbrosSystem.UmbrosAngularDiameterDegrees:0.0} deg / {ZyphosUmbrosSystem.SeparationInZyphosRadii:0.0} Rz"); panel.Readout("Objects", () => "fractal height DSL, atmosphere, Umbros"); }) + .Panel("Navigation", -18.0f, 82.0f, 316.0f, fadeWhenMouseDistant: true, panel => + { + panel.Section("Frame Lock"); + panel.Options("Target", () => (int)cameraFrame, value => cameraFrame = (ZyphosCameraFrame)Math.Clamp(value, 0, 2), CameraFrameOptions); + panel.Toggle("Auto Orbit", () => autoOrbit, value => autoOrbit = value); + panel.Readout("Pivot", () => cameraFrame == ZyphosCameraFrame.Planet ? "Zyphos center" : "Parent: Zyphos"); + panel.Readout("Constraint", () => cameraFrame == ZyphosCameraFrame.Planet ? "planet frame" : "keep parent in sight"); + panel.Section("Spatial Domains"); + panel.Toggle("Solar", () => showSolarDomain, value => showSolarDomain = value); + panel.Readout(" parent star", () => "M primary / 0.077 AU", isVisible: () => showSolarDomain); + panel.Toggle("Orbital", () => showOrbitalDomain, value => showOrbitalDomain = value); + panel.Readout(" Zyphos-Umbros", () => "8 Rz / 52 min eclipse", isVisible: () => showOrbitalDomain); + panel.Toggle("Planetary", () => showPlanetaryDomains, value => showPlanetaryDomains = value); + panel.Readout(" Zyphos", () => "surface + sea domain", isVisible: () => showPlanetaryDomains); + panel.Readout(" Umbros", () => "fixed-sky twin", isVisible: () => showPlanetaryDomains); + panel.Toggle("Surface", () => showSurfaceDomains, value => showSurfaceDomains = value); + panel.Readout(" lat/long", () => "terrain patch parent", isVisible: () => showSurfaceDomains); + panel.Readout(" cube tile", () => ZyphosFractalTerrain.Summary, isVisible: () => showSurfaceDomains); + }) .Command("zyphos", _ => $"Zyphos: {ZyphosFractalTerrain.Summary}", "Report Zyphos demo status.") .Command("zyphos-fractal", _ => ZyphosFractalTerrain.DebugDump, "Dump the compiled Zyphos fractal terrain grammar.") .Command("zyphos-system", _ => $"Zyphos-Umbros: separation {ZyphosUmbrosSystem.SeparationInZyphosRadii:0.0} Zyphos radii, Umbros radius {ZyphosUmbrosSystem.UmbrosRadiusRatio:0.00} Zyphos, apparent diameter {ZyphosUmbrosSystem.UmbrosAngularDiameterDegrees:0.0} degrees.", "Report the modeled Zyphos/Umbros/star baseline."); diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 4d26a9f..9a6b62f 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -141,3 +141,4 @@ {"timestamp":"2026-05-18T08:22:00+01:00","topic":"debug-ui-panel-scrolling","lesson":"DebugUi panels now own body scrolling, body clipping, and a visible scrollbar when controls exceed the viewport. Individual controls can still own local scrolling for text boxes and option popups, but panel overflow is an engine-level invariant so client panels cannot spill out of their frame.","files":["src/Aquarium.Engine/Render/Ui/DebugUi.cs"],"source":"user reported Zyphos UI did not fit its panel and expected all panels to have scrollbars"} {"timestamp":"2026-05-18T04:09:10+01:00","topic":"face-voice-proximity-routing","lesson":"Face voice is now routed through typed endpoint rows instead of one global session. `FaceVoiceRouter` selects the active endpoint by cursor/listener proximity when auto-route is enabled, while each `FaceVoiceEndpoint` owns its thread id, voice, prompt, enabled state, and XY anchor before delegating transport to `RealtimeFaceVoiceSession`. This keeps multi-Face speech routing explicit and spatial, while the next impurity to cut is manual XY placement: endpoint anchors should bind to real Face/body visual projections once those projections are exposed as a CPU-visible contract.","files":["src/Aquarium.Epiphany/Voice/FaceVoiceRouter.cs","src/Aquarium.Epiphany/Voice/FaceVoiceEndpoint.cs","src/Aquarium.Epiphany/AquariumRuntime.cs","src/Aquarium.Epiphany/State/AquariumLiveState.cs","state/map.yaml"],"source":"user asked to hook the voice path up while keeping in mind several Faces selected by spatial proximity"} {"timestamp":"2026-05-18T04:32:00+01:00","topic":"face-rumination-output-spatialization","lesson":"Face voice proximity is an addressing rule, not a speech-permission rule. Enabled Face endpoints can now run concurrently via `StartAll`, so active rumination loops may emit speech regardless of listener proximity; proximity updates only output gain and stereo pan. AquariumAudioDocument now carries per-chunk left/right gains and WasapiAudioDevice mixes stereo when the output device supports it, degrading to mono by averaging channels.","files":["src/Aquarium.Engine.Contracts/Audio/AquariumAudio.cs","src/Aquarium.Engine/Audio/WasapiAudioDevice.cs","src/Aquarium.Epiphany/Voice/RealtimeFaceVoiceSession.cs","src/Aquarium.Epiphany/Voice/FaceVoiceEndpoint.cs","src/Aquarium.Epiphany/Voice/FaceVoiceRouter.cs","src/Aquarium.Epiphany/AquariumRuntime.cs","state/map.yaml"],"source":"user clarified Faces should speak from active rumination loops regardless of proximity, using spatial audio only to indicate distance"} +{"timestamp":"2026-05-18T08:32:00+01:00","topic":"client-floating-navigation-panels","lesson":"Client UI panels are no longer folded into the renderer debug tab strip. Aquarium now renders client-declared panels as positioned floating panels, with optional right anchoring via negative left offsets and proximity fade to 10% opacity. Zyphos uses this to expose a right-side Navigation panel for camera frame locks and the solar/orbital/planetary/surface domain hierarchy.","files":["src/Aquarium.Engine.Contracts/Ui/AquariumUi.cs","src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/DirectWriteOverlay.cs","src/Aquarium.Engine/Render/Ui/DebugUi.cs","src/Aquarium.Zyphos/ZyphosRuntime.cs"],"source":"user expected a right-side fading navigation panel with a foldout hierarchy of spatial domains"} diff --git a/state/map.yaml b/state/map.yaml index 8ffe8cc..66d4821 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -101,6 +101,7 @@ renderer_state: - Studio2 PMREM and irradiance DDS cubemaps are loaded as D3D12 TextureCubes; PMREM serves roughness-mip specular, irradiance serves Lambertian diffuse IBL for non-metal bodies. - DirectWrite/Direct2D unified debug panel with tabs for Aquarium renderer controls, client-declared debug panels, terminal commands, and engine/client tooling surfaces. - DirectWrite/Direct2D debug panels own body scrolling and clipping; overflowing client controls must stay inside the panel with a visible scrollbar. + - Client-declared UI panels render as independent floating panels, not as tabs inside the renderer Debug panel. Panels can right-anchor with negative left offsets and fade to 10% opacity when the mouse is not near. - Aquarium exposes an optional synth/audio hosting boundary through AquariumSynthDocument; Aquarium consumes AquaSynth.Faust as a pinned repo-local NuGet package so synth-agent construction cannot break Aquarium builds until the package is intentionally updated. AquaSynth.Core arrives transitively for patch editor/parser surfaces. - Aquarium now exposes a generic queued PCM audio lane through AquariumAudioDocument. Epiphany Face voice uses it to play streamed Codex realtime output without reaching into the engine's WASAPI internals. - Epiphany owns the first native Face realtime voice session controller. It stores loopback app-server URI, thread id, voice, and speech prompt in CultCache live state; starts `thread/realtime/start` with audio output over the experimental Codex app-server WebSocket JSON-RPC edge; sends text utterances; reflects ephemeral transcript/error/audio counters in the debug UI; and treats speech as transient Face surface, not durable memory or project authority.