import { AppObjectController } from "@vived/core";
import { MouseInputEntity, } from "../../../MouseInput";
import { ScaleTransformUC } from "../../UC";
export class DragScaleTransformMC extends 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(ScaleTransformUC.type);
        if (!this.scaleUC) {
            this.error("App Object that does not have ScaleTransformUC");
            return;
        }
        const mouseInput = MouseInputEntity.get(this.appObjects);
        if (mouseInput) {
            mouseInput.registerController(this);
        }
        else {
            this.warn("Unable to find MouseInputEntity");
        }
    }
}
DragScaleTransformMC.type = "DragScaleTransformMC";
//# sourceMappingURL=DragScaleTransformMC.js.map