Add configurable grid + snap to the layout system
Two independent grids, each with a size and a snap toggle: - Garden grid (owner-set, in the garden settings form): drives the editor's visual grid and, when snapping is on, snaps objects on place/move and snaps their dimensions to whole grid steps on resize. - Bed grid (per plantable object, in the bed Inspector): when snapping is on, plants snap to the bed's grid on place/move, and the grid is drawn inside the focused bed. Plant radius stays free. Snapping defaults off on both, so existing gardens keep free placement. Grid spacing shares the [1cm, 100m] range and defaults to 1m (garden) / 30cm (bed); 0 is treated as unset and re-defaulted. Backend: migration 0005 adds grid_size_cm/snap_to_grid to gardens and garden_objects, threaded through domain/store/service/api with service + api round-trip tests. Frontend: new geometry snap helpers (unit-tested), schema/type plumbing, canvas + overlay snapping, and the two forms. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01JdQpdYYsTgtkJBxbcpAszi
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
-- Grid + snap settings for the layout system.
|
||||
--
|
||||
-- Two independent grids:
|
||||
-- * gardens.grid_size_cm / snap_to_grid — the garden-scale grid the visual grid
|
||||
-- is drawn from and (when snap is on) objects snap to when placed/moved/resized.
|
||||
-- Defaults to 100 cm (1 m), matching the editor's previous fixed grid.
|
||||
-- * garden_objects.grid_size_cm / snap_to_grid — a per-object grid used inside a
|
||||
-- plantable bed: when snap is on, plants snap to it. Defaults to 30 cm (~1 ft),
|
||||
-- a practical bed cell.
|
||||
--
|
||||
-- snap defaults to off on both, so existing gardens keep free placement until the
|
||||
-- owner (garden grid) or an editor (bed grid) opts in.
|
||||
ALTER TABLE gardens ADD COLUMN grid_size_cm REAL NOT NULL DEFAULT 100;
|
||||
ALTER TABLE gardens ADD COLUMN snap_to_grid INTEGER NOT NULL DEFAULT 0 CHECK (snap_to_grid IN (0, 1));
|
||||
|
||||
ALTER TABLE garden_objects ADD COLUMN grid_size_cm REAL NOT NULL DEFAULT 30;
|
||||
ALTER TABLE garden_objects ADD COLUMN snap_to_grid INTEGER NOT NULL DEFAULT 0 CHECK (snap_to_grid IN (0, 1));
|
||||
Reference in New Issue
Block a user