Web source: container == content — element grid + selection box sized to the cropped frame's canvas extent

- FindContentBounds already trimmed the bitmap; the grid/box still rendered at the uncropped user
  size, so Fill stretched the tight widget into a bigger frame = dead-between-content-and-border.
- ContentCanvasSize maps the crop rect to canvas units (1920/pixW per axis, DPI-correct) and the
  preview event now carries (bitmap, canvasW, canvasH).
- OnWebView2PreviewBitmapChanged sets the element Width/Height to that size; the grid and the
  SelectionOverlay (both bound to the element's Width/Height) now equal the widget exactly.
- IsPreviewDragging (set in MainWindow drag/resize) suppresses auto-fit mid-gesture.
- Tests 10/10 (alpha bounds, canvas-size mapping incl. DPI, control size); 0 warnings.
This commit is contained in:
2026-08-28 12:08:04 -07:00
parent bccdb4892c
commit ab29ec801d
7 changed files with 103 additions and 51 deletions
+3
View File
@@ -572,6 +572,7 @@ public partial class MainWindow : Window
{
_isResizing = true;
_resizeAspect = sel.ClipShape == ClipShape.Round ? 1 : sel.Width / Math.Max(1, sel.Height);
_viewModel.IsPreviewDragging = true;
grid.CaptureMouse();
e.Handled = true;
return;
@@ -583,6 +584,7 @@ public partial class MainWindow : Window
_viewModel.SelectedElement = hit;
_isDraggingOverlay = true;
_grabOffset = new Point(p.X - hit.X, p.Y - hit.Y);
_viewModel.IsPreviewDragging = true;
grid.CaptureMouse();
e.Handled = true;
return;
@@ -643,6 +645,7 @@ public partial class MainWindow : Window
grid.ReleaseMouseCapture();
_isDraggingOverlay = false;
_isResizing = false;
_viewModel.IsPreviewDragging = false;
}
private bool HitHandle(Point mouseScreen, SceneElement element)