import { AppObjectController } from "@vived/core";
import { MouseInputEntity, } from "../../../MouseInput";
import { PanTransformUC } from "../../UC";
export class PanTransformMC extends AppObjectController {
    constructor(appObject) {
        super(appObject, PanTransformMC.type);
        this.doPan = false;
        this.allow = (e) => {
            return true;
        };
        this.onDown = (e) => {
            this.doPan = false;
            if (!this.allow(e))
                return;
            this.panUC?.initializePixel(e.position);
            this.doPan = true;
        };
        this.onMove = (e) => {
            if (!this.doPan)
                return;
            this.panUC?.updatePixel(e.position);
        };
        this.onUp = () => {
            this.doPan = false;
            this.panUC?.finish();
        };
        this.panUC = appObject.getComponent(PanTransformUC.type);
        if (!this.panUC) {
            this.error("Controller has been added to an App Object that does not have PanTransformUC. Add one first.");
            return;
        }
        const mouseInput = MouseInputEntity.get(this.appObjects);
        if (mouseInput) {
            mouseInput.registerController(this);
        }
        else {
            this.warn("Unable to find MouseInputEntity");
        }
    }
}
PanTransformMC.type = "PanTransformMC";
//# sourceMappingURL=PanTransformMC.js.map