graphic-pixi/lib/plugins/InteractionPlugin.d.ts

174 lines
4.5 KiB
TypeScript
Raw Normal View History

2023-12-12 17:31:07 +08:00
/// <reference types="node" />
import { DisplayObject, FederatedMouseEvent, FederatedPointerEvent, Point } from 'pixi.js';
import { IGraphicScene } from '../app/JlGraphicApp';
import { JlGraphic } from '../core/JlGraphic';
export declare enum InteractionPluginType {
App = "app",
Graphic = "graphic",
Other = "other"
}
/**
*
*/
export interface InteractionPlugin {
readonly _type: string;
name: string;
app: IGraphicScene;
/**
*
*/
resume(): void;
/**
*
*/
pause(): void;
/**
*
*/
isActive(): boolean;
isAppPlugin(): boolean;
isOtherPlugin(): boolean;
isGraphicPlugin(): boolean;
}
export declare abstract class InteractionPluginBase implements InteractionPlugin {
readonly _type: string;
name: string;
app: IGraphicScene;
_pause: boolean;
constructor(app: IGraphicScene, name: string, type: string);
/**
*
*/
resume(): void;
/**
*
*/
pause(): void;
abstract bind(): void;
abstract unbind(): void;
/**
*
*/
isActive(): boolean;
isGraphicPlugin(): boolean;
isAppPlugin(): boolean;
isOtherPlugin(): boolean;
}
export declare abstract class OtherInteractionPlugin extends InteractionPluginBase {
constructor(app: IGraphicScene, name: string);
}
export declare class AppDragEvent {
app: IGraphicScene;
type: 'start' | 'move' | 'end';
target: DisplayObject;
original: FederatedPointerEvent;
start: Point;
constructor(app: IGraphicScene, type: 'start' | 'move' | 'end', target: DisplayObject, original: FederatedPointerEvent, start: Point);
get isMouse(): boolean;
get isLeftButton(): boolean;
get isRightButton(): boolean;
get isMiddleButton(): boolean;
get isTouch(): boolean;
/**
* ()
*/
get end(): Point;
get dx(): number;
get dy(): number;
get dsx(): number;
get dsy(): number;
/**
*
*/
toTargetShiftLen(target: DisplayObject): {
dx: number;
dy: number;
};
}
/**
*
*/
export declare class DragPlugin extends OtherInteractionPlugin {
static Name: string;
private threshold;
target: DisplayObject | null;
start: Point | null;
startClientPoint: Point | null;
drag: boolean;
constructor(app: IGraphicScene);
static new(app: IGraphicScene): DragPlugin;
bind(): void;
unbind(): void;
onPointerDown(e: FederatedPointerEvent): void;
onPointerMove(e: FederatedPointerEvent): void;
onPointerUp(e: FederatedPointerEvent): void;
/**
*
*/
clearCache(): void;
}
/**
*
*/
export declare class ViewportMovePlugin extends OtherInteractionPlugin {
static Name: string;
static MoveInterval: number;
static TriggerRange: number;
static DefaultMoveSpeed: number;
moveHandler: NodeJS.Timeout | null;
moveSpeedx: number;
moveSpeedy: number;
constructor(app: IGraphicScene);
static new(app: IGraphicScene): ViewportMovePlugin;
pause(): void;
bind(): void;
unbind(): void;
startMove(moveSpeedx: number, moveSpeedy: number): void;
stopMove(): void;
private calculateBoundaryMoveSpeed;
calculateMoveSpeed(dd: number): number;
viewportMove(e: FederatedMouseEvent): void;
}
/**
*
*/
export declare abstract class AppInteractionPlugin extends InteractionPluginBase {
constructor(name: string, app: IGraphicScene);
/**
* app交互插件同时只能生效一个
*/
resume(): void;
}
/**
* ,
*/
export declare abstract class GraphicInteractionPlugin<G extends JlGraphic> implements InteractionPlugin {
readonly _type = InteractionPluginType.Graphic;
app: IGraphicScene;
name: string;
_pause: boolean;
constructor(name: string, app: IGraphicScene);
isActive(): boolean;
isAppPlugin(): boolean;
isOtherPlugin(): boolean;
isGraphicPlugin(): boolean;
resume(): void;
pause(): void;
/**
*
*/
abstract filter(...grahpics: JlGraphic[]): G[] | undefined;
binds(list?: G[]): void;
unbinds(list?: G[]): void;
/**
*
* @param g
*/
abstract bind(g: G): void;
/**
*
* @param g
*/
abstract unbind(g: G): void;
}