UNPKG

@gorpacrate/core-graphics

Version:

A core library for creating shape-based graphic editors

113 lines 5.65 kB
"use strict"; exports.__esModule = true; var editor_events_1 = require("../editor-events"); var EditorShapeEventType; (function (EditorShapeEventType) { EditorShapeEventType[EditorShapeEventType["AddShape"] = 0] = "AddShape"; EditorShapeEventType[EditorShapeEventType["RemoveShapes"] = 1] = "RemoveShapes"; EditorShapeEventType[EditorShapeEventType["RemoveSelectedShapes"] = 2] = "RemoveSelectedShapes"; EditorShapeEventType[EditorShapeEventType["RemoveAllShapes"] = 3] = "RemoveAllShapes"; EditorShapeEventType[EditorShapeEventType["UpdateCustomParams"] = 4] = "UpdateCustomParams"; EditorShapeEventType[EditorShapeEventType["MoveSelectedShapes"] = 5] = "MoveSelectedShapes"; EditorShapeEventType[EditorShapeEventType["SendShapesBackward"] = 6] = "SendShapesBackward"; EditorShapeEventType[EditorShapeEventType["SendShapesForward"] = 7] = "SendShapesForward"; EditorShapeEventType[EditorShapeEventType["SendShapesToBack"] = 8] = "SendShapesToBack"; EditorShapeEventType[EditorShapeEventType["SendShapesToFront"] = 9] = "SendShapesToFront"; })(EditorShapeEventType = exports.EditorShapeEventType || (exports.EditorShapeEventType = {})); function isEditorShapeEvent(base) { return (base.type === editor_events_1.EditorEventType.Shape); } exports.isEditorShapeEvent = isEditorShapeEvent; function isAddShapeEditorEvent(base) { return (base.subType === EditorShapeEventType.AddShape); } exports.isAddShapeEditorEvent = isAddShapeEditorEvent; function isRemoveShapesEvent(base) { return (base.subType === EditorShapeEventType.RemoveShapes); } exports.isRemoveShapesEvent = isRemoveShapesEvent; function isRemoveSelectedShapesEvent(base) { return (base.subType === EditorShapeEventType.RemoveSelectedShapes); } exports.isRemoveSelectedShapesEvent = isRemoveSelectedShapesEvent; function isRemoveAllShapesEvent(base) { return (base.subType === EditorShapeEventType.RemoveAllShapes); } exports.isRemoveAllShapesEvent = isRemoveAllShapesEvent; function isUpdateShapeCustomParamsEvent(base) { return (base.subType === EditorShapeEventType.UpdateCustomParams); } exports.isUpdateShapeCustomParamsEvent = isUpdateShapeCustomParamsEvent; function isMoveSelectedShapesEvent(base) { return (base.subType === EditorShapeEventType.MoveSelectedShapes); } exports.isMoveSelectedShapesEvent = isMoveSelectedShapesEvent; function isSendShapesBackwardEvent(base) { return (base.subType === EditorShapeEventType.SendShapesBackward); } exports.isSendShapesBackwardEvent = isSendShapesBackwardEvent; function isSendShapesForwardEvent(base) { return (base.subType === EditorShapeEventType.SendShapesForward); } exports.isSendShapesForwardEvent = isSendShapesForwardEvent; function isSendShapesToBackEvent(base) { return (base.subType === EditorShapeEventType.SendShapesToBack); } exports.isSendShapesToBackEvent = isSendShapesToBackEvent; function isSendShapesToFrontEvent(base) { return (base.subType === EditorShapeEventType.SendShapesToFront); } exports.isSendShapesToFrontEvent = isSendShapesToFrontEvent; function isChangeShapesOrderEvent(base) { return (isSendShapesBackwardEvent(base) || isSendShapesForwardEvent(base) || isSendShapesToBackEvent(base) || isSendShapesToFrontEvent(base)); } exports.isChangeShapesOrderEvent = isChangeShapesOrderEvent; function addShape(shapeData, params) { var _a = (params || {}).selectWhenAdded, selectWhenAdded = _a === void 0 ? false : _a; return { type: editor_events_1.EditorEventType.Shape, subType: EditorShapeEventType.AddShape, payload: { shapeData: shapeData, selectWhenAdded: selectWhenAdded } }; } exports.addShape = addShape; function removeShapes(ids) { return { type: editor_events_1.EditorEventType.Shape, subType: EditorShapeEventType.RemoveShapes, payload: { ids: ids } }; } exports.removeShapes = removeShapes; function removeSelectedShapes() { return { type: editor_events_1.EditorEventType.Shape, subType: EditorShapeEventType.RemoveSelectedShapes }; } exports.removeSelectedShapes = removeSelectedShapes; function removeAllShapes() { return { type: editor_events_1.EditorEventType.Shape, subType: EditorShapeEventType.RemoveAllShapes }; } exports.removeAllShapes = removeAllShapes; function updateShapeCustomParams(id, value) { return { type: editor_events_1.EditorEventType.Shape, subType: EditorShapeEventType.UpdateCustomParams, payload: { id: id, value: value } }; } exports.updateShapeCustomParams = updateShapeCustomParams; function moveSelectedShapes(dx, dy) { return { type: editor_events_1.EditorEventType.Shape, subType: EditorShapeEventType.MoveSelectedShapes, payload: { dx: dx, dy: dy } }; } exports.moveSelectedShapes = moveSelectedShapes; function sendShapesBackward(ids) { return { type: editor_events_1.EditorEventType.Shape, subType: EditorShapeEventType.SendShapesBackward, payload: { ids: ids } }; } exports.sendShapesBackward = sendShapesBackward; function sendShapesForward(ids) { return { type: editor_events_1.EditorEventType.Shape, subType: EditorShapeEventType.SendShapesForward, payload: { ids: ids } }; } exports.sendShapesForward = sendShapesForward; function sendShapesToBack(ids) { return { type: editor_events_1.EditorEventType.Shape, subType: EditorShapeEventType.SendShapesToBack, payload: { ids: ids } }; } exports.sendShapesToBack = sendShapesToBack; function sendShapesToFront(ids) { return { type: editor_events_1.EditorEventType.Shape, subType: EditorShapeEventType.SendShapesToFront, payload: { ids: ids } }; } exports.sendShapesToFront = sendShapesToFront; //# sourceMappingURL=shapes.js.map