graphic-pixi/lib/app/JlDrawApp.d.ts

151 lines
4.2 KiB
TypeScript
Raw Permalink Normal View History

2023-12-12 17:31:07 +08:00
import { BitmapFont, BitmapText, Container, FederatedMouseEvent, Point } from 'pixi.js';
import { GraphicData, GraphicTemplate, JlGraphic } from '../core/JlGraphic';
import { AppInteractionPlugin, InteractionPlugin, KeyListener } from '../plugins';
import { GraphicApp, GraphicAppOptions, ICanvasProperties, IGraphicApp, IJlCanvas } from './JlGraphicApp';
/**
*
*/
export declare abstract class GraphicDrawAssistant<GT extends GraphicTemplate, GD extends GraphicData> extends AppInteractionPlugin {
readonly __GraphicDrawAssistant = true;
app: IDrawApp;
type: string;
description: string;
icon: string;
container: Container;
graphicTemplate: GT;
escListener: KeyListener;
onEsc(): void;
constructor(graphicApp: IDrawApp, graphicTemplate: GT, icon: string, description: string);
get canvas(): IJlCanvas;
bind(): void;
unbind(): void;
onLeftDown(e: FederatedMouseEvent): void;
onMouseMove(e: FederatedMouseEvent): void;
onLeftUp(e: FederatedMouseEvent): void;
onRightDown(e: FederatedMouseEvent): void;
onRightUp(e: FederatedMouseEvent): void;
onRightClick(e: FederatedMouseEvent): void;
/**
* id
*/
2023-12-14 13:11:42 +08:00
nextId(): number;
2023-12-12 17:31:07 +08:00
clearCache(): void;
/**
*
* @param cp
*/
abstract redraw(cp: Point): void;
abstract prepareData(data: GD): boolean;
toCanvasCoordinates(p: Point): Point;
/**
*
*/
storeGraphic(...graphics: JlGraphic[]): void;
/**
* App
*/
createAndStore(finish: boolean): JlGraphic | null;
/**
*
*/
finish(...graphics: JlGraphic[]): void;
}
/**
*
*/
export type DrawAssistant = GraphicDrawAssistant<GraphicTemplate, GraphicData>;
/**
*
*/
export type DrawAppOptions = GraphicAppOptions;
/**
*
*/
export interface IDrawApp extends IGraphicApp {
/**
*
*/
get drawing(): boolean;
/**
*
*/
set drawing(value: boolean);
/**
*
* @param options
*/
setOptions(options: DrawAppOptions): void;
/**
*
*/
getDrawAssistant<DA extends DrawAssistant>(graphicType: string): DA;
/**
*
* @param data
*/
updateCanvasAndRecord(data: ICanvasProperties): void;
/**
*
* @param g
* @param data
*/
updateGraphicAndRecord(g: JlGraphic, data: GraphicData): void;
/**
* form表单对象
* @param form
*/
bindFormData(form: GraphicData): void;
/**
* form表单对象
* @param form
*/
unbindFormData(form: GraphicData): void;
}
/**
*
*/
export declare class JlDrawApp extends GraphicApp implements IDrawApp {
font: BitmapFont;
coordinates: BitmapText;
scaleText: BitmapText;
drawAssistants: DrawAssistant[];
_drawing: boolean;
private debouncedFormDataUpdator;
get drawing(): boolean;
set drawing(value: boolean);
constructor(options: DrawAppOptions);
setOptions(options: DrawAppOptions): void;
registerInteractionPlugin(...plugins: InteractionPlugin[]): void;
getDrawAssistant<DA extends DrawAssistant>(graphicType: string): DA;
private appOperationRecord;
/**
*
*/
private appendDrawStatesDisplay;
bindKeyboardOperation(): void;
/**
* ,
* @param graphic
*/
beforeGraphicStore(graphic: JlGraphic): void;
formData: GraphicData | undefined;
/**
* form表单对象
* @param form
*/
bindFormData(form: GraphicData): void;
/**
* form绑定
* @param form
*/
unbindFormData(form: GraphicData): void;
private formDataSyncListen;
/**
* 使debounce限流
*/
private handleFormDataUpdate;
private doFormDataUpdate;
updateCanvasAndRecord(data: ICanvasProperties): void;
updateGraphicAndRecord(g: JlGraphic, data: GraphicData): void;
}