core-graphics
Version:
A core library for creating shape-based graphic editors
149 lines (146 loc) • 6.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.SceneModifierKey = exports.ButtonType = exports.EditorInputEventType = undefined;
exports.isEditorInputEvent = isEditorInputEvent;
exports.isShapeMouseDownEvent = isShapeMouseDownEvent;
exports.isShapeMouseUpEvent = isShapeMouseUpEvent;
exports.isShapeResizeHandleMouseDownEvent = isShapeResizeHandleMouseDownEvent;
exports.isShapeResizeHandleMouseUpEvent = isShapeResizeHandleMouseUpEvent;
exports.isBackgroundMouseDownEvent = isBackgroundMouseDownEvent;
exports.isBackgroundMouseUpEvent = isBackgroundMouseUpEvent;
exports.isMouseDownEvent = isMouseDownEvent;
exports.isMouseUpEvent = isMouseUpEvent;
exports.isMouseMoveEvent = isMouseMoveEvent;
exports.isMouseEnterEvent = isMouseEnterEvent;
exports.isMouseLeaveEvent = isMouseLeaveEvent;
exports.isModKeyDownEvent = isModKeyDownEvent;
exports.isModKeyUpEvent = isModKeyUpEvent;
exports.canvasShapeMouseDown = canvasShapeMouseDown;
exports.canvasShapeMouseUp = canvasShapeMouseUp;
exports.canvasShapeResizeHandleMouseDown = canvasShapeResizeHandleMouseDown;
exports.canvasShapeResizeHandleMouseUp = canvasShapeResizeHandleMouseUp;
exports.canvasBackgroundMouseDown = canvasBackgroundMouseDown;
exports.canvasBackgroundMouseUp = canvasBackgroundMouseUp;
exports.canvasMouseDown = canvasMouseDown;
exports.canvasMouseUp = canvasMouseUp;
exports.canvasMouseMove = canvasMouseMove;
exports.canvasMouseEnter = canvasMouseEnter;
exports.canvasMouseLeave = canvasMouseLeave;
exports.canvasModifierKeyDown = canvasModifierKeyDown;
exports.canvasModifierKeyUp = canvasModifierKeyUp;
var _editorEvents = require("../editor-events");
var EditorInputEventType = exports.EditorInputEventType = undefined;
(function (EditorInputEventType) {
EditorInputEventType[EditorInputEventType["ShapeMouseDown"] = 0] = "ShapeMouseDown";
EditorInputEventType[EditorInputEventType["ShapeMouseUp"] = 1] = "ShapeMouseUp";
EditorInputEventType[EditorInputEventType["ShapeResizeHandleMouseDown"] = 2] = "ShapeResizeHandleMouseDown";
EditorInputEventType[EditorInputEventType["ShapeResizeHandleMouseUp"] = 3] = "ShapeResizeHandleMouseUp";
EditorInputEventType[EditorInputEventType["SelectedShapesMouseDown"] = 4] = "SelectedShapesMouseDown";
EditorInputEventType[EditorInputEventType["SelectedShapesMouseUp"] = 5] = "SelectedShapesMouseUp";
EditorInputEventType[EditorInputEventType["BackgroundMouseDown"] = 6] = "BackgroundMouseDown";
EditorInputEventType[EditorInputEventType["BackgroundMouseUp"] = 7] = "BackgroundMouseUp";
EditorInputEventType[EditorInputEventType["MouseDown"] = 8] = "MouseDown";
EditorInputEventType[EditorInputEventType["MouseUp"] = 9] = "MouseUp";
EditorInputEventType[EditorInputEventType["MouseMove"] = 10] = "MouseMove";
EditorInputEventType[EditorInputEventType["MouseEnter"] = 11] = "MouseEnter";
EditorInputEventType[EditorInputEventType["MouseLeave"] = 12] = "MouseLeave";
EditorInputEventType[EditorInputEventType["ModKeyDown"] = 13] = "ModKeyDown";
EditorInputEventType[EditorInputEventType["ModKeyUp"] = 14] = "ModKeyUp";
})(EditorInputEventType || (exports.EditorInputEventType = EditorInputEventType = {}));
function isEditorInputEvent(base) {
return base.type === _editorEvents.EditorEventType.Input;
}
var ButtonType = exports.ButtonType = undefined;
(function (ButtonType) {
ButtonType[ButtonType["Left"] = 0] = "Left";
ButtonType[ButtonType["Right"] = 1] = "Right";
})(ButtonType || (exports.ButtonType = ButtonType = {}));
var SceneModifierKey = exports.SceneModifierKey = undefined;
(function (SceneModifierKey) {
SceneModifierKey[SceneModifierKey["Ctrl"] = 0] = "Ctrl";
SceneModifierKey[SceneModifierKey["Shift"] = 1] = "Shift";
SceneModifierKey[SceneModifierKey["Alt"] = 2] = "Alt";
})(SceneModifierKey || (exports.SceneModifierKey = SceneModifierKey = {}));
function isShapeMouseDownEvent(base) {
return base.subType === EditorInputEventType.ShapeMouseDown;
}
function isShapeMouseUpEvent(base) {
return base.subType === EditorInputEventType.ShapeMouseUp;
}
function isShapeResizeHandleMouseDownEvent(base) {
return base.subType === EditorInputEventType.ShapeResizeHandleMouseDown;
}
function isShapeResizeHandleMouseUpEvent(base) {
return base.subType === EditorInputEventType.ShapeResizeHandleMouseUp;
}
function isBackgroundMouseDownEvent(base) {
return base.subType === EditorInputEventType.BackgroundMouseDown;
}
function isBackgroundMouseUpEvent(base) {
return base.subType === EditorInputEventType.BackgroundMouseUp;
}
function isMouseDownEvent(base) {
return base.subType === EditorInputEventType.MouseDown;
}
function isMouseUpEvent(base) {
return base.subType === EditorInputEventType.MouseUp;
}
function isMouseMoveEvent(base) {
return base.subType === EditorInputEventType.MouseMove;
}
function isMouseEnterEvent(base) {
return base.subType === EditorInputEventType.MouseEnter;
}
function isMouseLeaveEvent(base) {
return base.subType === EditorInputEventType.MouseLeave;
}
function isModKeyDownEvent(base) {
return base.subType === EditorInputEventType.ModKeyDown;
}
function isModKeyUpEvent(base) {
return base.subType === EditorInputEventType.ModKeyUp;
}
function evFact(subType, payload) {
return { type: _editorEvents.EditorEventType.Input, subType: subType, payload: payload };
}
function canvasShapeMouseDown(payload) {
return evFact(EditorInputEventType.ShapeMouseDown, payload);
}
function canvasShapeMouseUp(payload) {
return evFact(EditorInputEventType.ShapeMouseUp, payload);
}
function canvasShapeResizeHandleMouseDown(payload) {
return evFact(EditorInputEventType.ShapeResizeHandleMouseDown, payload);
}
function canvasShapeResizeHandleMouseUp(payload) {
return evFact(EditorInputEventType.ShapeResizeHandleMouseUp, payload);
}
function canvasBackgroundMouseDown(button) {
return evFact(EditorInputEventType.BackgroundMouseDown, { button: button });
}
function canvasBackgroundMouseUp(button) {
return evFact(EditorInputEventType.BackgroundMouseUp, { button: button });
}
function canvasMouseDown(payload) {
return evFact(EditorInputEventType.MouseDown, payload);
}
function canvasMouseUp(payload) {
return evFact(EditorInputEventType.MouseUp, payload);
}
function canvasMouseMove(payload) {
return evFact(EditorInputEventType.MouseMove, payload);
}
function canvasMouseEnter(payload) {
return evFact(EditorInputEventType.MouseEnter, payload);
}
function canvasMouseLeave(payload) {
return evFact(EditorInputEventType.MouseLeave, payload);
}
function canvasModifierKeyDown(key) {
return evFact(EditorInputEventType.ModKeyDown, { key: key });
}
function canvasModifierKeyUp(key) {
return evFact(EditorInputEventType.ModKeyUp, { key: key });
}