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
+13
View File
@@ -77,6 +77,19 @@ public sealed class ZoomBoxInteractionTests
Assert.Equal(Visibility.Visible, circleOutline.Visibility);
Assert.Equal(Visibility.Collapsed, rectOutline.Visibility);
// The dims are preview chrome ABOVE the composed content (a sibling of
// CanvasGrid, below the ZoomBox) — never inside CanvasGrid — so the zoom
// box's sample of CanvasGrid can never pick up the dim shading, even when
// the zoom box is dragged so the capture slides under the dims.
var previewCanvas = (Canvas)pane.FindName("PreviewCanvas")!;
var canvasGrid = (Grid)pane.FindName("CanvasGrid")!;
var dimsLayer = (ItemsControl)pane.FindName("DimRectsLayer")!;
Assert.Equal(previewCanvas, VisualTreeHelper.GetParent(dimsLayer));
for (var parent = VisualTreeHelper.GetParent(dimsLayer); parent != null; parent = VisualTreeHelper.GetParent(parent))
Assert.False(ReferenceEquals(parent, canvasGrid), "the dims layer must not be inside CanvasGrid");
Assert.True(previewCanvas.Children.IndexOf(dimsLayer) < previewCanvas.Children.IndexOf(zoomBox),
"the dims must render below the zoom box, not above it");
// Phone (vertical rectangle): tall 9:16 box; capture centred on the click.
vm.ZoomShape = ZoomShape.VerticalRectangle;
vm.ActivateZoom(960, 540);