fix: wire crop, selection, and transform tool overlays into canvas

- CropOverlay: rendered in its own Layer when crop tool is active,
  cropState auto-initialized when switching to crop tool
- SelectionOverlay: marching ants rendered for active selections,
  selection tool mouse events dispatched through canvas handler
- TransformToolTransformer: rendered when transform tool is active
- Selection tool handlers wired for marquee-rect, marquee-ellipse,
  lasso-free, lasso-poly, and magic-wand tools
- Active selection preview rect shown while dragging
This commit is contained in:
SnapOtter
2026-05-07 23:58:50 +08:00
parent 3bcf06f1ec
commit 6e53a14072
2 changed files with 92 additions and 6 deletions
+15 -2
View File
@@ -202,12 +202,25 @@ export const useEditorStore = create<EditorState>()(
// ===== ACTIONS =====
setTool: (tool) => {
const { activeTool } = get();
const { activeTool, canvasSize, cropState } = get();
const leavingCrop = activeTool === "crop" && tool !== "crop";
const enteringCrop = tool === "crop" && activeTool !== "crop";
set({
activeTool: tool,
previousTool: activeTool,
isCropping: tool === "crop",
...(activeTool === "crop" && tool !== "crop" ? { cropState: null } : {}),
...(leavingCrop ? { cropState: null } : {}),
...(enteringCrop && !cropState
? {
cropState: {
x: canvasSize.width * 0.1,
y: canvasSize.height * 0.1,
width: canvasSize.width * 0.8,
height: canvasSize.height * 0.8,
aspectRatio: null,
},
}
: {}),
});
},