"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DragScaleTransformMC = void 0;
const core_1 = require("@vived/core");
const MouseInput_1 = require("../../../MouseInput");
const UC_1 = require("../../UC");
class DragScaleTransformMC extends core_1.AppObjectController {
    constructor(appObject) {
        super(appObject, DragScaleTransformMC.type);
        this.isDragging = false;
        this.allow = (e) => {
            return true;
        };
        this.onDown = (e) => {
            this.isDragging = false;
            if (!this.allow(e))
                return;
            const pixelPosition = e.position;
            this.scaleUC?.initializePixel(pixelPosition);
            this.isDragging = true;
        };
        this.onMove = (e) => {
            if (!this.isDragging)
                return;
            this.scaleUC?.updatePixel(e.position);
        };
        this.onUp = () => {
            this.isDragging = false;
            this.scaleUC?.finish();
        };
        this.scaleUC = appObject.getComponent(UC_1.ScaleTransformUC.type);
        if (!this.scaleUC) {
            this.error("App Object that does not have ScaleTransformUC");
            return;
        }
        const mouseInput = MouseInput_1.MouseInputEntity.get(this.appObjects);
        if (mouseInput) {
            mouseInput.registerController(this);
        }
        else {
            this.warn("Unable to find MouseInputEntity");
        }
    }
}
exports.DragScaleTransformMC = DragScaleTransformMC;
DragScaleTransformMC.type = "DragScaleTransformMC";
//# sourceMappingURL=DragScaleTransformMC.js.map