'use client'; import { useTransformStore } from '@/store/transform-store'; import { useLayerStore } from '@/store/layer-store'; import { useHistoryStore } from '@/store/history-store'; import { useToolStore } from '@/store/tool-store'; import { TransformCommand } from '@/core/commands/transform-command'; import { Move, RotateCw, Maximize2, Check, X, Lock, Unlock } from 'lucide-react'; import { cn } from '@/lib/utils'; export function TransformPanel() { const { activeTransform, transformType, maintainAspectRatio, setTransformType, setMaintainAspectRatio, applyTransform, cancelTransform, } = useTransformStore(); const { activeLayerId, layers } = useLayerStore(); const { executeCommand } = useHistoryStore(); const { setActiveTool } = useToolStore(); const activeLayer = layers.find((l) => l.id === activeLayerId); const hasActiveLayer = !!activeLayer && !activeLayer.locked; const handleApply = () => { if (!activeTransform || !activeLayer) return; const command = TransformCommand.applyToLayer( activeLayer, activeTransform.currentState, activeTransform.originalBounds ); executeCommand(command); applyTransform(); }; const handleCancel = () => { cancelTransform(); }; const handleMoveTool = () => { setActiveTool('move'); }; const handleTransformTool = () => { setActiveTool('move'); // Will be updated to 'transform' when tool types are updated }; return (
{/* Transform Tools */}

Tools

{/* Transform Options */} {activeTransform && (

Options

{/* Maintain Aspect Ratio */} {/* Transform State Display */}
Position: {Math.round(activeTransform.currentState.x)},{' '} {Math.round(activeTransform.currentState.y)}
Scale: {(activeTransform.currentState.scaleX * 100).toFixed(0)}% ×{' '} {(activeTransform.currentState.scaleY * 100).toFixed(0)}%
Rotation: {activeTransform.currentState.rotation.toFixed(1)}°
{/* Apply/Cancel Buttons */}
)} {/* Instructions */}

Instructions

{transformType === 'move' && ( <>

• Click and drag to move the layer

• Arrow keys for precise movement

• Hold Shift for 10px increments

)} {transformType === 'free-transform' && ( <>

• Drag corners to scale

• Drag edges to scale in one direction

• Drag rotate handle to rotate

• Drag inside to move

• Hold Shift to constrain proportions

)}
{!hasActiveLayer && (

Select an unlocked layer to transform

)}
); }