Add shift and control fields to ptr; use for selection add/remove
parent
15398be065
commit
32beb3a221
|
@ -251,15 +251,15 @@
|
|||
|
||||
if (e.button === 0) {
|
||||
if (currentTool instanceof BrushTool) {
|
||||
currentTool.pointerDown({file, brushSize, brushType, colorIndex: primaryColorIndex}, {x: mousePixelX, y: mousePixelY, id: e.button })
|
||||
currentTool.pointerDown({file, brushSize, brushType, colorIndex: primaryColorIndex}, {x: mousePixelX, y: mousePixelY, id: e.button, shift: e.shiftKey, control: e.ctrlKey })
|
||||
} else if (currentTool instanceof EraserTool) {
|
||||
currentTool.pointerDown({file, brushSize, brushType}, {x: mousePixelX, y: mousePixelY, id: e.button })
|
||||
currentTool.pointerDown({file, brushSize, brushType}, {x: mousePixelX, y: mousePixelY, id: e.button, shift: e.shiftKey, control: e.ctrlKey })
|
||||
} else if (currentTool instanceof FillTool) {
|
||||
currentTool.pointerDown({file, colorIndex: primaryColorIndex}, {x: mousePixelX, y: mousePixelY, id: e.button })
|
||||
currentTool.pointerDown({file, colorIndex: primaryColorIndex}, {x: mousePixelX, y: mousePixelY, id: e.button, shift: e.shiftKey, control: e.ctrlKey })
|
||||
} else if (currentTool instanceof PickerTool) {
|
||||
currentTool.pointerDown({file, setColorIndex: index=>primaryColorIndex=index}, {x: mousePixelX, y: mousePixelY, id: e.button })
|
||||
currentTool.pointerDown({file, setColorIndex: index=>primaryColorIndex=index}, {x: mousePixelX, y: mousePixelY, id: e.button, shift: e.shiftKey, control: e.ctrlKey })
|
||||
} else {
|
||||
currentTool.pointerDown({file}, {x: mousePixelX, y: mousePixelY, id: e.button })
|
||||
currentTool.pointerDown({file}, {x: mousePixelX, y: mousePixelY, id: e.button, shift: e.shiftKey, control: e.ctrlKey })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -342,7 +342,7 @@
|
|||
|
||||
if (e.button === 0) {
|
||||
if (currentTool.isActive()) {
|
||||
currentTool.pointerUp({file}, {x: mousePixelX, y: mousePixelY, id: 0 })
|
||||
currentTool.pointerUp({file}, {x: mousePixelX, y: mousePixelY, id: 0, shift: e.shiftKey, control: e.ctrlKey })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ interface Pointer {
|
|||
x: number
|
||||
y: number
|
||||
id: number
|
||||
shift?: boolean
|
||||
control?: boolean
|
||||
}
|
||||
|
||||
export type BrushType = "circle" | "square"
|
||||
|
@ -256,11 +258,19 @@ export class SelectionTool implements Tool {
|
|||
return
|
||||
}
|
||||
|
||||
let value = true
|
||||
if (!ptr.shift && !ptr.control) {
|
||||
ctx.file.selection.clear()
|
||||
}
|
||||
if (ptr.control) {
|
||||
value = false
|
||||
}
|
||||
|
||||
let {x: startX, y: startY, width, height} = this.getArea()
|
||||
|
||||
for (let x = startX; x <= startX+width-1; x++) {
|
||||
for (let y = startY; y <= startY+height-1; y++) {
|
||||
ctx.file.selection.setPixel(x, y, true)
|
||||
ctx.file.selection.setPixel(x, y, value)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue