diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte index d2c9955..38e28c0 100644 --- a/frontend/src/App.svelte +++ b/frontend/src/App.svelte @@ -6,7 +6,7 @@ import FloatingPanel from './components/FloatingPanel.svelte' import { Palette, PaletteEntry, defaultPalette } from './types/palette' - import { LoadedFile, SelectionClearUndoable } from './types/file' + import { LoadedFile, PixelsPlaceUndoable, SelectionClearUndoable, SelectionSetUndoable } from './types/file' import "carbon-components-svelte/css/all.css" import { Tabs, Tab, TabContent, Theme, Button, Modal, Truncate, ButtonSet, NumberInput } from "carbon-components-svelte" @@ -22,6 +22,7 @@ import Shortcut from './components/Shortcut.svelte' import Shortcuts from './components/Shortcuts.svelte' import { CopyPaste } from './types/copypaste' + import type { PixelPosition } from './types/shapes.js'; let theme: 'white'|'g10'|'g80'|'g90'|'g100' = 'g90' @@ -92,6 +93,24 @@ if (!focusedFile) return CopyPaste.toLocal(focusedFile.canvas, focusedFile.selection) } + function engageDelete(cut: boolean) { + if (!focusedFile) return + focusedFile.capture() + if (cut) { + CopyPaste.toLocal(focusedFile.canvas, focusedFile.selection) + } + let pixels: PixelPosition[] = [] + for (let y = 0; y < focusedFile.canvas.height; y++) { + for (let x = 0; x < focusedFile.canvas.width; x++) { + if (focusedFile.selection.isPixelMarked(x, y)) { + pixels.push({x, y, index: 0}) + } + } + } + focusedFile.push(new SelectionClearUndoable()) + focusedFile.push(new PixelsPlaceUndoable(pixels)) + focusedFile.release() + } function engagePaste() { if (!focusedFile) return let cp = CopyPaste.fromLocal() @@ -173,6 +192,8 @@ swapTool(toolPicker)} /> swapTool(toolErase)} /> engageCopy()} /> + engageDelete(true)} /> + engageDelete(false)} /> engagePaste()} />