"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PanTransformMC = void 0;
const core_1 = require("@vived/core");
const MouseInput_1 = require("../../../MouseInput");
const UC_1 = require("../../UC");
class PanTransformMC extends core_1.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(UC_1.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 = MouseInput_1.MouseInputEntity.get(this.appObjects);
        if (mouseInput) {
            mouseInput.registerController(this);
        }
        else {
            this.warn("Unable to find MouseInputEntity");
        }
    }
}
exports.PanTransformMC = PanTransformMC;
PanTransformMC.type = "PanTransformMC";
//# sourceMappingURL=PanTransformMC.js.map