From 68b42ba56e4ce22ea8a499e4a0d12ad75f3bb299 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 31 May 2026 18:20:46 +0100 Subject: [PATCH] Add isolated CultUI smoke surface --- .../Render/DirectWriteOverlay.cs | 32 ++++- src/Aquarium.Sample.Minimal/MinimalRuntime.cs | 134 +++++++++++++++++- state/evidence.jsonl | 1 + 3 files changed, 163 insertions(+), 4 deletions(-) diff --git a/src/Aquarium.Engine/Render/DirectWriteOverlay.cs b/src/Aquarium.Engine/Render/DirectWriteOverlay.cs index 3d56de4..8c08ee5 100644 --- a/src/Aquarium.Engine/Render/DirectWriteOverlay.cs +++ b/src/Aquarium.Engine/Render/DirectWriteOverlay.cs @@ -286,12 +286,13 @@ internal sealed class DirectWriteOverlay : IDisposable private void DrawMetricElement(AquariumUiElement element, Rect bounds) { - var value = Math.Clamp(element.ReadMetric?.Invoke() ?? 0.0, 0.0, 1.0); + var value = element.ReadMetric?.Invoke() ?? 0.0; + var normalized = Math.Clamp(value, 0.0, 1.0); DrawSurfaceFrame(bounds, null, element.Style?.Tone ?? "neutral", drawTitle: false); renderTarget.DrawText($"{element.Text}: {value:0.000}", smallFormat, RectFromEdges(bounds.Left + 8.0f, bounds.Top + 2.0f, bounds.Right - 8.0f, bounds.Top + 18.0f), primaryTextBrush, DrawTextOptions.Clip); var track = RectFromEdges(bounds.Left + 8.0f, bounds.Bottom - 10.0f, bounds.Right - 8.0f, bounds.Bottom - 5.0f); renderTarget.FillRectangle(track, dimAccentBrush); - renderTarget.FillRectangle(RectFromEdges(track.Left, track.Top, track.Left + track.Width * (float)value, track.Bottom), ToneBrush(element.Style?.Tone ?? "neutral")); + renderTarget.FillRectangle(RectFromEdges(track.Left, track.Top, track.Left + track.Width * (float)normalized, track.Bottom), ToneBrush(element.Style?.Tone ?? "neutral")); } private void DrawToggleElement(AquariumUiElement element, Rect bounds) @@ -353,7 +354,8 @@ internal sealed class DirectWriteOverlay : IDisposable var weight = Math.Max(0.001f, element.Weight); return element.Kind switch { - "text" when element.Role is "mono" => 34.0f * weight, + "group" or "pane" or "card" => PreferredContainerExtent(element) * weight, + "text" when element.Role is "mono" => 18.0f * weight, "text" when element.Role is "strong" or "title" => 22.0f * weight, "text" => 18.0f * weight, "toggle" or "select" or "slider" => 24.0f * weight, @@ -363,6 +365,30 @@ internal sealed class DirectWriteOverlay : IDisposable }; } + private static float PreferredContainerExtent(AquariumUiElement element) + { + var layout = element.Layout ?? AquariumUiLayout.Vertical(); + var children = element.Children?.Where(static child => child.Visible).ToArray() ?? []; + if (children.Length == 0) + { + return element.Kind == "pane" ? 72.0f : 24.0f; + } + + var horizontal = string.Equals(layout.Direction, "horizontal", StringComparison.Ordinal); + var childExtents = children.Select(static child => PreferredExtent(child, horizontal: false) ?? 48.0f * Math.Max(0.001f, child.Weight)).ToArray(); + var contentExtent = horizontal + ? childExtents.Max() + : childExtents.Sum() + layout.Gap * Math.Max(0, childExtents.Length - 1); + contentExtent += layout.Padding * 2.0f; + + return element.Kind switch + { + "pane" => contentExtent + 38.0f, + "card" => contentExtent, + _ => contentExtent, + }; + } + public void Dispose() { smallFormat.Dispose(); diff --git a/src/Aquarium.Sample.Minimal/MinimalRuntime.cs b/src/Aquarium.Sample.Minimal/MinimalRuntime.cs index 703a581..76ea8af 100644 --- a/src/Aquarium.Sample.Minimal/MinimalRuntime.cs +++ b/src/Aquarium.Sample.Minimal/MinimalRuntime.cs @@ -10,6 +10,20 @@ namespace Aquarium.Sample.Minimal; public sealed class MinimalRuntime : IAquariumRuntime { private float timeSeconds; + private int selectedFeed; + private int selectedLut; + private bool feedEnabled = true; + private bool visible = true; + private bool locked; + private float opacity = 1.0f; + private float gain = 0.72f; + private float lutStrength = 1.0f; + private float x = -3.2f; + private float y = 2.1f; + private float z; + private float rotation; + private float scaleX = 2.4f; + private float scaleY = 0.8f; public AquariumRuntimeOptions Options { get; private set; } @@ -17,7 +31,7 @@ public sealed class MinimalRuntime : IAquariumRuntime public AquariumRenderPlan RenderPlan { get; } = CreateRenderPlan(); - public AquariumUiDocument Ui { get; } = AquariumUiDocument.Empty; + public AquariumUiDocument Ui { get; } public AquariumAudioDocument Audio { get; } = new(); @@ -30,6 +44,11 @@ public sealed class MinimalRuntime : IAquariumRuntime Vector2.Zero, AquariumSceneState.Empty); + public MinimalRuntime() + { + Ui = CreateUi(); + } + public AquariumFrame ComposeFrame(AquariumFrame frame, AquariumFrameInput input) { return frame; @@ -58,6 +77,119 @@ public sealed class MinimalRuntime : IAquariumRuntime Options = options; } + private AquariumUiDocument CreateUi() + { + var feeds = new[] + { + new AquariumUiOption(0, "PS3 Eye 0 high-speed"), + new AquariumUiOption(1, "Kiyo Pro RGB"), + new AquariumUiOption(2, "Synthetic checker field"), + }; + var luts = new[] + { + new AquariumUiOption(0, "Neutral"), + new AquariumUiOption(1, "Thermal"), + new AquariumUiOption(2, "Depth debug"), + }; + + return new AquariumUiDocument() + .Surface("aquarium.ui_smoke", "CultUI Smoke", 16.0f, 56.0f, 980.0f, 620.0f, surface => + { + surface.Horizontal("columns", columns => + { + columns.Vertical("left", left => + { + left.Pane("program", "Program", pane => + { + pane.Options("feed", "Feed", () => selectedFeed, value => selectedFeed = value, feeds); + pane.Toggle("feed-enabled", "Visible", () => feedEnabled, value => feedEnabled = value); + pane.Slider("opacity", "Opacity", () => opacity, value => opacity = value, 0.0f, 1.0f, "0.00"); + pane.Text("program-compose", () => $"1:{feeds[selectedFeed].Label}@{opacity:0.00} | LUT:{luts[selectedLut].Label}", "mono"); + pane.Options("stem", "Stem", () => 0, _ => { }, [new AquariumUiOption(0, "Focusrite Input 1")]); + pane.Slider("gain", "Gain", () => gain, value => gain = value, 0.0f, 1.5f, "0.00"); + pane.Options("lut", "LUT", () => selectedLut, value => selectedLut = value, luts); + pane.Slider("lut-strength", "LUT Strength", () => lutStrength, value => lutStrength = value, 0.0f, 1.0f, "0.00"); + }, weight: 1.2f); + + left.Pane("scene", "Scene", pane => + { + pane.Options("editor-view", "Editor View", () => 0, _ => { }, [new AquariumUiOption(0, "Scene")]); + pane.Card("tree", card => + { + card.Text("tree-0", "Scene", "strong"); + card.Text("tree-1", " - [eye] Editor Camera ", "mono"); + card.Text("tree-2", " - Sensor Feeds (4)", "mono"); + card.Text("tree-3", " - [eye] Kiyo Pro RGB context ", "mono"); + card.Text("tree-4", " - [eye] Synthetic checker field ", "mono"); + }); + pane.Row("scene-buttons", row => + { + row.Button("previous", "Previous", () => selectedFeed = Math.Max(0, selectedFeed - 1)); + row.Button("next", "Next", () => selectedFeed = Math.Min(feeds.Length - 1, selectedFeed + 1)); + }); + pane.Text("scene-status", () => $"SdfTextPanel pos={x:0.00},{y:0.00},{z:0.00} scale={scaleX:0.00},{scaleY:0.00}", "mono"); + }); + }, weight: 1.05f); + + columns.Vertical("middle", middle => + { + middle.Pane("sync", "Sync", pane => + { + pane.Text("streams", "4 video / 4 audio buffers", "strong"); + pane.Metric("sources", "sources", () => 5.0); + pane.Metric("ingested", "samples ingested", () => 533_939.0 + (timeSeconds * 120.0)); + pane.Text("buffer-detail", "Focusrite Input 1 [asio-ch0]: 3751 1ch 192000Hz; passive mode waiting for program audio column", "body"); + pane.Text("audio-sync", () => $"asio-ch0: {1484.0 + Math.Sin(timeSeconds) * 0.2:0.00} samples {779.2 + Math.Cos(timeSeconds) * 0.1:0.00} us", "mono"); + pane.Text("chirplet", "chirplet reference: asio-ch1 passive; calibration emission command-ready", "body"); + pane.Slider("perspective", "Perspective", () => 10.0f, _ => { }, 1.0f, 20.0f, "0.0x"); + pane.Slider("angle", "Angle", () => 25.0f, _ => { }, 0.0f, 90.0f, "0.0 deg"); + pane.Text("tube-budget", "40/40 age columns x 4/8 lanes x 4 subdivisions", "mono"); + }, weight: 1.15f); + + middle.Pane("transform", "Transform", pane => + { + pane.Toggle("visible", "Visible", () => visible, value => visible = value); + pane.Toggle("locked", "Locked", () => locked, value => locked = value); + pane.Text("mode", "Mode: Grab", "mono"); + pane.Slider("x", "X", () => x, value => x = value, -10.0f, 10.0f, "0.00"); + pane.Slider("y", "Y", () => y, value => y = value, -10.0f, 10.0f, "0.00"); + pane.Slider("z", "Z", () => z, value => z = value, -10.0f, 10.0f, "0.00"); + pane.Slider("rotation", "Rotation", () => rotation, value => rotation = value, -180.0f, 180.0f, "0.00"); + pane.Slider("scale-x", "Scale X", () => scaleX, value => scaleX = value, 0.1f, 4.0f, "0.00"); + pane.Slider("scale-y", "Scale Y", () => scaleY, value => scaleY = value, 0.1f, 4.0f, "0.00"); + pane.Row("transform-buttons", row => + { + row.Button("reset-transform", "Reset Transform", ResetTransform); + row.Button("reset-camera", "Reset Camera", ResetTransform); + }); + }); + }, weight: 1.1f); + + columns.Pane("create", "Create", pane => + { + pane.Text("text-label", "Text", "body"); + pane.Text("text-value", "Mimir", "strong"); + pane.Button("add-sdf-text", "Add SDF Text", () => { }); + pane.Text("model-path-label", "Model Path", "body"); + pane.Text("model-path", "assets/models/example.glb", "mono"); + pane.Button("import-model", "Import Model", () => { }); + pane.Metric("fps", "ui smoke fps proxy", () => 1.0 / Math.Max(0.001, Math.Min(0.25, timeSeconds % 1.0))); + pane.Text("budget", "This pane is intentionally narrow enough to prove labels clip inside their cells instead of wandering across neighbors.", "body"); + }, weight: 0.75f); + }); + }); + } + + private void ResetTransform() + { + x = -3.2f; + y = 2.1f; + z = 0.0f; + rotation = 0.0f; + scaleX = 2.4f; + scaleY = 0.8f; + } + private static AquariumRenderPlan CreateRenderPlan() { var app = new AquariumApp(); diff --git a/state/evidence.jsonl b/state/evidence.jsonl index df654a6..1bb49db 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -322,3 +322,4 @@ {"timestamp":"2026-05-31T08:48:00+01:00","type":"verification","status":"ok","note":"Aquarium.EveSurface no longer assumes every Eve dashboard document is VoidBot-shaped. Generic providers now render their node list and selected detail through Surface Nodes / State Graph panels. Verified by connecting to Mimir.EveDashboard provider mimir.stream.layout and capturing the decoded surface at E:/Projects/Mimir/artifacts/runtime/mimir-eve-surface-layout-generic-decoder.png.","files":["src/Aquarium.EveSurface/EveSurfaceRuntime.cs"],"source":"dotnet build src/Aquarium.EveSurface/Aquarium.EveSurface.csproj; live Mimir.EveDashboard ws://127.0.0.1:8795/eve/deck provider mimir.stream.layout"} {"ts":"2026-05-31T18:06:36+01:00","type":"implementation","status":"ok","note":"AquariumUiDocument now carries Eve/CultUI-style composition surfaces in addition to legacy debug panels. Surface authoring defaults to vertical groups and uses explicit Horizontal scopes for columns; DirectWrite lowering subdivides each parent rectangle by axis and child weight instead of measuring children into sibling space, making overlap structurally impossible for lowered siblings.","files":["src/Aquarium.Engine.Contracts/Ui/AquariumUi.cs","src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/DirectWriteOverlay.cs"],"source":"dotnet build src/Aquarium.Engine/Aquarium.Engine.csproj --no-restore; dotnet build E:/Projects/Mimir/src/Mimir.App/Mimir.App.csproj --no-restore"} {"ts":"2026-05-31T18:18:00+01:00","type":"implementation","status":"ok","note":"Eve/CultUI Direct2D lowering now distinguishes fixed preferred control rows from flexible panes/groups. Vertical scopes allocate compact preferred extents to leaf controls such as text, toggles, selects, sliders, metrics, and buttons, then give remaining space to flexible children by weight. This preserves the no-overlap subdivision invariant while avoiding equal-height slabs for ordinary controls.","files":["src/Aquarium.Engine/Render/DirectWriteOverlay.cs"],"source":"dotnet build src/Aquarium.Engine/Aquarium.Engine.csproj --no-restore; dotnet build E:/Projects/Mimir/src/Mimir.App/Mimir.App.csproj --no-restore; relaunched Mimir.App with mimir-runtime.desktop-editor.no-leap.mic-reference-sync.local.json"} +{"ts":"2026-05-31T18:24:00+01:00","type":"verification","status":"ok","note":"Aquarium.Sample.Minimal now carries a reusable CultUI smoke surface so Eve/CultUI layout can be verified without Mimir camera, USB, FFT, or sync workload. The smoke surface exercises nested vertical/horizontal scopes, panes, cards, rows, selects, toggles, sliders, buttons, metrics, live text, and clipped long readouts. DirectWrite lowering now derives preferred container height from nested child layout and displays metric raw values while clamping only the fill bar; the headless capture showed readable nested grids with no sibling overlap.","files":["src/Aquarium.Sample.Minimal/MinimalRuntime.cs","src/Aquarium.Engine/Render/DirectWriteOverlay.cs"],"source":"dotnet build src/Aquarium.Engine/Aquarium.Engine.csproj --no-restore; dotnet build src/Aquarium.Sample.Minimal/Aquarium.Sample.Minimal.csproj --no-restore; scripts/dev-reload.ps1 -ClientProject src/Aquarium.Sample.Minimal/Aquarium.Sample.Minimal.csproj; capture artifacts/fensalir-captures/cultui-smoke-minimal-fixed.png"}