- Refactor LayersSheet component to support mask editing state and improve layer visibility handling. - Introduce functions to collect mask layer IDs and count display layers excluding masks. - Update BrushControls to include mask view mode options and a Done button for exiting mask editing. - Modify brush session handling to support brush previews when editing masks. - Implement a new BrushPreviewRenderer for rendering brush strokes with visual feedback. - Add document geometry utilities for transforming points and resolving layer bounds. - Ensure proper cleanup of brush preview on pointer leave and other interactions.
62 lines
1.3 KiB
TypeScript
62 lines
1.3 KiB
TypeScript
import type { ImageDocument } from "@core/document";
|
|
import type { Angle, Size, Vec2D } from "@core/geometry";
|
|
import type { ArtboardId, AssetId, LayerId } from "@core/id";
|
|
import type { ToolState } from "./tools";
|
|
import type { TransformSession } from "./transform";
|
|
|
|
export type ViewportState = {
|
|
center: Vec2D;
|
|
zoom: number;
|
|
rotation: Angle;
|
|
size: Size;
|
|
};
|
|
|
|
export type SelectionState = {
|
|
artboardId?: ArtboardId;
|
|
layerIds: LayerId[];
|
|
};
|
|
|
|
export type MaskViewMode = "composite" | "blackWhite" | "alpha" | "overlay";
|
|
|
|
export type MaskEditState = {
|
|
targetLayerId: LayerId;
|
|
maskLayerId: LayerId;
|
|
viewMode?: MaskViewMode;
|
|
};
|
|
|
|
export type BrushPreviewState = {
|
|
position: Vec2D;
|
|
};
|
|
|
|
export type BrushStrokePreviewState = {
|
|
layerId: LayerId;
|
|
assetId: AssetId;
|
|
source: string;
|
|
};
|
|
|
|
export type EditorState = {
|
|
viewport: ViewportState;
|
|
selection: SelectionState;
|
|
tools: ToolState;
|
|
transformSession?: TransformSession;
|
|
maskEdit?: MaskEditState;
|
|
brushPreview?: BrushPreviewState;
|
|
brushStrokePreview?: BrushStrokePreviewState;
|
|
};
|
|
|
|
export type HistorySnapshot = {
|
|
document: ImageDocument;
|
|
editor: EditorState;
|
|
};
|
|
|
|
export type HistoryState = {
|
|
past: HistorySnapshot[];
|
|
future: HistorySnapshot[];
|
|
};
|
|
|
|
export type AppState = {
|
|
document: ImageDocument;
|
|
editor: EditorState;
|
|
history: HistoryState;
|
|
};
|