From c23efeb3972ddb9cb1a5e8abdf76993f02ea6aa4 Mon Sep 17 00:00:00 2001 From: syntaxbullet Date: Fri, 3 Jul 2026 10:10:50 +0200 Subject: [PATCH] feat(editor): add tool interaction state --- editor/index.ts | 2 ++ editor/initial-state.ts | 2 ++ editor/state.ts | 2 ++ editor/tools.ts | 15 +++++++++++++++ 4 files changed, 21 insertions(+) create mode 100644 editor/tools.ts diff --git a/editor/index.ts b/editor/index.ts index a516f04..403f654 100644 --- a/editor/index.ts +++ b/editor/index.ts @@ -1,4 +1,6 @@ export type { AppState, EditorState, SelectionState, ViewportState } from "./state"; +export type { InteractionMode, ToolId, ToolState } from "./tools"; +export { initialToolState } from "./tools"; export { createInitialAppState, initialEditorState } from "./initial-state"; export type { AppStore, StateListener } from "./store"; export { createAppStore } from "./store"; diff --git a/editor/initial-state.ts b/editor/initial-state.ts index d879e66..199cadc 100644 --- a/editor/initial-state.ts +++ b/editor/initial-state.ts @@ -1,4 +1,5 @@ import type { AppState, EditorState } from "./state"; +import { initialToolState } from "./tools"; export const initialEditorState: EditorState = { viewport: { @@ -10,6 +11,7 @@ export const initialEditorState: EditorState = { selection: { layerIds: [], }, + tools: initialToolState, }; export function createInitialAppState(name = "Untitled"): AppState { diff --git a/editor/state.ts b/editor/state.ts index f881bc8..0b9cfab 100644 --- a/editor/state.ts +++ b/editor/state.ts @@ -1,6 +1,7 @@ import type { ImageDocument } from "@core/document"; import type { Angle, Size, Vec2D } from "@core/geometry"; import type { ArtboardId, LayerId } from "@core/id"; +import type { ToolState } from "./tools"; export type ViewportState = { center: Vec2D; @@ -17,6 +18,7 @@ export type SelectionState = { export type EditorState = { viewport: ViewportState; selection: SelectionState; + tools: ToolState; }; export type AppState = { diff --git a/editor/tools.ts b/editor/tools.ts new file mode 100644 index 0000000..f2e38fd --- /dev/null +++ b/editor/tools.ts @@ -0,0 +1,15 @@ +export type ToolId = "select" | "pan"; + +export type InteractionMode = + | { type: "tool"; tool: ToolId } + | { type: "temporary-pan"; previousTool: ToolId }; + +export type ToolState = { + activeTool: ToolId; + interactionMode: InteractionMode; +}; + +export const initialToolState: ToolState = { + activeTool: "select", + interactionMode: { type: "tool", tool: "select" }, +};