From 5185d5e1937ae02537c8dcc2de2f33351f715e42 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 31 May 2026 22:05:43 +0100 Subject: [PATCH] Add Eve compositor preview primitive --- .../Ui/AquariumUi.cs | 17 ++++++ .../Render/DirectWriteOverlay.cs | 52 +++++++++++++++++++ state/evidence.jsonl | 1 + 3 files changed, 70 insertions(+) diff --git a/src/Aquarium.Engine.Contracts/Ui/AquariumUi.cs b/src/Aquarium.Engine.Contracts/Ui/AquariumUi.cs index 3f644e6..6bb7419 100644 --- a/src/Aquarium.Engine.Contracts/Ui/AquariumUi.cs +++ b/src/Aquarium.Engine.Contracts/Ui/AquariumUi.cs @@ -81,6 +81,16 @@ public sealed record AquariumUiLayout( public sealed record AquariumUiStyle(string Variant = "default", string Tone = "neutral"); +public sealed record AquariumUiPreviewItem( + string Id, + string Label, + float X, + float Y, + float Width, + float Height, + bool Selected = false, + string Tone = "neutral"); + public sealed record AquariumUiElement( string Id, string Kind, @@ -100,6 +110,7 @@ public sealed record AquariumUiElement( Func? ReadOption = null, Action? WriteOption = null, IReadOnlyList? Options = null, + Func>? ReadPreviewItems = null, Action? Invoke = null, Func? IsVisible = null, float Weight = 1.0f, @@ -188,6 +199,12 @@ public sealed class AquariumUiSurfaceBuilder(List children) children.Add(new AquariumUiElement(id, "button", label, Invoke: invoke, Weight: Math.Max(0.001f, weight))); return this; } + + public AquariumUiSurfaceBuilder Preview(string id, string label, Func> readItems, float weight = 1.0f) + { + children.Add(new AquariumUiElement(id, "preview", label, ReadPreviewItems: readItems, Weight: Math.Max(0.001f, weight))); + return this; + } } public sealed class AquariumUiPanelBuilder(List controls) diff --git a/src/Aquarium.Engine/Render/DirectWriteOverlay.cs b/src/Aquarium.Engine/Render/DirectWriteOverlay.cs index 8c08ee5..02fe6c5 100644 --- a/src/Aquarium.Engine/Render/DirectWriteOverlay.cs +++ b/src/Aquarium.Engine/Render/DirectWriteOverlay.cs @@ -260,6 +260,9 @@ internal sealed class DirectWriteOverlay : IDisposable case "button": DrawButtonElement(element, bounds); break; + case "preview": + DrawPreviewElement(element, bounds); + break; default: DrawTextElement(element, bounds); break; @@ -335,6 +338,54 @@ internal sealed class DirectWriteOverlay : IDisposable renderTarget.DrawText(element.Text ?? "", smallFormat, RectFromEdges(bounds.Left + 8.0f, bounds.Top, bounds.Right - 8.0f, bounds.Bottom), primaryTextBrush, DrawTextOptions.Clip); } + private void DrawPreviewElement(AquariumUiElement element, Rect bounds) + { + DrawSurfaceFrame(bounds, null, "neutral", drawTitle: false); + renderTarget.DrawText(element.Text ?? "", smallFormat, RectFromEdges(bounds.Left + 8.0f, bounds.Top + 6.0f, bounds.Right - 8.0f, bounds.Top + 24.0f), quietTextBrush, DrawTextOptions.Clip); + + var padded = RectFromEdges(bounds.Left + 10.0f, bounds.Top + 30.0f, bounds.Right - 10.0f, bounds.Bottom - 10.0f); + if (padded.Width <= 1.0f || padded.Height <= 1.0f) + { + return; + } + + var targetAspect = 16.0f / 9.0f; + var canvasWidth = padded.Width; + var canvasHeight = canvasWidth / targetAspect; + if (canvasHeight > padded.Height) + { + canvasHeight = padded.Height; + canvasWidth = canvasHeight * targetAspect; + } + + var canvas = RectFromEdges( + padded.Left + (padded.Width - canvasWidth) * 0.5f, + padded.Top + (padded.Height - canvasHeight) * 0.5f, + padded.Left + (padded.Width + canvasWidth) * 0.5f, + padded.Top + (padded.Height + canvasHeight) * 0.5f); + renderTarget.FillRectangle(canvas, panelBrush); + renderTarget.DrawRectangle(canvas, outlineBrush, 1.0f); + + var items = element.ReadPreviewItems?.Invoke() ?? []; + foreach (var item in items) + { + var left = canvas.Left + Math.Clamp(item.X, 0.0f, 1.0f) * canvas.Width; + var top = canvas.Top + Math.Clamp(item.Y, 0.0f, 1.0f) * canvas.Height; + var right = canvas.Left + Math.Clamp(item.X + item.Width, 0.0f, 1.0f) * canvas.Width; + var bottom = canvas.Top + Math.Clamp(item.Y + item.Height, 0.0f, 1.0f) * canvas.Height; + var itemBounds = RectFromEdges(left, top, right, bottom); + if (itemBounds.Width <= 1.0f || itemBounds.Height <= 1.0f) + { + continue; + } + + var brush = item.Selected ? accentBrush : ToneBrush(item.Tone); + renderTarget.FillRectangle(itemBounds, item.Selected ? hoverRowBrush : rowBrush); + renderTarget.DrawRectangle(itemBounds, brush, item.Selected ? 2.0f : 1.0f); + renderTarget.DrawText(item.Label, smallFormat, RectFromEdges(itemBounds.Left + 6.0f, itemBounds.Top + 3.0f, itemBounds.Right - 6.0f, itemBounds.Bottom), primaryTextBrush, DrawTextOptions.Clip); + } + } + private ID2D1SolidColorBrush ToneBrush(string tone) => tone switch { @@ -355,6 +406,7 @@ internal sealed class DirectWriteOverlay : IDisposable return element.Kind switch { "group" or "pane" or "card" => PreferredContainerExtent(element) * weight, + "preview" => 240.0f * 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, diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 1bb49db..146fb05 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -323,3 +323,4 @@ {"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"} +{"ts":"2026-05-31T22:05:00+01:00","type":"implementation","status":"ok","note":"Eve/CultUI surfaces now include a DirectWrite preview primitive for editor/compositor surfaces. The primitive renders a bounded 16:9 program canvas and normalized item rectangles supplied by the client, allowing Mimir to show OBS-style program arrangement without inventing a Mimir-only overlay path.","files":["src/Aquarium.Engine.Contracts/Ui/AquariumUi.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"}