Zoom: dims never shade the box — move the dim overlay above CanvasGrid (Unit: zoom shading fix)

Creator's final zoom correction: as the box is dragged, its capture region slides
under the dim rectangles and the box picks up the 55% black "div shading" inside
itself, because the VisualBrush samples the whole CanvasGrid and DimRects lived
inside CanvasGrid. The captured area must stay clear regardless of box position.

- PreviewPane.xaml: the DimRects ItemsControl is now a SIBLING of CanvasGrid
  (above the composed content, below the ZoomBox), never a descendant — the zoom
  source is shading-free by construction.
- ZoomBoxInteractionTests: structural invariant — DimRectsLayer is a direct
  child of PreviewCanvas (not inside CanvasGrid) and renders below the ZoomBox.
- Side effect (correctness, not a bug): quality dims now also sedate the global
  overlays outside the crop, matching "chrome outside the crop is dimmed".
This commit is contained in:
2026-10-08 08:40:23 -07:00
parent 6bff21b234
commit 948dd08214
4 changed files with 70 additions and 55 deletions
+25 -35
View File
@@ -1,4 +1,4 @@
# HANDOFF — 2026-10-08 (zoom rework)
# HANDOFF — 2026-10-08 (zoom rework + dims-shading fix)
## Branch
- main (no feature branch)
@@ -9,51 +9,41 @@
- `Controls/LeftPanel.xaml` (pinned-message UI)
- Untracked: `Helpers/RelayCommandGeneric.cs`
## What just happened (2026-10-08, second zoom pass — creator correction)
The zoom box shipped in `4b3d82f` was a **loupe** (box follows its own content, built from the
backdrop only, slotted at z-index 1). The creator corrected it; the model is now:
## What just happened (2026-10-08, third zoom pass — dims shading)
The zoom box shipped as a **loupe** (`4b3d82f`), then was corrected to an **anchored-capture
magnifier over the full composite drawn last** (commit `6bff21b`). The final correction: as the box
is dragged, the dim rectangles (55% black "div shading" around the box) were sliding under the
capture region — shown inside the box because its `VisualBrush` samples all of `CanvasGrid`, and the
`DimRects` ItemsControl previously lived INSIDE `CanvasGrid`.
- **Anchored capture, not a loupe.** Right-clicking the live preview fixes a **capture window** —
the box/2 region centred on the click (`CaptureX/Y`, clamped to the master) — and parks a movable
**2x magnifier** box. The box is a **live, always-on 2x view of that captured region**; dragging the
box relocates it, **`UpdateZoomMove` never touches the capture** (creator ruling).
- **Content = every layer.** The zoom pass runs on the **already-composited frame** (backdrop + all
elements), so the magnified webcam/square/layers all show in the box. `SceneCompositor` skips the
active `ZoomSceneElement` in every layer loop and `BlitZoom`s it **LAST (layer n+1, on top of
everything)** via the pure static `ZoomMagnifier` (2x bilinear, 8.8 fixed-point, temp snapshot via
`ArrayPool` so a box overlapping its own source never recurses, optional round clip).
- **Rectangle = 4:3** ("more of a 640x480 aspect ratio"); Circle = square, Phone = 9:16 (kept).
Changes in this pass: new `Services/Compositor/ZoomMagnifier.cs`; `ZoomSceneElement`/`ZoomState`
gained `CaptureX`/`CaptureY`; `MainViewModel.Zoom.cs` rewritten (`BuildZoomFrame`/`ZoomFrameBuilder`
and the zoom-as-crop resolver case removed — no per-frame builder/cache anymore);
`PreviewPane.xaml`: `ZoomBox` hoisted OUT of `OverlayCanvas` to be a **sibling of `CanvasGrid`**
(renders above everything in the preview); `PreviewPane.xaml.cs` `UpdateZoomBox` samples `CanvasGrid`
(the whole composed preview) at the fixed capture, `Stretch=Fill`. `ZoomFrameBuilderTests.cs` deleted
(superseded); new `ZoomMagnifierTests.cs` (the "box over blue shows green capture, at 2x, all layers"
proof + round-clip); `ZoomBoxInteractionTests.cs` rewritten (per-shape 4:3/9:16/square + capture
anchor centred on the click + move-moves-only-the-box assertion + corner-clamp).
Fix: the `DimRects` overlay is now a **sibling of `CanvasGrid`** (renders above the composed
content, below the `ZoomBox`), never a descendant — so the zoom sample can never pick up the shading
and the captured area stays clear no matter where the box is dragged. Behavior consequence to note:
in non-zoom ("quality dims") mode the dims now also shade the global overlays (brand flash, alert
ticker, social bar) that sit above them in the old tree — consistent with "chrome outside the crop
is dimmed". Structural invariant added to `ZoomBoxInteractionTests`: `DimRectsLayer` is a direct
child of `PreviewCanvas`, not inside `CanvasGrid`, and renders below the `ZoomBox`.
## Zoom feature state
- Models: `ZoomState.cs`, `ZoomShape.cs` (Circle/VerticalRectangle/HorizontalRectangle), `ZoomSceneElement.cs`.
- ViewModel (`MainViewModel.Zoom.cs`): `ActivateZoom`/`ToggleZoom`/`DismissZoom`/`StartZoomMove`/`UpdateZoomMove`/`EndZoomMove` + `RebuildDimRectsForZoom`; transient element healed/mirrored by `HealZoomLayers`/`EnsureZoomLayer`.
- Output: box composited last via `BlitZoom`/`ZoomMagnifier`; output crop = tier (box never the crop).
- Preview: `ZoomBox` = sibling above `CanvasGrid`, samples the full composite at the fixed capture, 2x; circle→ellipse clip, rect/square outline per shape; `LeftPanel` hides the placeholder row via `IsZoomLayer`.
- Preview: `ZoomBox` + `DimRectsLayer` are both SIBLINGS of `CanvasGrid` (box above dims above content); box samples the full composite at the fixed capture, 2x; circle→ellipse clip, rect/square outline per shape; `LeftPanel` hides the placeholder row via `IsZoomLayer`.
- Rectangle shape = 4:3; Circle square; Phone 9:16. Capture anchored on click (`CaptureX/Y`); dragging the box never changes it.
## Tests
- Full suite: **404 passed / 2 failed** (both = known pre-existing environment flakes, unrelated to
zoom): `AudioPipelineTests.Mix_HonorsProviderGains_AndGameMute_KillsTheLoopback` (audio timing)
and `LayerReorderPersistenceTests.RealMouseDrag_OnTheLayerList_PersistsTheReorder` (needs
interactive desktop). Zoom tests 3/3 green, 0 build warnings.
- Full suite: **406 passed / 0 failed** on a clean full run (the pre-existing audio-loopback timing
flake and `RealMouseDrag`'s interactive-desktop requirement recur occasionally — not zoom
regressions). Zoom tests 3/3 green, 0 build warnings.
## Known issues / follow-ups
- **Background "Use default background" toggle still not working** (carried from 2026-10-07):
binding exists (`UseDefaultBackground`), VM handler invalidates bake; investigate when time permits.
- Preview shows editing chrome (dim rects, selection) inside the zoom box — accepted preview
artefact; the output only shows composed content.
- The 3px selection / crop-outline strokes could still show in the zoom box IF the capture overlaps
them in edit mode — not shading, thin outlines only; the dims (the user's complaint) are gone.
## Next step
- User runs the app live to eyeball the corrected zoom: right-click preview → anchored capture stays
fixed while the box is dragged; the box shows ALL layers at 2x on top of everything; rectangle box
is 4:3. Then TASK 51 (webcam background Remove + Blur) per `TASKS/task-51-webcam-bg-effects.md`,
and the background-toggle investigation if still open.
- User runs the app live to eyeball: drag the zoom box anywhere and the captured content stays clean
(no dim shading in the box; the scene outside the box stays dimmed). Then TASK 51 (webcam
background Remove + Blur) per `TASKS/task-51-webcam-bg-effects.md`, and the background-toggle
investigation if still open.