feat(layers): add layer management panel

This commit is contained in:
syntaxbullet
2026-07-03 17:26:50 +02:00
parent ba3f253ee5
commit fedeaffa57
27 changed files with 1525 additions and 156 deletions

View File

@@ -3,8 +3,10 @@ import type { Dispatch } from "@commands/dispatcher";
import type { ImageDocument } from "@core/document";
import type { Rect, Vec2D } from "@core/geometry";
import type { EditorState } from "@editor/state";
import { isPanInteractionMode } from "@editor/tools";
import { resolveTransformTargetBounds, selectedTransformTarget } from "@editor/transform-targets";
import type { TransformHandle } from "@editor/transform";
import { findLayerInfoInDocument } from "./layers-panel";
import type { PointerInputEvent } from "./pointer";
export type TransformControlsInputController = {
@@ -23,11 +25,11 @@ export function createTransformControlsInputController(options: {
if (event.pointerType !== "mouse" || (event.buttons & 1) !== 1) return false;
const editor = options.getEditor();
if (editor.tools.activeTool !== "select") return false;
if (editor.tools.activeTool !== "select" || isPanInteractionMode(editor.tools.interactionMode)) return false;
const document = options.getDocument();
const target = selectedTransformTarget(document, editor.selection);
if (!target) return false;
if (!target || isTransformTargetLocked(document, target)) return false;
const bounds = resolveTransformTargetBounds(document, target);
if (!bounds) return false;
@@ -45,7 +47,7 @@ export function createTransformControlsInputController(options: {
},
pointerMove(event) {
const editor = options.getEditor();
if (!editor.transformSession) return false;
if (!editor.transformSession || isPanInteractionMode(editor.tools.interactionMode)) return false;
options.dispatch(commandIds.transformUpdate, { point: viewportPointToDocumentPoint(event.position, editor.viewport), shiftKey: event.shiftKey });
return true;
@@ -68,6 +70,15 @@ export function hitTestArtboardTransformHandle(position: Vec2D, bounds: Rect, vi
return undefined;
}
function isTransformTargetLocked(document: ImageDocument, target: { type: "artboard" | "layer"; id: string }) {
if (target.type === "artboard") {
const artboard = document.artboards.find((candidate) => candidate.id === target.id);
return !artboard || !artboard.visible || artboard.locked;
}
const layer = findLayerInfoInDocument(document, target.id)?.layer;
return !layer || !layer.visible || layer.locked;
}
function transformHandleRects(rect: Rect): { handle: TransformHandle; rect: Rect }[] {
const size = 12;
const half = size / 2;