fix(tools): add modifier key support for advanced brush tools
TypeScript compilation fixes: - Added modifier keys (altKey, ctrlKey, shiftKey, metaKey) to PointerState interface - Updated all PointerState creations in canvas to include modifier keys - Added 'smudge' and 'dodge' cursor definitions to tool store Tool integration: - Added 'clone', 'smudge', 'dodge' to drawing tools array in canvas - Clone Stamp uses Alt+Click to set source point - Dodge/Burn uses Alt key to toggle between dodge (lighten) and burn (darken) modes - Smudge tool benefits from modifier key tracking for future enhancements All tools now properly receive keyboard modifier state for advanced interactions. Build verified successful with pnpm build. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -237,6 +237,10 @@ export function CanvasWithTools() {
|
|||||||
prevX: canvasPos.x,
|
prevX: canvasPos.x,
|
||||||
prevY: canvasPos.y,
|
prevY: canvasPos.y,
|
||||||
pressure: e.pressure || 1,
|
pressure: e.pressure || 1,
|
||||||
|
altKey: e.altKey,
|
||||||
|
ctrlKey: e.ctrlKey,
|
||||||
|
shiftKey: e.shiftKey,
|
||||||
|
metaKey: e.metaKey,
|
||||||
};
|
};
|
||||||
|
|
||||||
setPointer(newPointer);
|
setPointer(newPointer);
|
||||||
@@ -259,6 +263,10 @@ export function CanvasWithTools() {
|
|||||||
prevX: canvasPos.x,
|
prevX: canvasPos.x,
|
||||||
prevY: canvasPos.y,
|
prevY: canvasPos.y,
|
||||||
pressure: e.pressure || 1,
|
pressure: e.pressure || 1,
|
||||||
|
altKey: e.altKey,
|
||||||
|
ctrlKey: e.ctrlKey,
|
||||||
|
shiftKey: e.shiftKey,
|
||||||
|
metaKey: e.metaKey,
|
||||||
};
|
};
|
||||||
|
|
||||||
const textTool = toolsCache.current['text'];
|
const textTool = toolsCache.current['text'];
|
||||||
@@ -283,6 +291,10 @@ export function CanvasWithTools() {
|
|||||||
prevX: canvasPos.x,
|
prevX: canvasPos.x,
|
||||||
prevY: canvasPos.y,
|
prevY: canvasPos.y,
|
||||||
pressure: e.pressure || 1,
|
pressure: e.pressure || 1,
|
||||||
|
altKey: e.altKey,
|
||||||
|
ctrlKey: e.ctrlKey,
|
||||||
|
shiftKey: e.shiftKey,
|
||||||
|
metaKey: e.metaKey,
|
||||||
};
|
};
|
||||||
|
|
||||||
setPointer(newPointer);
|
setPointer(newPointer);
|
||||||
@@ -295,7 +307,7 @@ export function CanvasWithTools() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Drawing tools
|
// Drawing tools
|
||||||
if (e.button === 0 && !e.shiftKey && ['pencil', 'brush', 'eraser', 'fill', 'eyedropper', 'shape'].includes(activeTool)) {
|
if (e.button === 0 && !e.shiftKey && ['pencil', 'brush', 'eraser', 'fill', 'eyedropper', 'shape', 'clone', 'smudge', 'dodge'].includes(activeTool)) {
|
||||||
const activeLayer = getActiveLayer();
|
const activeLayer = getActiveLayer();
|
||||||
if (!activeLayer || !activeLayer.canvas || activeLayer.locked) return;
|
if (!activeLayer || !activeLayer.canvas || activeLayer.locked) return;
|
||||||
|
|
||||||
@@ -306,6 +318,10 @@ export function CanvasWithTools() {
|
|||||||
prevX: canvasPos.x,
|
prevX: canvasPos.x,
|
||||||
prevY: canvasPos.y,
|
prevY: canvasPos.y,
|
||||||
pressure: e.pressure || 1,
|
pressure: e.pressure || 1,
|
||||||
|
altKey: e.altKey,
|
||||||
|
ctrlKey: e.ctrlKey,
|
||||||
|
shiftKey: e.shiftKey,
|
||||||
|
metaKey: e.metaKey,
|
||||||
};
|
};
|
||||||
|
|
||||||
setPointer(newPointer);
|
setPointer(newPointer);
|
||||||
@@ -341,7 +357,7 @@ export function CanvasWithTools() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Drawing
|
// Drawing
|
||||||
if (pointer.isDown && ['pencil', 'brush', 'eraser', 'eyedropper', 'shape'].includes(activeTool)) {
|
if (pointer.isDown && ['pencil', 'brush', 'eraser', 'eyedropper', 'shape', 'clone', 'smudge', 'dodge'].includes(activeTool)) {
|
||||||
const activeLayer = getActiveLayer();
|
const activeLayer = getActiveLayer();
|
||||||
if (!activeLayer || !activeLayer.canvas) return;
|
if (!activeLayer || !activeLayer.canvas) return;
|
||||||
|
|
||||||
@@ -350,6 +366,10 @@ export function CanvasWithTools() {
|
|||||||
x: canvasPos.x,
|
x: canvasPos.x,
|
||||||
y: canvasPos.y,
|
y: canvasPos.y,
|
||||||
pressure: e.pressure || 1,
|
pressure: e.pressure || 1,
|
||||||
|
altKey: e.altKey,
|
||||||
|
ctrlKey: e.ctrlKey,
|
||||||
|
shiftKey: e.shiftKey,
|
||||||
|
metaKey: e.metaKey,
|
||||||
};
|
};
|
||||||
|
|
||||||
setPointer(newPointer);
|
setPointer(newPointer);
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ export const useToolStore = create<ToolStore>()(
|
|||||||
shape: 'crosshair',
|
shape: 'crosshair',
|
||||||
crop: 'crosshair',
|
crop: 'crosshair',
|
||||||
clone: 'crosshair',
|
clone: 'crosshair',
|
||||||
|
smudge: 'crosshair',
|
||||||
|
dodge: 'crosshair',
|
||||||
blur: 'crosshair',
|
blur: 'crosshair',
|
||||||
sharpen: 'crosshair',
|
sharpen: 'crosshair',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -55,6 +55,14 @@ export interface PointerState {
|
|||||||
prevY: number;
|
prevY: number;
|
||||||
/** Pressure (0-1, for stylus) */
|
/** Pressure (0-1, for stylus) */
|
||||||
pressure: number;
|
pressure: number;
|
||||||
|
/** Alt key modifier */
|
||||||
|
altKey?: boolean;
|
||||||
|
/** Ctrl key modifier */
|
||||||
|
ctrlKey?: boolean;
|
||||||
|
/** Shift key modifier */
|
||||||
|
shiftKey?: boolean;
|
||||||
|
/** Meta key modifier */
|
||||||
|
metaKey?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user