Snap-to-grid for moving/resizing canvas objects, plus a per-sheet grid size

Sheet.gridSize (4-200px, default 24, configurable in Settings -> Blatt)
now doubles as both the visible dot-grid's spacing and the snap
increment while dragging to move any canvas object, or free/viewport-
resizing a chart/text/button/fixed-viewport table. An "Automatisch"
table's resize is left unsnapped on top of this -- it already
discretizes to row/col boundaries by construction.

Also fixes the visible grid not actually lining up with real snap
positions once zoomed: the dot pattern's background-size now scales
with zoom like the objects themselves already did, instead of staying a
fixed screen-pixel size regardless of zoom level.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
wkh
2026-09-09 23:33:39 +02:00
co-authored by Claude Sonnet 5
parent 5f75b9c298
commit d0500fcaf5
8 changed files with 101 additions and 14 deletions
+12
View File
@@ -10,6 +10,7 @@ import { useDocument } from '../store/document';
import { useTheme } from '../composables/useTheme';
import { NUMBER_LOCALES, NUM_FORMATS } from '../store/format';
import type { CellFormat, HAlign } from '../store/types';
import { DEFAULT_GRID_SIZE, MIN_GRID_SIZE, MAX_GRID_SIZE } from '../store/types';
const store = useDocument();
const { mode: themeMode } = useTheme();
@@ -461,6 +462,17 @@ function resetDoc() {
/>
<span>Raster einblenden</span>
</label>
<label class="f">
<span>Rasterweite ({{ sheet.gridSize ?? DEFAULT_GRID_SIZE }} px)</span>
<input
type="range"
:min="MIN_GRID_SIZE"
:max="MAX_GRID_SIZE"
:value="sheet.gridSize ?? DEFAULT_GRID_SIZE"
title="Steuert auch, worauf Objekte beim Verschieben/Skalieren einrasten"
@input="store.setSheetGridSize(sheet.id, num($event))"
/>
</label>
<div class="row-btns">
<button @click="store.addSheet()">Neues Blatt</button>