mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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:
@@ -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,
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user