Layer, frame and shape lists all reorder by drag and drop
Reordering shapes by dragging worked well in the vector tab. Pixel art layers and frames and tilemap layers still used up/down buttons. All three lists now share one widget built from the shape list. - SortableList in the UI toolkit, with the drag rules next to it in src/ui/sortable.ts. A row has an optional thumbnail, a name, a hint on the right and an eye toggle. Every drop is one undo step. - The shape list is a thin wrapper around it. shapeRows.ts is gone, its tests moved to the new rules. - Pixel art layers show the layer alone on the current frame, frames show the whole frame. Up/Down, Hide, Earlier and Later are gone. - Tilemap layers get the eye instead of the checkbox. The per-row up, down and delete buttons are replaced by Delete layer next to Add layer. - A row is selected on release instead of press. Selecting rebuilt the inspector or tilemap panel and cancelled a drag that started on a row not yet selected. Tests: - ./check.sh: 138 files, 2052 tests, exit 0 (before 137 / 2051). - GM_STEPS=39,40,47,48 (fresh seed): ALL PASSED, 154 checks. - 5 new e2e checks. Check total 1264 in the README is computed (1259 + 5), CI never measured 1259. - Counter-checks bite: dropMove ignoring reversed fails a unit test, a tilemap drop not applied fails the drag check, a layer thumbnail showing all layers fails the thumbnail check. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8adef83f23
commit
5b9b57fd19
14 files changed
+699
-326
No files matched your search
+32
-16
@@ -528,16 +528,34 @@ export function installDebugHook(app: Application, state: EditorState, editor: E
|
||||
side.reveal(side.palette);
|
||||
return side.palette.swatchGlobal(index);
|
||||
},
|
||||
/**
|
||||
* The centre of a layer's or frame's row, scrolled into view, with the centre of its picture;
|
||||
* `eye` is the layer's switch.
|
||||
*/
|
||||
layerRow: (layerId: string) => {
|
||||
const side = editor.pixelArtEditor.side;
|
||||
side.reveal(side.layers);
|
||||
return side.layers.rowGlobal(layerId);
|
||||
const row = side.layers.rowGlobal(layerId);
|
||||
return row
|
||||
? {
|
||||
x: row.x + row.w / 2,
|
||||
y: row.y + row.h / 2,
|
||||
thumb: side.layers.thumbGlobal(layerId),
|
||||
eye: side.layers.eyeGlobal(layerId),
|
||||
}
|
||||
: null;
|
||||
},
|
||||
frameRow: (frameId: string) => {
|
||||
const side = editor.pixelArtEditor.side;
|
||||
side.reveal(side.frames);
|
||||
return side.frames.rowGlobal(frameId);
|
||||
const row = side.frames.rowGlobal(frameId);
|
||||
return row
|
||||
? { x: row.x + row.w / 2, y: row.y + row.h / 2, thumb: side.frames.thumbGlobal(frameId) }
|
||||
: null;
|
||||
},
|
||||
/** The ids as the two lists show them, top first. */
|
||||
layerRows: () => editor.pixelArtEditor.side.layers.shownIds,
|
||||
frameRows: () => editor.pixelArtEditor.side.frames.shownIds,
|
||||
previewIndex: () => editor.pixelArtEditor.side.preview.shownIndex,
|
||||
/** Canvas, layers and frames as the model holds them. */
|
||||
asset: (assetId: string) => {
|
||||
@@ -767,21 +785,19 @@ export function installDebugHook(app: Application, state: EditorState, editor: E
|
||||
const button = currentTilemapWidgets()?.focus;
|
||||
return button ? { ...centreOf(button), label: button.text } : null;
|
||||
},
|
||||
/** One row of the layer list, top-down as drawn: the layer, its switch and its buttons. */
|
||||
/** One row of the layer list, top-down as drawn: the layer, where to press it, and its eye. */
|
||||
layerRowAt: (index: number) => {
|
||||
const row = currentTilemapWidgets()?.layers[index];
|
||||
return row
|
||||
? {
|
||||
id: row.id,
|
||||
// `y` is the row's own line, so a check can tell whether it is inside the panel.
|
||||
y: centreOf(row.name).y,
|
||||
name: centreOf(row.name),
|
||||
visible: centreOf(row.visible),
|
||||
up: centreOf(row.up),
|
||||
down: centreOf(row.down),
|
||||
remove: centreOf(row.remove),
|
||||
}
|
||||
: null;
|
||||
const list = currentTilemapWidgets()?.layers;
|
||||
const id = list?.shownIds[index];
|
||||
const row = id ? list.rowGlobal(id) : null;
|
||||
if (!list || !id || !row) return null;
|
||||
const name = { x: row.x + row.w / 2, y: row.y + row.h / 2 };
|
||||
// `y` is the row's own line, so a check can tell whether it is inside the panel.
|
||||
return { id, y: name.y, name, visible: list.eyeGlobal(id) };
|
||||
},
|
||||
removeLayerAt: () => {
|
||||
const button = currentTilemapWidgets()?.removeLayer;
|
||||
return button ? { ...centreOf(button), enabled: button.enabled } : null;
|
||||
},
|
||||
/** Where a cell sits on screen – for a click that paints it or a pixel that proves it. */
|
||||
cellAt: (objectId: string, x: number, y: number) => viewport.cellScreen(objectId, x, y),
|
||||
|
||||
Reference in new issue
Block a user