UNPKG

@gorpacrate/core-graphics

Version:

A core library for creating shape-based graphic editors

117 lines (116 loc) 3.64 kB
import { IBoundingBox, IPoint, IShapeDeclaration, IShapeResizeHandle } from '../declarations'; import { IRubberBandState } from './rubber-band'; export declare type ISceneMode = IModeSelect | IModeSelected | IModeMovingViewport | IModeSubSelected | IModeMoving | IModeDrawingShape | IModeResizing | IModeRubberbandSelection; export declare enum ModeType { Select = 0, Selected = 1, MovingViewport = 2, SubSelected = 3, Moving = 4, DrawingShape = 5, Resizing = 6, RubberbandSelection = 7 } export interface IModeSelect { type: ModeType.Select; displayName: string; } export interface IModeSelected { type: ModeType.Selected; displayName: string; payload: { ids: string[]; }; } export interface IModeMovingViewport { type: ModeType.MovingViewport; displayName: string; payload: { moving: boolean; dx: number; dy: number; }; } export interface IModeSubSelected { type: ModeType.SubSelected; displayName: string; payload: { id: string; }; } export interface IModeMoving { type: ModeType.Moving; displayName: string; payload: { ids: string[]; startX: number; startY: number; endX: number; endY: number; }; } export interface IModeDrawingShape { type: ModeType.DrawingShape; displayName: string; payload: { shapeType: string; drawingGenerator?: Iterator<IPoint[]>; drawnKeyPoints: IPoint[]; drawing: boolean; }; } export interface IModeResizing { type: ModeType.Resizing; displayName: string; payload: { ids: string[]; handle: IShapeResizeHandle; bb: IBoundingBox; pStart: IPoint; pEnd: IPoint; forceProportional: boolean; }; } export interface IModeRubberbandSelection { type: ModeType.RubberbandSelection; displayName: string; payload: IRubberBandState; } export declare function isSelectMode(base: ISceneMode): base is IModeSelect; export declare function isRubberBandSelectionMode(base: ISceneMode): base is IModeRubberbandSelection; export declare function isMovingViewportMode(base: ISceneMode): base is IModeMovingViewport; export declare function isSelectedMode(base: ISceneMode): base is IModeSelected; export declare function isSubSelectedMode(base: ISceneMode): base is IModeSubSelected; export declare function isMovingMode(base: ISceneMode): base is IModeMoving; export declare function isDrawingShapeMode(base: ISceneMode): base is IModeDrawingShape; export declare function isResizingMode(base: ISceneMode): base is IModeResizing; export declare function modeSelect(): IModeSelect; export declare function modeSelected(ids: string[]): IModeSelected; export declare function modeMovingViewport(payload?: { moving: boolean; dx: number; dy: number; }): IModeMovingViewport; export declare function modeRubberbandSelection(payload: { pStart: IPoint; pEnd: IPoint; newlySelectedShapes: string[]; previouslySelectedShapes: string[]; }): IModeRubberbandSelection; export declare function modeSubSelected(id: string): IModeSubSelected; export declare function modeMoving(payload: { ids: string[]; startX: number; startY: number; endX: number; endY: number; }): IModeMoving; export declare function modeResizing(payload: { ids: string[]; handle: IShapeResizeHandle; bb: IBoundingBox; pStart: IPoint; pEnd: IPoint; forceProportional: boolean; }): IModeResizing; export declare function modeDrawShape(shapeDeclaration: IShapeDeclaration): IModeDrawingShape;