UNPKG

@eclipse-glsp/client

Version:

A sprotty-based client for GLSP

105 lines 4.41 kB
"use strict"; /******************************************************************************** * Copyright (c) 2023-2024 EclipseSource and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * This Source Code may also be made available under the following Secondary * Licenses when the conditions for such availability set forth in the Eclipse * Public License v. 2.0 are satisfied: GNU General Public License, version 2 * with the GNU Classpath Exception which is available at * https://www.gnu.org/software/classpath/license.html. * * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ Object.defineProperty(exports, "__esModule", { value: true }); exports.Direction = exports.getDirectionFrom = exports.getDirectionOf = exports.isSelectionBounds = exports.SelectionBounds = exports.SELECTION_BOUNDS = exports.isHelperLine = exports.HelperLine = exports.HELPER_LINE = exports.HelperLineType = void 0; const sprotty_1 = require("@eclipse-glsp/sprotty"); const uuid_1 = require("uuid"); const model_1 = require("../change-bounds/model"); exports.HelperLineType = { Left: 'left', Right: 'right', Center: 'center', Top: 'top', Bottom: 'bottom', Middle: 'middle', LeftRight: 'left-right', RightLeft: 'right-left', BottomTop: 'bottom-top', TopBottom: 'top-bottom' }; exports.HELPER_LINE = 'helper-line'; class HelperLine extends sprotty_1.GChildElement { constructor(startPoint = sprotty_1.Point.ORIGIN, endPoint = sprotty_1.Point.ORIGIN, lineType = exports.HelperLineType.Left) { super(); this.startPoint = startPoint; this.endPoint = endPoint; this.lineType = lineType; this.id = (0, uuid_1.v4)(); this.type = exports.HELPER_LINE; } get isLeft() { return this.lineType === exports.HelperLineType.Left || this.lineType === exports.HelperLineType.LeftRight; } get isRight() { return this.lineType === exports.HelperLineType.Right || this.lineType === exports.HelperLineType.RightLeft; } get isTop() { return this.lineType === exports.HelperLineType.Top || this.lineType === exports.HelperLineType.TopBottom; } get isBottom() { return this.lineType === exports.HelperLineType.Bottom || this.lineType === exports.HelperLineType.BottomTop; } get isMiddle() { return this.lineType === exports.HelperLineType.Middle; } get isCenter() { return this.lineType === exports.HelperLineType.Center; } } exports.HelperLine = HelperLine; function isHelperLine(element) { return element.type === exports.HELPER_LINE; } exports.isHelperLine = isHelperLine; exports.SELECTION_BOUNDS = 'selection-bounds'; class SelectionBounds extends sprotty_1.GShapeElement { constructor(bounds) { super(); this.id = (0, uuid_1.v4)(); this.type = exports.SELECTION_BOUNDS; if (bounds) { this.bounds = bounds; } } } exports.SelectionBounds = SelectionBounds; function isSelectionBounds(element) { return element.type === exports.SELECTION_BOUNDS; } exports.isSelectionBounds = isSelectionBounds; // kept for backwards compatibility after moving the definition exports.getDirectionOf = sprotty_1.Vector.direction; function getDirectionFrom(resize) { if (resize === model_1.ResizeHandleLocation.TopLeft) { return [sprotty_1.Direction.Up, sprotty_1.Direction.Left]; } if (resize === model_1.ResizeHandleLocation.TopRight) { return [sprotty_1.Direction.Up, sprotty_1.Direction.Right]; } if (resize === model_1.ResizeHandleLocation.BottomLeft) { return [sprotty_1.Direction.Down, sprotty_1.Direction.Left]; } if (resize === model_1.ResizeHandleLocation.BottomRight) { return [sprotty_1.Direction.Down, sprotty_1.Direction.Right]; } return []; } exports.getDirectionFrom = getDirectionFrom; // re-export for backwards compatibility after moving the definition var sprotty_2 = require("@eclipse-glsp/sprotty"); Object.defineProperty(exports, "Direction", { enumerable: true, get: function () { return sprotty_2.Direction; } }); //# sourceMappingURL=model.js.map