import { EventReactions, EventGuards, Guard, TemplateState, TemplateStateMachine } from "../../being/interfaces"; import { Point } from "../../utils/misc"; import { CanvasOperator, KmtInputContext } from "./kmt-input-context"; /** * @description The possible states of the keyboard mouse and trackpad input state machine. * * @category Input State Machine */ export type KmtInputStates = "IDLE" | "READY_TO_PAN_VIA_SPACEBAR" | "READY_TO_PAN_VIA_SCROLL_WHEEL" | "PAN" | "INITIAL_PAN" | "PAN_VIA_SCROLL_WHEEL"; /** * @description The payload for the pointer event. * * @category Input State Machine */ export type PointerEventPayload = { x: number; y: number; }; type EmptyPayload = {}; /** * @description The payload for the scroll event. * * @category Input State Machine */ export type ScrollEventPayload = { deltaX: number; deltaY: number; }; /** * @description The payload for the scroll with ctrl event. * * @category Input State Machine */ export type ScrollWithCtrlEventPayload = { deltaX: number; deltaY: number; x: number; y: number; }; /** * @description The payload mapping for the events of the keyboard mouse and trackpad input state machine. * * @category Input State Machine */ export type KmtInputEventMapping = { leftPointerDown: PointerEventPayload; leftPointerUp: PointerEventPayload; leftPointerMove: PointerEventPayload; spacebarDown: EmptyPayload; spacebarUp: EmptyPayload; stayIdle: EmptyPayload; cursorOnElement: EmptyPayload; scroll: ScrollEventPayload; scrollWithCtrl: ScrollWithCtrlEventPayload; middlePointerDown: PointerEventPayload; middlePointerUp: PointerEventPayload; middlePointerMove: PointerEventPayload; }; /** * @description Converts the point from window coordinates(browser) to view port coordinates. * * @category Input State Machine */ export declare function convertFromWindow2ViewPort(point: Point, canvas: HTMLCanvasElement): Point; export declare function convertFromWindow2ViewPortWithCanvasOperator(point: Point, canvasOperator: CanvasOperator): Point; export declare function convertFromWindow2ViewPortCanvasOperator(point: Point, canvasOperator: CanvasOperator): Point; /** * @description The possible target states of the idle state. * * @category Input State Machine */ export type KmtIdleStatePossibleTargetStates = "IDLE" | "READY_TO_PAN_VIA_SPACEBAR" | "READY_TO_PAN_VIA_SCROLL_WHEEL"; /** * @description The idle state of the keyboard mouse and trackpad input state machine. * * @category Input State Machine */ export declare class KmtIdleState extends TemplateState { constructor(); protected _guards: Guard; protected _eventGuards: Partial>>; get eventReactions(): EventReactions; protected _eventReactions: EventReactions; scrollHandler(context: KmtInputContext, payload: ScrollEventPayload): void; scrollWithCtrlHandler(context: KmtInputContext, payload: ScrollWithCtrlEventPayload): void; spacebarDownHandler(context: KmtInputContext, payload: EmptyPayload): void; middlePointerDownHandler(context: KmtInputContext, payload: PointerEventPayload): void; } /** * @description The possible target states of the ready to select state. * * @category Input State Machine */ export type ReadyToSelectStatePossibleTargetStates = "IDLE" | "SELECTING"; /** * @description The context for the ready to select state. * * @category Input State Machine */ export type SelectionContext = { setSelectionEndPoint: (point: Point) => void; toggleSelectionBox: (show: boolean) => void; cleanup: () => void; setup: () => void; canvas: HTMLCanvasElement; }; /** * @description The ready to select state of the keyboard mouse and trackpad input state machine. * * @category Input State Machine */ export declare class ReadyToSelectState extends TemplateState { constructor(); leftPointerMove: any; protected _eventReactions: EventReactions; get eventReactions(): EventReactions; } /** * @description The ready to pan via space bar state of the keyboard mouse and trackpad input state machine. * * @category Input State Machine */ export declare class ReadyToPanViaSpaceBarState extends TemplateState { constructor(); protected _eventReactions: EventReactions; get eventReactions(): EventReactions; leftPointerDownHandler(context: KmtInputContext, payload: PointerEventPayload): void; spacebarUpHandler(context: KmtInputContext, payload: EmptyPayload): void; } /** * @description The initial pan state of the keyboard mouse and trackpad input state machine. * * @category Input State Machine */ export declare class InitialPanState extends TemplateState { constructor(); protected _eventReactions: EventReactions; get eventReactions(): EventReactions; leftPointerMoveHandler(context: KmtInputContext, payload: PointerEventPayload): void; leftPointerUpHandler(context: KmtInputContext, payload: PointerEventPayload): void; } /** * @description The ready to pan via scroll wheel state of the keyboard mouse and trackpad input state machine. * * @category Input State Machine */ export declare class ReadyToPanViaScrollWheelState extends TemplateState { constructor(); protected _eventReactions: EventReactions; get eventReactions(): EventReactions; middlePointerMoveHandler(context: KmtInputContext, payload: PointerEventPayload): void; middlePointerUpHandler(context: KmtInputContext, payload: PointerEventPayload): void; } /** * @description The pan state of the keyboard mouse and trackpad input state machine. * * @category Input State Machine */ export declare class PanState extends TemplateState { constructor(); protected _eventReactions: EventReactions; get eventReactions(): EventReactions; leftPointerMoveHandler(context: KmtInputContext, payload: PointerEventPayload): void; spacebarUpHandler(context: KmtInputContext, payload: EmptyPayload): void; leftPointerUpHandler(context: KmtInputContext, payload: PointerEventPayload): void; } /** * @description The pan via scroll wheel state of the keyboard mouse and trackpad input state machine. * * @category Input State Machine */ export declare class PanViaScrollWheelState extends TemplateState { protected _eventReactions: EventReactions; get eventReactions(): EventReactions; middlePointerMoveHandler(context: KmtInputContext, payload: PointerEventPayload): void; middlePointerUpHandler(context: KmtInputContext, payload: PointerEventPayload): void; } export declare class KmtEmptyState extends TemplateState { constructor(); get eventReactions(): EventReactions; } export type KmtInputStateMachine = TemplateStateMachine; /** * @description Creates the keyboard mouse and trackpad input state machine. * * @category Input State Machine */ export declare function createKmtInputStateMachine(context: KmtInputContext): KmtInputStateMachine; export declare class KmtInputStateMachineWebWorkerProxy extends TemplateStateMachine { private _webworker; constructor(webworker: Worker); happens(event: keyof KmtInputEventMapping, payload: KmtInputEventMapping[keyof KmtInputEventMapping]): KmtInputStates | undefined; } export {};