From acce5e2474108e08120f5db4ef933a9042ce3676 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 1 Jun 2026 13:32:50 +0100 Subject: [PATCH] Wire compositor preview handles --- docs/implementation-plan.md | 2 +- notes/current-system-map.md | 3 +- notes/fresh-workspace-handoff.md | 2 +- src/Mimir.BufferSmoke/Program.cs | 19 +++++- src/Mimir.Runtime/MimirRuntime.cs | 2 +- .../Synchronization/MimirSceneEditorState.cs | 66 +++++++++++++++++++ state/evidence.jsonl | 1 + state/map.yaml | 4 +- 8 files changed, 92 insertions(+), 7 deletions(-) diff --git a/docs/implementation-plan.md b/docs/implementation-plan.md index df90199..f5c936c 100644 --- a/docs/implementation-plan.md +++ b/docs/implementation-plan.md @@ -303,7 +303,7 @@ a named invariant that the native runtime cannot protect yet. so the app preview is a live program-surface witness rather than a symbolic rectangle diagram. Placement commits keep video layers inside the program frame, snap near edges/center, and preserve the source aspect ratio while - resizing through sliders or the scale gizmo. + resizing through direct preview handles, sliders, or the scale gizmo. See [[scene-editor-control-surface|Mimir Scene Editor Control Surface]]. `Mimir.BufferSmoke --scene-editor-smoke` proves the graph/control/gizmo owner path. World SDF text glyph rendering, ASSIMP-style mesh import/upload, and diff --git a/notes/current-system-map.md b/notes/current-system-map.md index 5a11c8d..da9ee11 100644 --- a/notes/current-system-map.md +++ b/notes/current-system-map.md @@ -548,7 +548,8 @@ Fensalir-owned blit of the current output buffer, then draws Mimir's normalized placement overlays on top. This editor is not the OBS program output authority; it is a live program-surface witness. The placement commit primitive keeps layers inside the program frame, snaps near edges/center, and preserves source -aspect while resizing through sliders or the scale gizmo. World SDF glyph rendering, ASSIMP-style +aspect while resizing through direct preview handles, sliders, or the scale +gizmo. World SDF glyph rendering, ASSIMP-style mesh decoding/upload, and pixel-accurate gizmo hit-testing are explicit Fensalir renderer cuts, mapped in [[docs/scene-editor-control-surface|Mimir Scene Editor Control Surface]]. diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index df3d081..c849263 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -51,7 +51,7 @@ Get-Content .\state\evidence.jsonl -Tail 8 properties. The center preview requests Fensalir's current output-buffer blit as its background and overlays Mimir's normalized layer placements on top. Placement commits snap near frame edges/center and preserve source aspect - while resizing. + while resizing through direct preview handles, sliders, or the scale gizmo. Camera/SDF/model editor affordances have no live UI authority, and editor camera/SDF/spline output no longer contributes to the runtime frame. Smoke with `--scene-editor-smoke`. diff --git a/src/Mimir.BufferSmoke/Program.cs b/src/Mimir.BufferSmoke/Program.cs index 1135a9c..9c37e9f 100644 --- a/src/Mimir.BufferSmoke/Program.cs +++ b/src/Mimir.BufferSmoke/Program.cs @@ -8,6 +8,7 @@ using Aquarium.Engine; using Aquarium.Engine.Audio; using Aquarium.Engine.Input; using Aquarium.Engine.Render; +using Aquarium.Engine.Ui; using GameCult.Caching; using GameCult.Caching.MessagePack; using MessagePack; @@ -4237,6 +4238,18 @@ static int RunSceneEditorSmoke() Math.Abs(snappedPlacement.Value.CenterX - snappedPlacement.Value.Width * 0.5f) < 0.001f && Math.Abs(snappedPlacement.Value.CenterY - (1.0f - snappedPlacement.Value.Height * 0.5f)) < 0.001f; editor.CenterSelectedProgramLayer(); + editor.HandlePreviewInteraction(new AquariumUiPreviewInteraction(displayNode.Id, "move", "begin", 0.5f, 0.5f, 0.0f, 0.0f)); + editor.HandlePreviewInteraction(new AquariumUiPreviewInteraction(displayNode.Id, "move", "drag", 0.6f, 0.6f, 0.1f, 0.05f)); + var draggedPlacement = editor.PlacementForSource("raven-display"); + var previewMoveHandled = draggedPlacement.HasValue && + Math.Abs(draggedPlacement.Value.CenterX - 0.6f) < 0.001f && + Math.Abs(draggedPlacement.Value.CenterY - 0.55f) < 0.001f; + editor.HandlePreviewInteraction(new AquariumUiPreviewInteraction(displayNode.Id, "se", "drag", 0.75f, 0.75f, 0.08f, 0.02f)); + var handlePlacement = editor.PlacementForSource("raven-display"); + var previewHandleAspectLocked = handlePlacement.HasValue && + Math.Abs(handlePlacement.Value.Width - handlePlacement.Value.Height) < 0.001f && + handlePlacement.Value.Width > draggedPlacement?.Width; + editor.CenterSelectedProgramLayer(); editor.MoveSelectedLayer(-1); var hierarchy = editor.DescribeHierarchy(); @@ -4250,7 +4263,7 @@ static int RunSceneEditorSmoke() Console.WriteLine( $"scene-editor-smoke nodes={editor.Nodes.Count} feeds={editor.Nodes.Count(node => node.Kind == MimirSceneEditorNodeKind.SensorFeedPanel)} " + $"preview={previewItems.Count} selected={editor.SelectedNode?.DisplayName} hasDisplay={hasDisplay} cameraPreview={hasCameraPreview} " + - $"placement={placement?.CenterX:0.000},{placement?.CenterY:0.000} programCentered={programCentered} aspectLocked={aspectLocked} snapped={snappedToBounds}"); + $"placement={placement?.CenterX:0.000},{placement?.CenterY:0.000} programCentered={programCentered} aspectLocked={aspectLocked} snapped={snappedToBounds} previewMove={previewMoveHandled} previewHandle={previewHandleAspectLocked}"); return editor.Nodes.Count == 3 && hasDisplay && @@ -4258,7 +4271,9 @@ static int RunSceneEditorSmoke() !hasCameraPreview && programCentered && aspectLocked && - snappedToBounds + snappedToBounds && + previewMoveHandled && + previewHandleAspectLocked ? 0 : 1; } diff --git a/src/Mimir.Runtime/MimirRuntime.cs b/src/Mimir.Runtime/MimirRuntime.cs index ca0593d..4d816d6 100644 --- a/src/Mimir.Runtime/MimirRuntime.cs +++ b/src/Mimir.Runtime/MimirRuntime.cs @@ -893,7 +893,7 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec shell.Vertical("mimir.editor-center", center => { - center.Preview("scene.view-preview", "", () => sceneEditor.PreviewItems, weight: 2.2f, blitOutputBuffer: true); + center.Preview("scene.view-preview", "", () => sceneEditor.PreviewItems, weight: 2.2f, blitOutputBuffer: true, handleInteraction: sceneEditor.HandlePreviewInteraction); center.Pane("mimir.audio-mixer", "Audio Mixer", mixer => { mixer.Horizontal("audio.channel-bank", bank => diff --git a/src/Mimir.Runtime/Synchronization/MimirSceneEditorState.cs b/src/Mimir.Runtime/Synchronization/MimirSceneEditorState.cs index daba913..b423166 100644 --- a/src/Mimir.Runtime/Synchronization/MimirSceneEditorState.cs +++ b/src/Mimir.Runtime/Synchronization/MimirSceneEditorState.cs @@ -402,6 +402,34 @@ public sealed class MimirSceneEditorState } } + public void HandlePreviewInteraction(AquariumUiPreviewInteraction interaction) + { + if (nodes.FirstOrDefault(node => string.Equals(node.Id, interaction.ItemId, StringComparison.Ordinal)) is not { Kind: MimirSceneEditorNodeKind.SensorFeedPanel } node || + node.Locked) + { + return; + } + + SelectedNodeId = node.Id; + if (interaction.Phase != "drag") + { + return; + } + + var placement = PlacementForNode(node); + if (interaction.Handle == "move") + { + SetNodeProgramPlacement(node, placement with + { + CenterX = placement.CenterX + interaction.DeltaX, + CenterY = placement.CenterY + interaction.DeltaY, + }); + return; + } + + SetNodeProgramPlacement(node, ResizeProgramPlacementFromHandle(node, placement, interaction.Handle, interaction.DeltaX, interaction.DeltaY)); + } + public bool IncludesVideoSource(string sourceId) => NodeForSource(sourceId) is not { } node || node.Visible; @@ -697,6 +725,44 @@ public sealed class MimirSceneEditorState return placement with { Width = width, Height = height }; } + private static MimirCompositorPlacement ResizeProgramPlacementFromHandle( + MimirSceneEditorNode node, + MimirCompositorPlacement placement, + string handle, + float deltaX, + float deltaY) + { + var west = handle.Contains('w', StringComparison.Ordinal); + var east = handle.Contains('e', StringComparison.Ordinal); + var north = handle.Contains('n', StringComparison.Ordinal); + var south = handle.Contains('s', StringComparison.Ordinal); + if ((!west && !east) || (!north && !south)) + { + return placement; + } + + var l = placement.CenterX - placement.Width * 0.5f; + var r = placement.CenterX + placement.Width * 0.5f; + var t = placement.CenterY - placement.Height * 0.5f; + var b = placement.CenterY + placement.Height * 0.5f; + var targetWidthFromX = placement.Width + (east ? deltaX : -deltaX); + var targetHeightFromY = placement.Height + (south ? deltaY : -deltaY); + var aspect = ProgramPlacementAspectFor(node); + var xChange = MathF.Abs(targetWidthFromX - placement.Width); + var yChange = MathF.Abs(targetHeightFromY - placement.Height); + var targetWidth = xChange >= yChange + ? targetWidthFromX + : targetHeightFromY * aspect; + var resized = ResizeProgramPlacement(node, placement, targetWidth, resizeWidth: true); + var centerX = west ? r - resized.Width * 0.5f : l + resized.Width * 0.5f; + var centerY = north ? b - resized.Height * 0.5f : t + resized.Height * 0.5f; + return resized with + { + CenterX = centerX, + CenterY = centerY, + }; + } + private MimirSceneEditorNode? NodeForSource(string sourceId) => nodes.FirstOrDefault(node => node.Kind == MimirSceneEditorNodeKind.SensorFeedPanel && diff --git a/state/evidence.jsonl b/state/evidence.jsonl index e899112..c56ab59 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -328,3 +328,4 @@ {"ts": "2026-06-01T12:25:06+01:00", "type": "correction", "status": "ok", "note": "Corrected the app recording feature ownership after user rejected the isolated Kiyo/Faust mic receipt as half-assed. MimirProgramRecorder now delegates to scripts/record-stream-proof-output.ps1, writes artifacts/runtime/stream-proof/mimir-program-record-latest.mp4, and records the same Raven + Kiyo PIP + Starfire Scarlett NVENC/AAC composite used for Yggdrasil/public stream judgment. MIMIR_RECORD_START_RAVEN=1 asks the app recorder to launch Raven's sender; otherwise it records from an already-running feed. The earlier record-kiyo-dual-mic-composite delegate is no longer the app recorder actuator."} {"ts": "2026-06-01T12:46:47+01:00", "type": "decision", "status": "ok", "note": "Mimir center preview now requests Fensalir's UI preview output-buffer blit and overlays MimirSceneEditorState placement items on top; Fensalir owns the backbuffer snapshot/draw, Mimir owns only preview intent and layer geometry."} {"ts": "2026-06-01T13:22:54+01:00", "type": "implementation", "status": "ok", "note": "Added MimirSceneEditorState program-placement affordances: one placement commit path clamps layers inside the program frame, snaps centers/edges near boundaries, and preserves the source aspect ratio for width/height slider edits plus scale-gizmo resizing. --scene-editor-smoke now asserts aspect locking and boundary snapping."} +{"ts": "2026-06-01T13:32:22+01:00", "type": "implementation", "status": "ok", "note": "Direct compositor handles are now wired: Fensalir CultUI preview hit-tests selected item corner handles/body drags and emits normalized AquariumUiPreviewInteraction gestures, while MimirSceneEditorState handles those gestures through the same snapping/aspect-preserving placement owner. Sliders remain fallback/precision controls."} diff --git a/state/map.yaml b/state/map.yaml index 7459f3d..5dbf818 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -61,7 +61,9 @@ invariants: the preview observes the program surface without becoming composition authority. Placement commits keep layers inside the frame, snap near edges/center, and preserve source aspect while resizing through sliders or - the scale gizmo. + the scale gizmo. The center preview now has direct Fensalir CultUI + body/corner-handle gestures wired to the same placement owner; sliders are + fallback/precision controls, not the primary compositor surface. - `MimirProgramRecorder` owns the first app-level recording control. The Video Sources rail exposes `Record` / `Stop`, status text, latest output path, and process-tree shutdown. Its current actuator delegates to